@@ -822,6 +822,136 @@ pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId) const
822
822
return localVarResult;
823
823
});
824
824
}
825
+ pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::petsPost (boost::optional<std::shared_ptr<Page>> page) const
826
+ {
827
+
828
+
829
+ std::shared_ptr<const ApiConfiguration> localVarApiConfiguration ( m_ApiClient->getConfiguration () );
830
+ utility::string_t localVarPath = utility::conversions::to_string_t (" /pets" );
831
+
832
+ std::map<utility::string_t , utility::string_t > localVarQueryParams;
833
+ std::map<utility::string_t , utility::string_t > localVarHeaderParams ( localVarApiConfiguration->getDefaultHeaders () );
834
+ std::map<utility::string_t , utility::string_t > localVarFormParams;
835
+ std::map<utility::string_t , std::shared_ptr<HttpContent>> localVarFileParams;
836
+
837
+ std::unordered_set<utility::string_t > localVarResponseHttpContentTypes;
838
+ localVarResponseHttpContentTypes.insert ( utility::conversions::to_string_t (" application/json" ) );
839
+
840
+ utility::string_t localVarResponseHttpContentType;
841
+
842
+ // use JSON if possible
843
+ if ( localVarResponseHttpContentTypes.size () == 0 )
844
+ {
845
+ localVarResponseHttpContentType = utility::conversions::to_string_t (" application/json" );
846
+ }
847
+ // JSON
848
+ else if ( localVarResponseHttpContentTypes.find (utility::conversions::to_string_t (" application/json" )) != localVarResponseHttpContentTypes.end () )
849
+ {
850
+ localVarResponseHttpContentType = utility::conversions::to_string_t (" application/json" );
851
+ }
852
+ // multipart formdata
853
+ else if ( localVarResponseHttpContentTypes.find (utility::conversions::to_string_t (" multipart/form-data" )) != localVarResponseHttpContentTypes.end () )
854
+ {
855
+ localVarResponseHttpContentType = utility::conversions::to_string_t (" multipart/form-data" );
856
+ }
857
+ else
858
+ {
859
+ throw ApiException (400 , utility::conversions::to_string_t (" PetApi->petsPost does not produce any supported media type" ));
860
+ }
861
+
862
+ localVarHeaderParams[utility::conversions::to_string_t (" Accept" )] = localVarResponseHttpContentType;
863
+
864
+ std::unordered_set<utility::string_t > localVarConsumeHttpContentTypes;
865
+
866
+ if (page && *page != nullptr )
867
+ {
868
+ localVarQueryParams[utility::conversions::to_string_t (" page" )] = ApiClient::parameterToString (*page);
869
+ }
870
+
871
+ std::shared_ptr<IHttpBody> localVarHttpBody;
872
+ utility::string_t localVarRequestHttpContentType;
873
+
874
+ // use JSON if possible
875
+ if ( localVarConsumeHttpContentTypes.size () == 0 || localVarConsumeHttpContentTypes.find (utility::conversions::to_string_t (" application/json" )) != localVarConsumeHttpContentTypes.end () )
876
+ {
877
+ localVarRequestHttpContentType = utility::conversions::to_string_t (" application/json" );
878
+ }
879
+ // multipart formdata
880
+ else if ( localVarConsumeHttpContentTypes.find (utility::conversions::to_string_t (" multipart/form-data" )) != localVarConsumeHttpContentTypes.end () )
881
+ {
882
+ localVarRequestHttpContentType = utility::conversions::to_string_t (" multipart/form-data" );
883
+ }
884
+ else if (localVarConsumeHttpContentTypes.find (utility::conversions::to_string_t (" application/x-www-form-urlencoded" )) != localVarConsumeHttpContentTypes.end ())
885
+ {
886
+ localVarRequestHttpContentType = utility::conversions::to_string_t (" application/x-www-form-urlencoded" );
887
+ }
888
+ else
889
+ {
890
+ throw ApiException (415 , utility::conversions::to_string_t (" PetApi->petsPost does not consume any supported media type" ));
891
+ }
892
+
893
+
894
+ return m_ApiClient->callApi (localVarPath, utility::conversions::to_string_t (" POST" ), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
895
+ .then ([=, this ](web::http::http_response localVarResponse)
896
+ {
897
+ if (m_ApiClient->getResponseHandler ())
898
+ {
899
+ m_ApiClient->getResponseHandler ()(localVarResponse.status_code (), localVarResponse.headers ());
900
+ }
901
+
902
+ // 1xx - informational : OK
903
+ // 2xx - successful : OK
904
+ // 3xx - redirection : OK
905
+ // 4xx - client error : not OK
906
+ // 5xx - client error : not OK
907
+ if (localVarResponse.status_code () >= 400 )
908
+ {
909
+ throw ApiException (localVarResponse.status_code ()
910
+ , utility::conversions::to_string_t (" error calling petsPost: " ) + localVarResponse.reason_phrase ()
911
+ , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string (true ).get ()));
912
+ }
913
+
914
+ // check response content type
915
+ if (localVarResponse.headers ().has (utility::conversions::to_string_t (" Content-Type" )))
916
+ {
917
+ utility::string_t localVarContentType = localVarResponse.headers ()[utility::conversions::to_string_t (" Content-Type" )];
918
+ if ( localVarContentType.find (localVarResponseHttpContentType) == std::string::npos )
919
+ {
920
+ throw ApiException (500
921
+ , utility::conversions::to_string_t (" error calling petsPost: unexpected response type: " ) + localVarContentType
922
+ , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string (true ).get ()));
923
+ }
924
+ }
925
+
926
+ return localVarResponse.extract_string ();
927
+ })
928
+ .then ([=, this ](utility::string_t localVarResponse)
929
+ {
930
+ std::vector<std::shared_ptr<Pet>> localVarResult;
931
+
932
+ if (localVarResponseHttpContentType == utility::conversions::to_string_t (" application/json" ))
933
+ {
934
+ web::json::value localVarJson = web::json::value::parse (localVarResponse);
935
+ for ( auto & localVarItem : localVarJson.as_array () )
936
+ {
937
+ std::shared_ptr<Pet> localVarItemObj;
938
+ ModelBase::fromJson (localVarItem, localVarItemObj);
939
+ localVarResult.push_back (localVarItemObj);
940
+ }
941
+ }
942
+ // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
943
+ // {
944
+ // TODO multipart response parsing
945
+ // }
946
+ else
947
+ {
948
+ throw ApiException (500
949
+ , utility::conversions::to_string_t (" error calling petsPost: unsupported response type" ));
950
+ }
951
+
952
+ return localVarResult;
953
+ });
954
+ }
825
955
pplx::task<std::shared_ptr<Pet>> PetApi::updatePet (std::shared_ptr<Pet> pet) const
826
956
{
827
957
0 commit comments