clerk-http-client 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +87 -0
- data/README.md +360 -0
- data/Rakefile +10 -0
- data/bin/fmt +5 -0
- data/bin/generate +8 -0
- data/bin/setup +7 -0
- data/clerk-http-client.gemspec +41 -0
- data/docs/ActorToken.md +34 -0
- data/docs/ActorTokensApi.md +147 -0
- data/docs/AddDomainRequest.md +22 -0
- data/docs/Admin.md +24 -0
- data/docs/AllowListBlockListApi.md +421 -0
- data/docs/AllowlistIdentifier.md +32 -0
- data/docs/BetaFeaturesApi.md +217 -0
- data/docs/BlocklistIdentifier.md +30 -0
- data/docs/BlocklistIdentifiers.md +20 -0
- data/docs/CNameTarget.md +22 -0
- data/docs/ChangeProductionInstanceDomainRequest.md +20 -0
- data/docs/ClerkError.md +26 -0
- data/docs/ClerkErrors.md +20 -0
- data/docs/Client.md +34 -0
- data/docs/ClientsApi.md +221 -0
- data/docs/CreateActorTokenRequest.md +24 -0
- data/docs/CreateAllowlistIdentifierRequest.md +20 -0
- data/docs/CreateBlocklistIdentifierRequest.md +18 -0
- data/docs/CreateEmailAddressRequest.md +24 -0
- data/docs/CreateInvitationRequest.md +28 -0
- data/docs/CreateJWTTemplateRequest.md +30 -0
- data/docs/CreateOAuthApplicationRequest.md +24 -0
- data/docs/CreateOrganizationDomainRequest.md +22 -0
- data/docs/CreateOrganizationInvitationBulkRequestInner.md +28 -0
- data/docs/CreateOrganizationInvitationRequest.md +28 -0
- data/docs/CreateOrganizationMembershipRequest.md +20 -0
- data/docs/CreateOrganizationRequest.md +30 -0
- data/docs/CreatePhoneNumberRequest.md +26 -0
- data/docs/CreateRedirectURLRequest.md +18 -0
- data/docs/CreateSAMLConnectionRequest.md +34 -0
- data/docs/CreateSAMLConnectionRequestAttributeMapping.md +24 -0
- data/docs/CreateSessionTokenFromTemplate200Response.md +20 -0
- data/docs/CreateSignInTokenRequest.md +20 -0
- data/docs/CreateUserRequest.md +62 -0
- data/docs/DeletedObject.md +24 -0
- data/docs/DisableMFA200Response.md +18 -0
- data/docs/Domain.md +34 -0
- data/docs/Domains.md +20 -0
- data/docs/DomainsApi.md +286 -0
- data/docs/EmailAddress.md +32 -0
- data/docs/EmailAddressVerification.md +51 -0
- data/docs/EmailAddressesApi.md +289 -0
- data/docs/EmailSMSTemplatesApi.md +449 -0
- data/docs/GetOAuthAccessToken200ResponseInner.md +34 -0
- data/docs/IdentificationLink.md +20 -0
- data/docs/InstanceRestrictions.md +26 -0
- data/docs/InstanceSettingsApi.md +216 -0
- data/docs/Invitation.md +36 -0
- data/docs/InvitationsApi.md +223 -0
- data/docs/JWKSApi.md +74 -0
- data/docs/JWTTemplate.md +36 -0
- data/docs/JWTTemplatesApi.md +354 -0
- data/docs/MergeOrganizationMetadataRequest.md +20 -0
- data/docs/MiscellaneousApi.md +75 -0
- data/docs/OAuthApplication.md +42 -0
- data/docs/OAuthApplicationWithSecret.md +44 -0
- data/docs/OAuthApplications.md +20 -0
- data/docs/OAuthApplicationsApi.md +433 -0
- data/docs/OTP.md +24 -0
- data/docs/Oauth.md +28 -0
- data/docs/OauthError.md +47 -0
- data/docs/Organization.md +40 -0
- data/docs/OrganizationDomain.md +38 -0
- data/docs/OrganizationDomainApi.md +81 -0
- data/docs/OrganizationDomainVerification.md +24 -0
- data/docs/OrganizationDomains.md +20 -0
- data/docs/OrganizationDomainsApi.md +231 -0
- data/docs/OrganizationInvitation.md +38 -0
- data/docs/OrganizationInvitationWithPublicOrganizationData.md +40 -0
- data/docs/OrganizationInvitationWithPublicOrganizationDataPublicOrganizationData.md +26 -0
- data/docs/OrganizationInvitations.md +20 -0
- data/docs/OrganizationInvitationsApi.md +533 -0
- data/docs/OrganizationInvitationsWithPublicOrganizationData.md +20 -0
- data/docs/OrganizationMembership.md +38 -0
- data/docs/OrganizationMembershipPublicUserData.md +30 -0
- data/docs/OrganizationMemberships.md +20 -0
- data/docs/OrganizationMembershipsApi.md +453 -0
- data/docs/OrganizationSettings.md +36 -0
- data/docs/OrganizationWithLogo.md +46 -0
- data/docs/Organizations.md +20 -0
- data/docs/OrganizationsApi.md +591 -0
- data/docs/Passkey.md +26 -0
- data/docs/PhoneNumber.md +38 -0
- data/docs/PhoneNumberVerification.md +49 -0
- data/docs/PhoneNumbersApi.md +289 -0
- data/docs/PreviewTemplateRequest.md +24 -0
- data/docs/ProxyCheck.md +32 -0
- data/docs/ProxyChecksApi.md +77 -0
- data/docs/RedirectURL.md +26 -0
- data/docs/RedirectURLsApi.md +284 -0
- data/docs/RevokeInvitation200Response.md +36 -0
- data/docs/RevokeOrganizationInvitationRequest.md +18 -0
- data/docs/SAML.md +28 -0
- data/docs/SAMLAccount.md +38 -0
- data/docs/SAMLAccountSamlConnection.md +47 -0
- data/docs/SAMLAccountVerification.md +49 -0
- data/docs/SAMLConnection.md +38 -0
- data/docs/SAMLConnections.md +20 -0
- data/docs/SAMLConnectionsApi.md +363 -0
- data/docs/SchemasPasskey.md +26 -0
- data/docs/SchemasPasskeyVerification.md +47 -0
- data/docs/SchemasSAMLConnection.md +60 -0
- data/docs/SchemasSAMLConnectionAttributeMapping.md +24 -0
- data/docs/Session.md +42 -0
- data/docs/SessionLatestActivity.md +34 -0
- data/docs/SessionsApi.md +373 -0
- data/docs/SignInToken.md +32 -0
- data/docs/SignInTokensApi.md +147 -0
- data/docs/SignUp.md +62 -0
- data/docs/SignUpsApi.md +79 -0
- data/docs/SvixURL.md +18 -0
- data/docs/TOTP.md +28 -0
- data/docs/Template.md +60 -0
- data/docs/TestingToken.md +22 -0
- data/docs/TestingTokensApi.md +74 -0
- data/docs/Ticket.md +24 -0
- data/docs/ToggleTemplateDeliveryRequest.md +18 -0
- data/docs/TotalCount.md +20 -0
- data/docs/UpdateDomainRequest.md +22 -0
- data/docs/UpdateEmailAddressRequest.md +20 -0
- data/docs/UpdateInstanceAuthConfig200Response.md +28 -0
- data/docs/UpdateInstanceAuthConfigRequest.md +28 -0
- data/docs/UpdateInstanceOrganizationSettingsRequest.md +30 -0
- data/docs/UpdateInstanceRequest.md +34 -0
- data/docs/UpdateInstanceRestrictionsRequest.md +26 -0
- data/docs/UpdateOAuthApplicationRequest.md +22 -0
- data/docs/UpdateOrganizationDomainRequest.md +20 -0
- data/docs/UpdateOrganizationMembershipMetadataRequest.md +20 -0
- data/docs/UpdateOrganizationMembershipRequest.md +18 -0
- data/docs/UpdateOrganizationRequest.md +30 -0
- data/docs/UpdatePhoneNumberRequest.md +22 -0
- data/docs/UpdateProductionInstanceDomainRequest.md +18 -0
- data/docs/UpdateSAMLConnectionRequest.md +42 -0
- data/docs/UpdateSAMLConnectionRequestAttributeMapping.md +24 -0
- data/docs/UpdateSignUpRequest.md +18 -0
- data/docs/UpdateUserMetadataRequest.md +22 -0
- data/docs/UpdateUserRequest.md +66 -0
- data/docs/UpsertTemplateRequest.md +30 -0
- data/docs/User.md +94 -0
- data/docs/UsersApi.md +1829 -0
- data/docs/VerifyClientRequest.md +18 -0
- data/docs/VerifyDomainProxyRequest.md +20 -0
- data/docs/VerifyPassword200Response.md +18 -0
- data/docs/VerifyPasswordRequest.md +18 -0
- data/docs/VerifySessionRequest.md +18 -0
- data/docs/VerifyTOTP200Response.md +20 -0
- data/docs/VerifyTOTPRequest.md +18 -0
- data/docs/Web3Signature.md +28 -0
- data/docs/Web3Wallet.md +28 -0
- data/docs/Web3WalletVerification.md +49 -0
- data/docs/WebhooksApi.md +207 -0
- data/docs/WellKnownJWKS.md +18 -0
- data/docs/WellKnownJWKSKeysInner.md +28 -0
- data/git_push.sh +57 -0
- data/lib/clerk-http-client/api/actor_tokens_api.rb +157 -0
- data/lib/clerk-http-client/api/allow_list_block_list_api.rb +410 -0
- data/lib/clerk-http-client/api/beta_features_api.rb +228 -0
- data/lib/clerk-http-client/api/clients_api.rb +234 -0
- data/lib/clerk-http-client/api/domains_api.rb +292 -0
- data/lib/clerk-http-client/api/email_addresses_api.rb +298 -0
- data/lib/clerk-http-client/api/email_sms_templates_api.rb +488 -0
- data/lib/clerk-http-client/api/instance_settings_api.rb +232 -0
- data/lib/clerk-http-client/api/invitations_api.rb +241 -0
- data/lib/clerk-http-client/api/jwks_api.rb +81 -0
- data/lib/clerk-http-client/api/jwt_templates_api.rb +355 -0
- data/lib/clerk-http-client/api/miscellaneous_api.rb +85 -0
- data/lib/clerk-http-client/api/o_auth_applications_api.rb +440 -0
- data/lib/clerk-http-client/api/organization_domain_api.rb +104 -0
- data/lib/clerk-http-client/api/organization_domains_api.rb +258 -0
- data/lib/clerk-http-client/api/organization_invitations_api.rb +586 -0
- data/lib/clerk-http-client/api/organization_memberships_api.rb +499 -0
- data/lib/clerk-http-client/api/organizations_api.rb +606 -0
- data/lib/clerk-http-client/api/phone_numbers_api.rb +298 -0
- data/lib/clerk-http-client/api/proxy_checks_api.rb +92 -0
- data/lib/clerk-http-client/api/redirect_urls_api.rb +281 -0
- data/lib/clerk-http-client/api/saml_connections_api.rb +375 -0
- data/lib/clerk-http-client/api/sessions_api.rb +385 -0
- data/lib/clerk-http-client/api/sign_in_tokens_api.rb +157 -0
- data/lib/clerk-http-client/api/sign_ups_api.rb +98 -0
- data/lib/clerk-http-client/api/testing_tokens_api.rb +81 -0
- data/lib/clerk-http-client/api/users_api.rb +1828 -0
- data/lib/clerk-http-client/api/webhooks_api.rb +199 -0
- data/lib/clerk-http-client/api_client.rb +437 -0
- data/lib/clerk-http-client/api_error.rb +58 -0
- data/lib/clerk-http-client/configuration.rb +393 -0
- data/lib/clerk-http-client/models/actor_token.rb +385 -0
- data/lib/clerk-http-client/models/add_domain_request.rb +249 -0
- data/lib/clerk-http-client/models/admin.rb +303 -0
- data/lib/clerk-http-client/models/allowlist_identifier.rb +327 -0
- data/lib/clerk-http-client/models/blocklist_identifier.rb +318 -0
- data/lib/clerk-http-client/models/blocklist_identifiers.rb +240 -0
- data/lib/clerk-http-client/models/c_name_target.rb +254 -0
- data/lib/clerk-http-client/models/change_production_instance_domain_request.rb +225 -0
- data/lib/clerk-http-client/models/clerk_error.rb +271 -0
- data/lib/clerk-http-client/models/clerk_errors.rb +232 -0
- data/lib/clerk-http-client/models/client.rb +380 -0
- data/lib/clerk-http-client/models/create_actor_token_request.rb +263 -0
- data/lib/clerk-http-client/models/create_allowlist_identifier_request.rb +234 -0
- data/lib/clerk-http-client/models/create_blocklist_identifier_request.rb +222 -0
- data/lib/clerk-http-client/models/create_email_address_request.rb +247 -0
- data/lib/clerk-http-client/models/create_invitation_request.rb +303 -0
- data/lib/clerk-http-client/models/create_jwt_template_request.rb +327 -0
- data/lib/clerk-http-client/models/create_o_auth_application_request.rb +261 -0
- data/lib/clerk-http-client/models/create_organization_domain_request.rb +236 -0
- data/lib/clerk-http-client/models/create_organization_invitation_bulk_request_inner.rb +280 -0
- data/lib/clerk-http-client/models/create_organization_invitation_request.rb +280 -0
- data/lib/clerk-http-client/models/create_organization_membership_request.rb +239 -0
- data/lib/clerk-http-client/models/create_organization_request.rb +289 -0
- data/lib/clerk-http-client/models/create_phone_number_request.rb +258 -0
- data/lib/clerk-http-client/models/create_redirect_url_request.rb +215 -0
- data/lib/clerk-http-client/models/create_saml_connection_request.rb +355 -0
- data/lib/clerk-http-client/models/create_saml_connection_request_attribute_mapping.rb +242 -0
- data/lib/clerk-http-client/models/create_session_token_from_template200_response.rb +257 -0
- data/lib/clerk-http-client/models/create_sign_in_token_request.rb +227 -0
- data/lib/clerk-http-client/models/create_user_request.rb +453 -0
- data/lib/clerk-http-client/models/deleted_object.rb +255 -0
- data/lib/clerk-http-client/models/disable_mfa200_response.rb +214 -0
- data/lib/clerk-http-client/models/domain.rb +368 -0
- data/lib/clerk-http-client/models/domains.rb +240 -0
- data/lib/clerk-http-client/models/email_address.rb +361 -0
- data/lib/clerk-http-client/models/email_address_verification.rb +106 -0
- data/lib/clerk-http-client/models/get_o_auth_access_token200_response_inner.rb +295 -0
- data/lib/clerk-http-client/models/identification_link.rb +271 -0
- data/lib/clerk-http-client/models/instance_restrictions.rb +285 -0
- data/lib/clerk-http-client/models/invitation.rb +388 -0
- data/lib/clerk-http-client/models/jwt_template.rb +387 -0
- data/lib/clerk-http-client/models/merge_organization_metadata_request.rb +225 -0
- data/lib/clerk-http-client/models/o_auth_application.rb +449 -0
- data/lib/clerk-http-client/models/o_auth_application_with_secret.rb +466 -0
- data/lib/clerk-http-client/models/o_auth_applications.rb +240 -0
- data/lib/clerk-http-client/models/oauth.rb +328 -0
- data/lib/clerk-http-client/models/oauth_error.rb +104 -0
- data/lib/clerk-http-client/models/organization.rb +413 -0
- data/lib/clerk-http-client/models/organization_domain.rb +364 -0
- data/lib/clerk-http-client/models/organization_domain_verification.rb +281 -0
- data/lib/clerk-http-client/models/organization_domains.rb +240 -0
- data/lib/clerk-http-client/models/organization_invitation.rb +342 -0
- data/lib/clerk-http-client/models/organization_invitation_with_public_organization_data.rb +351 -0
- data/lib/clerk-http-client/models/organization_invitation_with_public_organization_data_public_organization_data.rb +250 -0
- data/lib/clerk-http-client/models/organization_invitations.rb +240 -0
- data/lib/clerk-http-client/models/organization_invitations_with_public_organization_data.rb +240 -0
- data/lib/clerk-http-client/models/organization_membership.rb +346 -0
- data/lib/clerk-http-client/models/organization_membership_public_user_data.rb +272 -0
- data/lib/clerk-http-client/models/organization_memberships.rb +240 -0
- data/lib/clerk-http-client/models/organization_settings.rb +391 -0
- data/lib/clerk-http-client/models/organization_with_logo.rb +454 -0
- data/lib/clerk-http-client/models/organizations.rb +240 -0
- data/lib/clerk-http-client/models/otp.rb +315 -0
- data/lib/clerk-http-client/models/passkey.rb +324 -0
- data/lib/clerk-http-client/models/phone_number.rb +391 -0
- data/lib/clerk-http-client/models/phone_number_verification.rb +105 -0
- data/lib/clerk-http-client/models/preview_template_request.rb +246 -0
- data/lib/clerk-http-client/models/proxy_check.rb +367 -0
- data/lib/clerk-http-client/models/redirect_url.rb +321 -0
- data/lib/clerk-http-client/models/revoke_invitation200_response.rb +395 -0
- data/lib/clerk-http-client/models/revoke_organization_invitation_request.rb +216 -0
- data/lib/clerk-http-client/models/saml.rb +331 -0
- data/lib/clerk-http-client/models/saml_account.rb +381 -0
- data/lib/clerk-http-client/models/saml_account_saml_connection.rb +104 -0
- data/lib/clerk-http-client/models/saml_account_verification.rb +105 -0
- data/lib/clerk-http-client/models/saml_connection.rb +362 -0
- data/lib/clerk-http-client/models/saml_connections.rb +240 -0
- data/lib/clerk-http-client/models/schemas_passkey.rb +310 -0
- data/lib/clerk-http-client/models/schemas_passkey_verification.rb +104 -0
- data/lib/clerk-http-client/models/schemas_saml_connection.rb +541 -0
- data/lib/clerk-http-client/models/schemas_saml_connection_attribute_mapping.rb +241 -0
- data/lib/clerk-http-client/models/session.rb +444 -0
- data/lib/clerk-http-client/models/session_latest_activity.rb +300 -0
- data/lib/clerk-http-client/models/sign_in_token.rb +368 -0
- data/lib/clerk-http-client/models/sign_up.rb +517 -0
- data/lib/clerk-http-client/models/svix_url.rb +221 -0
- data/lib/clerk-http-client/models/template.rb +460 -0
- data/lib/clerk-http-client/models/testing_token.rb +289 -0
- data/lib/clerk-http-client/models/ticket.rb +303 -0
- data/lib/clerk-http-client/models/toggle_template_delivery_request.rb +216 -0
- data/lib/clerk-http-client/models/total_count.rb +272 -0
- data/lib/clerk-http-client/models/totp.rb +289 -0
- data/lib/clerk-http-client/models/update_domain_request.rb +238 -0
- data/lib/clerk-http-client/models/update_email_address_request.rb +227 -0
- data/lib/clerk-http-client/models/update_instance_auth_config200_response.rb +294 -0
- data/lib/clerk-http-client/models/update_instance_auth_config_request.rb +273 -0
- data/lib/clerk-http-client/models/update_instance_organization_settings_request.rb +277 -0
- data/lib/clerk-http-client/models/update_instance_request.rb +300 -0
- data/lib/clerk-http-client/models/update_instance_restrictions_request.rb +255 -0
- data/lib/clerk-http-client/models/update_o_auth_application_request.rb +237 -0
- data/lib/clerk-http-client/models/update_organization_domain_request.rb +227 -0
- data/lib/clerk-http-client/models/update_organization_membership_metadata_request.rb +225 -0
- data/lib/clerk-http-client/models/update_organization_membership_request.rb +222 -0
- data/lib/clerk-http-client/models/update_organization_request.rb +279 -0
- data/lib/clerk-http-client/models/update_phone_number_request.rb +238 -0
- data/lib/clerk-http-client/models/update_production_instance_domain_request.rb +215 -0
- data/lib/clerk-http-client/models/update_saml_connection_request.rb +347 -0
- data/lib/clerk-http-client/models/update_saml_connection_request_attribute_mapping.rb +242 -0
- data/lib/clerk-http-client/models/update_sign_up_request.rb +216 -0
- data/lib/clerk-http-client/models/update_user_metadata_request.rb +241 -0
- data/lib/clerk-http-client/models/update_user_request.rb +472 -0
- data/lib/clerk-http-client/models/upsert_template_request.rb +278 -0
- data/lib/clerk-http-client/models/user.rb +633 -0
- data/lib/clerk-http-client/models/verify_client_request.rb +215 -0
- data/lib/clerk-http-client/models/verify_domain_proxy_request.rb +225 -0
- data/lib/clerk-http-client/models/verify_password200_response.rb +214 -0
- data/lib/clerk-http-client/models/verify_password_request.rb +222 -0
- data/lib/clerk-http-client/models/verify_session_request.rb +215 -0
- data/lib/clerk-http-client/models/verify_totp200_response.rb +257 -0
- data/lib/clerk-http-client/models/verify_totp_request.rb +222 -0
- data/lib/clerk-http-client/models/web3_signature.rb +323 -0
- data/lib/clerk-http-client/models/web3_wallet.rb +327 -0
- data/lib/clerk-http-client/models/web3_wallet_verification.rb +105 -0
- data/lib/clerk-http-client/models/well_known_jwks.rb +216 -0
- data/lib/clerk-http-client/models/well_known_jwks_keys_inner.rb +259 -0
- data/lib/clerk-http-client/version.rb +15 -0
- data/lib/clerk-http-client.rb +321 -0
- data/openapitools.json +7 -0
- data/pkg/clerk-http-client-1.0.0.gem +0 -0
- data/resources/.DS_Store +0 -0
- data/resources/oas/bapi-2024-10-01.yml +7238 -0
- data/resources/templates/Gemfile.mustache +9 -0
- data/resources/templates/README.mustache +163 -0
- data/resources/templates/Rakefile.mustache +10 -0
- data/resources/templates/api.mustache +257 -0
- data/resources/templates/api_client.mustache +246 -0
- data/resources/templates/api_client_faraday_partial.mustache +200 -0
- data/resources/templates/api_client_httpx_partial.mustache +134 -0
- data/resources/templates/api_client_typhoeus_partial.mustache +161 -0
- data/resources/templates/api_doc.mustache +132 -0
- data/resources/templates/api_error.mustache +50 -0
- data/resources/templates/api_info.mustache +12 -0
- data/resources/templates/api_test.mustache +47 -0
- data/resources/templates/base_object.mustache +114 -0
- data/resources/templates/configuration.mustache +491 -0
- data/resources/templates/configuration_faraday_partial.mustache +40 -0
- data/resources/templates/configuration_httpx_partial.mustache +11 -0
- data/resources/templates/configuration_typhoeus_partial.mustache +41 -0
- data/resources/templates/gem.mustache +89 -0
- data/resources/templates/gemspec.mustache +41 -0
- data/resources/templates/git_push.sh.mustache +57 -0
- data/resources/templates/gitignore.mustache +39 -0
- data/resources/templates/gitlab-ci.mustache +26 -0
- data/resources/templates/model.mustache +33 -0
- data/resources/templates/model_doc.mustache +12 -0
- data/resources/templates/model_test.mustache +82 -0
- data/resources/templates/partial_anyof_module.mustache +94 -0
- data/resources/templates/partial_model_enum_class.mustache +23 -0
- data/resources/templates/partial_model_generic.mustache +377 -0
- data/resources/templates/partial_model_generic_doc.mustache +28 -0
- data/resources/templates/partial_oneof_module.mustache +137 -0
- data/resources/templates/partial_oneof_module_doc.mustache +93 -0
- data/resources/templates/rspec.mustache +2 -0
- data/resources/templates/rubocop.mustache +148 -0
- data/resources/templates/spec_helper.mustache +103 -0
- data/resources/templates/travis.mustache +11 -0
- data/resources/templates/version.mustache +7 -0
- data/sdk-generator-config.json +20 -0
- data/spec/api/actor_tokens_api_spec.rb +59 -0
- data/spec/api/allow_list_block_list_api_spec.rb +105 -0
- data/spec/api/beta_features_api_spec.rb +71 -0
- data/spec/api/clients_api_spec.rb +72 -0
- data/spec/api/domains_api_spec.rb +83 -0
- data/spec/api/email_addresses_api_spec.rb +84 -0
- data/spec/api/email_sms_templates_api_spec.rb +115 -0
- data/spec/api/instance_settings_api_spec.rb +71 -0
- data/spec/api/invitations_api_spec.rb +73 -0
- data/spec/api/jwks_api_spec.rb +46 -0
- data/spec/api/jwt_templates_api_spec.rb +94 -0
- data/spec/api/miscellaneous_api_spec.rb +48 -0
- data/spec/api/o_auth_applications_api_spec.rb +109 -0
- data/spec/api/organization_domain_api_spec.rb +49 -0
- data/spec/api/organization_domains_api_spec.rb +77 -0
- data/spec/api/organization_invitations_api_spec.rb +133 -0
- data/spec/api/organization_memberships_api_spec.rb +118 -0
- data/spec/api/organizations_api_spec.rb +139 -0
- data/spec/api/phone_numbers_api_spec.rb +84 -0
- data/spec/api/proxy_checks_api_spec.rb +47 -0
- data/spec/api/redirect_urls_api_spec.rb +82 -0
- data/spec/api/saml_connections_api_spec.rb +97 -0
- data/spec/api/sessions_api_spec.rb +101 -0
- data/spec/api/sign_in_tokens_api_spec.rb +59 -0
- data/spec/api/sign_ups_api_spec.rb +48 -0
- data/spec/api/testing_tokens_api_spec.rb +46 -0
- data/spec/api/users_api_spec.rb +366 -0
- data/spec/api/webhooks_api_spec.rb +68 -0
- data/spec/models/actor_token_spec.rb +92 -0
- data/spec/models/add_domain_request_spec.rb +48 -0
- data/spec/models/admin_spec.rb +62 -0
- data/spec/models/allowlist_identifier_spec.rb +86 -0
- data/spec/models/blocklist_identifier_spec.rb +80 -0
- data/spec/models/blocklist_identifiers_spec.rb +42 -0
- data/spec/models/c_name_target_spec.rb +48 -0
- data/spec/models/change_production_instance_domain_request_spec.rb +42 -0
- data/spec/models/clerk_error_spec.rb +60 -0
- data/spec/models/clerk_errors_spec.rb +42 -0
- data/spec/models/client_spec.rb +88 -0
- data/spec/models/create_actor_token_request_spec.rb +54 -0
- data/spec/models/create_allowlist_identifier_request_spec.rb +42 -0
- data/spec/models/create_blocklist_identifier_request_spec.rb +36 -0
- data/spec/models/create_email_address_request_spec.rb +54 -0
- data/spec/models/create_invitation_request_spec.rb +66 -0
- data/spec/models/create_jwt_template_request_spec.rb +72 -0
- data/spec/models/create_o_auth_application_request_spec.rb +54 -0
- data/spec/models/create_organization_domain_request_spec.rb +48 -0
- data/spec/models/create_organization_invitation_bulk_request_inner_spec.rb +66 -0
- data/spec/models/create_organization_invitation_request_spec.rb +66 -0
- data/spec/models/create_organization_membership_request_spec.rb +42 -0
- data/spec/models/create_organization_request_spec.rb +72 -0
- data/spec/models/create_phone_number_request_spec.rb +60 -0
- data/spec/models/create_redirect_url_request_spec.rb +36 -0
- data/spec/models/create_saml_connection_request_attribute_mapping_spec.rb +54 -0
- data/spec/models/create_saml_connection_request_spec.rb +88 -0
- data/spec/models/create_session_token_from_template200_response_spec.rb +46 -0
- data/spec/models/create_sign_in_token_request_spec.rb +42 -0
- data/spec/models/create_user_request_spec.rb +168 -0
- data/spec/models/deleted_object_spec.rb +54 -0
- data/spec/models/disable_mfa200_response_spec.rb +36 -0
- data/spec/models/domain_spec.rb +88 -0
- data/spec/models/domains_spec.rb +42 -0
- data/spec/models/email_address_spec.rb +82 -0
- data/spec/models/email_address_verification_spec.rb +32 -0
- data/spec/models/get_o_auth_access_token200_response_inner_spec.rb +84 -0
- data/spec/models/identification_link_spec.rb +46 -0
- data/spec/models/instance_restrictions_spec.rb +64 -0
- data/spec/models/invitation_spec.rb +98 -0
- data/spec/models/jwt_template_spec.rb +94 -0
- data/spec/models/merge_organization_metadata_request_spec.rb +42 -0
- data/spec/models/o_auth_application_spec.rb +112 -0
- data/spec/models/o_auth_application_with_secret_spec.rb +118 -0
- data/spec/models/o_auth_applications_spec.rb +42 -0
- data/spec/models/oauth_error_spec.rb +32 -0
- data/spec/models/oauth_spec.rb +74 -0
- data/spec/models/organization_domain_spec.rb +104 -0
- data/spec/models/organization_domain_verification_spec.rb +58 -0
- data/spec/models/organization_domains_spec.rb +42 -0
- data/spec/models/organization_invitation_spec.rb +100 -0
- data/spec/models/organization_invitation_with_public_organization_data_public_organization_data_spec.rb +60 -0
- data/spec/models/organization_invitation_with_public_organization_data_spec.rb +106 -0
- data/spec/models/organization_invitations_spec.rb +42 -0
- data/spec/models/organization_invitations_with_public_organization_data_spec.rb +42 -0
- data/spec/models/organization_membership_public_user_data_spec.rb +72 -0
- data/spec/models/organization_membership_spec.rb +100 -0
- data/spec/models/organization_memberships_spec.rb +42 -0
- data/spec/models/organization_settings_spec.rb +98 -0
- data/spec/models/organization_spec.rb +106 -0
- data/spec/models/organization_with_logo_spec.rb +124 -0
- data/spec/models/organizations_spec.rb +42 -0
- data/spec/models/otp_spec.rb +62 -0
- data/spec/models/passkey_spec.rb +72 -0
- data/spec/models/phone_number_spec.rb +100 -0
- data/spec/models/phone_number_verification_spec.rb +32 -0
- data/spec/models/preview_template_request_spec.rb +54 -0
- data/spec/models/proxy_check_spec.rb +82 -0
- data/spec/models/redirect_url_spec.rb +64 -0
- data/spec/models/revoke_invitation200_response_spec.rb +98 -0
- data/spec/models/revoke_organization_invitation_request_spec.rb +36 -0
- data/spec/models/saml_account_saml_connection_spec.rb +32 -0
- data/spec/models/saml_account_spec.rb +100 -0
- data/spec/models/saml_account_verification_spec.rb +32 -0
- data/spec/models/saml_connection_spec.rb +96 -0
- data/spec/models/saml_connections_spec.rb +42 -0
- data/spec/models/saml_spec.rb +74 -0
- data/spec/models/schemas_passkey_spec.rb +64 -0
- data/spec/models/schemas_passkey_verification_spec.rb +32 -0
- data/spec/models/schemas_saml_connection_attribute_mapping_spec.rb +54 -0
- data/spec/models/schemas_saml_connection_spec.rb +166 -0
- data/spec/models/session_latest_activity_spec.rb +84 -0
- data/spec/models/session_spec.rb +116 -0
- data/spec/models/sign_in_token_spec.rb +86 -0
- data/spec/models/sign_up_spec.rb +176 -0
- data/spec/models/svix_url_spec.rb +36 -0
- data/spec/models/template_spec.rb +166 -0
- data/spec/models/testing_token_spec.rb +52 -0
- data/spec/models/ticket_spec.rb +62 -0
- data/spec/models/toggle_template_delivery_request_spec.rb +36 -0
- data/spec/models/total_count_spec.rb +46 -0
- data/spec/models/totp_spec.rb +66 -0
- data/spec/models/update_domain_request_spec.rb +48 -0
- data/spec/models/update_email_address_request_spec.rb +42 -0
- data/spec/models/update_instance_auth_config200_response_spec.rb +70 -0
- data/spec/models/update_instance_auth_config_request_spec.rb +66 -0
- data/spec/models/update_instance_organization_settings_request_spec.rb +72 -0
- data/spec/models/update_instance_request_spec.rb +84 -0
- data/spec/models/update_instance_restrictions_request_spec.rb +60 -0
- data/spec/models/update_o_auth_application_request_spec.rb +48 -0
- data/spec/models/update_organization_domain_request_spec.rb +42 -0
- data/spec/models/update_organization_membership_metadata_request_spec.rb +42 -0
- data/spec/models/update_organization_membership_request_spec.rb +36 -0
- data/spec/models/update_organization_request_spec.rb +72 -0
- data/spec/models/update_phone_number_request_spec.rb +48 -0
- data/spec/models/update_production_instance_domain_request_spec.rb +36 -0
- data/spec/models/update_saml_connection_request_attribute_mapping_spec.rb +54 -0
- data/spec/models/update_saml_connection_request_spec.rb +108 -0
- data/spec/models/update_sign_up_request_spec.rb +36 -0
- data/spec/models/update_user_metadata_request_spec.rb +48 -0
- data/spec/models/update_user_request_spec.rb +180 -0
- data/spec/models/upsert_template_request_spec.rb +72 -0
- data/spec/models/user_spec.rb +268 -0
- data/spec/models/verify_client_request_spec.rb +36 -0
- data/spec/models/verify_domain_proxy_request_spec.rb +42 -0
- data/spec/models/verify_password200_response_spec.rb +36 -0
- data/spec/models/verify_password_request_spec.rb +36 -0
- data/spec/models/verify_session_request_spec.rb +36 -0
- data/spec/models/verify_totp200_response_spec.rb +46 -0
- data/spec/models/verify_totp_request_spec.rb +36 -0
- data/spec/models/web3_signature_spec.rb +74 -0
- data/spec/models/web3_wallet_spec.rb +70 -0
- data/spec/models/web3_wallet_verification_spec.rb +32 -0
- data/spec/models/well_known_jwks_keys_inner_spec.rb +66 -0
- data/spec/models/well_known_jwks_spec.rb +36 -0
- data/spec/spec_helper.rb +111 -0
- data/test.rb +2 -0
- metadata +782 -0
@@ -0,0 +1,163 @@
|
|
1
|
+
# {{gemName}}
|
2
|
+
|
3
|
+
{{moduleName}} - the Ruby gem for the {{appName}}
|
4
|
+
|
5
|
+
{{#appDescriptionWithNewLines}}
|
6
|
+
{{{.}}}
|
7
|
+
{{/appDescriptionWithNewLines}}
|
8
|
+
|
9
|
+
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
10
|
+
|
11
|
+
- API version: {{appVersion}}
|
12
|
+
- Package version: {{gemVersion}}
|
13
|
+
{{^hideGenerationTimestamp}}
|
14
|
+
- Build date: {{generatedDate}}
|
15
|
+
{{/hideGenerationTimestamp}}
|
16
|
+
- Generator version: {{generatorVersion}}
|
17
|
+
- Build package: {{generatorClass}}
|
18
|
+
{{#infoUrl}}
|
19
|
+
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
20
|
+
{{/infoUrl}}
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
### Build a gem
|
25
|
+
|
26
|
+
To build the Ruby code into a gem:
|
27
|
+
|
28
|
+
```shell
|
29
|
+
gem build {{{gemName}}}.gemspec
|
30
|
+
```
|
31
|
+
|
32
|
+
Then either install the gem locally:
|
33
|
+
|
34
|
+
```shell
|
35
|
+
gem install ./{{{gemName}}}-{{{gemVersion}}}.gem
|
36
|
+
```
|
37
|
+
|
38
|
+
(for development, run `gem install --dev ./{{{gemName}}}-{{{gemVersion}}}.gem` to install the development dependencies)
|
39
|
+
|
40
|
+
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
|
41
|
+
|
42
|
+
Finally add this to the Gemfile:
|
43
|
+
|
44
|
+
gem '{{{gemName}}}', '~> {{{gemVersion}}}'
|
45
|
+
|
46
|
+
### Install from Git
|
47
|
+
|
48
|
+
If the Ruby gem is hosted at a git repository: https://{{gitHost}}/{{gitUserId}}{{^gitUserId}}YOUR_GIT_USERNAME{{/gitUserId}}/{{gitRepoId}}{{^gitRepoId}}YOUR_GIT_REPO{{/gitRepoId}}, then add the following in the Gemfile:
|
49
|
+
|
50
|
+
gem '{{{gemName}}}', :git => 'https://{{gitHost}}/{{gitUserId}}{{^gitUserId}}YOUR_GIT_USERNAME{{/gitUserId}}/{{gitRepoId}}{{^gitRepoId}}YOUR_GIT_REPO{{/gitRepoId}}.git'
|
51
|
+
|
52
|
+
### Include the Ruby code directly
|
53
|
+
|
54
|
+
Include the Ruby code directly using `-I` as follows:
|
55
|
+
|
56
|
+
```shell
|
57
|
+
ruby -Ilib script.rb
|
58
|
+
```
|
59
|
+
|
60
|
+
## Getting Started
|
61
|
+
|
62
|
+
Please follow the [installation](#installation) procedure and then run the following code:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
# Load the gem
|
66
|
+
require '{{{gemName}}}'
|
67
|
+
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}
|
68
|
+
# Setup authorization
|
69
|
+
{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
70
|
+
# Configure HTTP basic authorization: {{{name}}}
|
71
|
+
config.username = 'YOUR_USERNAME'
|
72
|
+
config.password = 'YOUR_PASSWORD'{{/isBasicBasic}}{{#isBasicBearer}}
|
73
|
+
# Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}}
|
74
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
75
|
+
# Configure a proc to get access tokens in lieu of the static access_token configuration
|
76
|
+
config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' } {{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}
|
77
|
+
# Configure API key authorization: {{{name}}}
|
78
|
+
config.api_key['{{{keyParamName}}}'] = 'YOUR API KEY'
|
79
|
+
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
|
80
|
+
# config.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}}
|
81
|
+
# Configure OAuth2 access token for authorization: {{{name}}}
|
82
|
+
config.access_token = 'YOUR ACCESS TOKEN'
|
83
|
+
# Configure a proc to get access tokens in lieu of the static access_token configuration
|
84
|
+
config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' } {{/isOAuth}}
|
85
|
+
{{#isFaraday}}
|
86
|
+
# Configure faraday connection
|
87
|
+
config.configure_faraday_connection { |connection| 'YOUR CONNECTION CONFIG PROC' }
|
88
|
+
{{/isFaraday}}
|
89
|
+
{{#isHttpx}}
|
90
|
+
# Configure httpx session
|
91
|
+
config.configure_session { |session| 'YOUR CONNECTION CONFIG PROC' }
|
92
|
+
{{/isHttpx}}
|
93
|
+
{{/authMethods}}end
|
94
|
+
{{/hasAuthMethods}}
|
95
|
+
|
96
|
+
api_instance = {{{moduleName}}}::{{{classname}}}.new
|
97
|
+
{{#requiredParams}}
|
98
|
+
{{{paramName}}} = {{{vendorExtensions.x-ruby-example}}} # {{{dataType}}} | {{{description}}}
|
99
|
+
{{/requiredParams}}
|
100
|
+
{{#optionalParams}}
|
101
|
+
{{#-first}}
|
102
|
+
opts = {
|
103
|
+
{{/-first}}
|
104
|
+
{{{paramName}}}: {{{vendorExtensions.x-ruby-example}}}{{^-last}},{{/-last}} # {{{dataType}}} | {{{description}}}
|
105
|
+
{{#-last}}
|
106
|
+
}
|
107
|
+
{{/-last}}
|
108
|
+
{{/optionalParams}}
|
109
|
+
|
110
|
+
begin
|
111
|
+
{{#summary}} #{{{.}}}
|
112
|
+
{{/summary}} {{#returnType}}result = {{/returnType}}api_instance.{{{operationId}}}{{#hasParams}}({{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}){{/hasParams}}{{#returnType}}
|
113
|
+
p result{{/returnType}}
|
114
|
+
rescue {{{moduleName}}}::ApiError => e
|
115
|
+
puts "Exception when calling {{classname}}->{{{operationId}}}: #{e}"
|
116
|
+
end
|
117
|
+
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
118
|
+
```
|
119
|
+
|
120
|
+
## Documentation for API Endpoints
|
121
|
+
|
122
|
+
All URIs are relative to *{{basePath}}*
|
123
|
+
|
124
|
+
Class | Method | HTTP request | Description
|
125
|
+
------------ | ------------- | ------------- | -------------
|
126
|
+
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{moduleName}}::{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{{summary}}}
|
127
|
+
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
128
|
+
|
129
|
+
## Documentation for Models
|
130
|
+
|
131
|
+
{{#models}}{{#model}} - [{{moduleName}}::{{classname}}]({{modelDocPath}}{{classname}}.md)
|
132
|
+
{{/model}}{{/models}}
|
133
|
+
|
134
|
+
## Documentation for Authorization
|
135
|
+
|
136
|
+
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
|
137
|
+
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
|
138
|
+
{{#authMethods}}
|
139
|
+
### {{name}}
|
140
|
+
|
141
|
+
{{#isApiKey}}
|
142
|
+
|
143
|
+
- **Type**: API key
|
144
|
+
- **API key parameter name**: {{keyParamName}}
|
145
|
+
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
146
|
+
{{/isApiKey}}
|
147
|
+
{{#isBasic}}
|
148
|
+
{{#isBasicBasic}}- **Type**: HTTP basic authentication
|
149
|
+
{{/isBasicBasic}}{{#isBasicBearer}}- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
|
150
|
+
{{/isBasicBearer}}{{#isHttpSignature}}- **Type**: HTTP signature authentication
|
151
|
+
{{/isHttpSignature}}
|
152
|
+
{{/isBasic}}
|
153
|
+
{{#isOAuth}}
|
154
|
+
|
155
|
+
- **Type**: OAuth
|
156
|
+
- **Flow**: {{flow}}
|
157
|
+
- **Authorization URL**: {{authorizationUrl}}
|
158
|
+
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
159
|
+
{{#scopes}} - {{scope}}: {{description}}
|
160
|
+
{{/scopes}}
|
161
|
+
{{/isOAuth}}
|
162
|
+
|
163
|
+
{{/authMethods}}
|
@@ -0,0 +1,257 @@
|
|
1
|
+
=begin
|
2
|
+
{{> api_info}}
|
3
|
+
=end
|
4
|
+
|
5
|
+
require 'cgi'
|
6
|
+
|
7
|
+
module {{moduleName}}
|
8
|
+
{{#operations}}
|
9
|
+
class {{classname}}
|
10
|
+
attr_accessor :api_client
|
11
|
+
|
12
|
+
def initialize(api_client = ApiClient.default)
|
13
|
+
@api_client = api_client
|
14
|
+
end
|
15
|
+
{{#operation}}
|
16
|
+
{{#summary}}
|
17
|
+
# {{{.}}}
|
18
|
+
{{/summary}}
|
19
|
+
{{#notes}}
|
20
|
+
# {{{.}}}
|
21
|
+
{{/notes}}
|
22
|
+
{{#vendorExtensions.x-group-parameters}}
|
23
|
+
# @param [Hash] opts the parameters
|
24
|
+
{{#allParams}}
|
25
|
+
{{#required}}
|
26
|
+
# @option opts [{{{dataType}}}] :{{paramName}} {{description}} (required)
|
27
|
+
{{/required}}
|
28
|
+
{{/allParams}}
|
29
|
+
{{/vendorExtensions.x-group-parameters}}
|
30
|
+
{{^vendorExtensions.x-group-parameters}}
|
31
|
+
{{#allParams}}
|
32
|
+
{{#required}}
|
33
|
+
# @param {{paramName}} [{{{dataType}}}] {{description}}
|
34
|
+
{{/required}}
|
35
|
+
{{/allParams}}
|
36
|
+
# @param [Hash] opts the optional parameters
|
37
|
+
{{/vendorExtensions.x-group-parameters}}
|
38
|
+
{{#allParams}}
|
39
|
+
{{^required}}
|
40
|
+
# @option opts [{{{dataType}}}] :{{paramName}} {{description}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
41
|
+
{{/required}}
|
42
|
+
{{/allParams}}
|
43
|
+
# @return [{{{returnType}}}{{^returnType}}nil{{/returnType}}]
|
44
|
+
|
45
|
+
def {{ vendorExtensions.x-sdk-ruby-operationId }}{{ ^vendorExtensions.x-sdk-ruby-operationId }}{{operationId}}{{ /vendorExtensions.x-sdk-ruby-operationId }}({{^vendorExtensions.x-group-parameters}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}opts = {})
|
46
|
+
{{#returnType}}data, _status_code, _headers = {{/returnType}}{{ vendorExtensions.x-sdk-ruby-operationId }}{{ ^vendorExtensions.x-sdk-ruby-operationId }}{{operationId}}{{ /vendorExtensions.x-sdk-ruby-operationId }}_with_http_info({{^vendorExtensions.x-group-parameters}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}opts)
|
47
|
+
{{#returnType}}data{{/returnType}}{{^returnType}}nil{{/returnType}}
|
48
|
+
end
|
49
|
+
|
50
|
+
{{#summary}}
|
51
|
+
# {{.}}
|
52
|
+
{{/summary}}
|
53
|
+
{{#notes}}
|
54
|
+
# {{.}}
|
55
|
+
{{/notes}}
|
56
|
+
{{#vendorExtensions.x-group-parameters}}
|
57
|
+
# @param [Hash] opts the parameters
|
58
|
+
{{#allParams}}
|
59
|
+
{{#required}}
|
60
|
+
# @option opts [{{{dataType}}}] :{{paramName}} {{description}} (required)
|
61
|
+
{{/required}}
|
62
|
+
{{/allParams}}
|
63
|
+
{{/vendorExtensions.x-group-parameters}}
|
64
|
+
{{^vendorExtensions.x-group-parameters}}
|
65
|
+
{{#allParams}}
|
66
|
+
{{#required}}
|
67
|
+
# @param {{paramName}} [{{{dataType}}}] {{description}}
|
68
|
+
{{/required}}
|
69
|
+
{{/allParams}}
|
70
|
+
# @param [Hash] opts the optional parameters
|
71
|
+
{{/vendorExtensions.x-group-parameters}}
|
72
|
+
{{#allParams}}
|
73
|
+
{{^required}}
|
74
|
+
# @option opts [{{{dataType}}}] :{{paramName}} {{description}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
75
|
+
{{/required}}
|
76
|
+
{{/allParams}}
|
77
|
+
# @return [Array<({{{returnType}}}{{^returnType}}nil{{/returnType}}, Integer, Hash)>] {{#returnType}}{{{.}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}, response status code and response headers
|
78
|
+
# {{ httpMethod }} {{ returnContainer }}
|
79
|
+
def {{ vendorExtensions.x-sdk-ruby-operationId }}{{ ^vendorExtensions.x-sdk-ruby-operationId }}{{operationId}}{{ /vendorExtensions.x-sdk-ruby-operationId }}_with_http_info({{^vendorExtensions.x-group-parameters}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}opts = {})
|
80
|
+
if @api_client.config.debugging
|
81
|
+
@api_client.config.logger.debug 'Calling API: {{classname}}.{{operationId}} ...'
|
82
|
+
end
|
83
|
+
{{#vendorExtensions.x-group-parameters}}
|
84
|
+
# unbox the parameters from the hash
|
85
|
+
{{#allParams}}
|
86
|
+
{{^isNullable}}
|
87
|
+
{{#required}}
|
88
|
+
{{{paramName}}} = opts[:'{{{paramName}}}']
|
89
|
+
{{/required}}
|
90
|
+
{{/isNullable}}
|
91
|
+
{{/allParams}}
|
92
|
+
{{/vendorExtensions.x-group-parameters}}
|
93
|
+
{{#allParams}}
|
94
|
+
{{^isNullable}}
|
95
|
+
{{#required}}
|
96
|
+
# verify the required parameter '{{paramName}}' is set
|
97
|
+
if @api_client.config.client_side_validation && {{{paramName}}}.nil?
|
98
|
+
fail ArgumentError, "Missing the required parameter '{{paramName}}' when calling {{classname}}.{{operationId}}"
|
99
|
+
end
|
100
|
+
{{#isEnum}}
|
101
|
+
{{^isContainer}}
|
102
|
+
# verify enum value
|
103
|
+
allowable_values = [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]
|
104
|
+
if @api_client.config.client_side_validation && !allowable_values.include?({{{paramName}}})
|
105
|
+
fail ArgumentError, "invalid value for \"{{{paramName}}}\", must be one of #{allowable_values}"
|
106
|
+
end
|
107
|
+
{{/isContainer}}
|
108
|
+
{{/isEnum}}
|
109
|
+
{{/required}}
|
110
|
+
{{/isNullable}}
|
111
|
+
{{^required}}
|
112
|
+
{{#isEnum}}
|
113
|
+
{{#collectionFormat}}
|
114
|
+
allowable_values = [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]
|
115
|
+
if @api_client.config.client_side_validation && opts[:'{{{paramName}}}'] && !opts[:'{{{paramName}}}'].all? { |item| allowable_values.include?(item) }
|
116
|
+
fail ArgumentError, "invalid value for \"{{{paramName}}}\", must include one of #{allowable_values}"
|
117
|
+
end
|
118
|
+
{{/collectionFormat}}
|
119
|
+
{{^collectionFormat}}
|
120
|
+
allowable_values = [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]
|
121
|
+
if @api_client.config.client_side_validation && opts[:'{{{paramName}}}'] && !allowable_values.include?(opts[:'{{{paramName}}}'])
|
122
|
+
fail ArgumentError, "invalid value for \"{{{paramName}}}\", must be one of #{allowable_values}"
|
123
|
+
end
|
124
|
+
{{/collectionFormat}}
|
125
|
+
{{/isEnum}}
|
126
|
+
{{/required}}
|
127
|
+
{{#hasValidation}}
|
128
|
+
{{#maxLength}}
|
129
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length > {{{maxLength}}}
|
130
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be smaller than or equal to {{{maxLength}}}.'
|
131
|
+
end
|
132
|
+
|
133
|
+
{{/maxLength}}
|
134
|
+
{{#minLength}}
|
135
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length < {{{minLength}}}
|
136
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be great than or equal to {{{minLength}}}.'
|
137
|
+
end
|
138
|
+
|
139
|
+
{{/minLength}}
|
140
|
+
{{#maximum}}
|
141
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
|
142
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.'
|
143
|
+
end
|
144
|
+
|
145
|
+
{{/maximum}}
|
146
|
+
{{#minimum}}
|
147
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
|
148
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.'
|
149
|
+
end
|
150
|
+
|
151
|
+
{{/minimum}}
|
152
|
+
{{#pattern}}
|
153
|
+
pattern = Regexp.new({{{pattern}}})
|
154
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} !~ pattern
|
155
|
+
fail ArgumentError, "invalid value for '{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:\"{{{paramName}}}\"]{{/required}}' when calling {{classname}}.{{operationId}}, must conform to the pattern #{pattern}."
|
156
|
+
end
|
157
|
+
|
158
|
+
{{/pattern}}
|
159
|
+
{{#maxItems}}
|
160
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.length > {{{maxItems}}}
|
161
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, number of items must be less than or equal to {{{maxItems}}}.'
|
162
|
+
end
|
163
|
+
|
164
|
+
{{/maxItems}}
|
165
|
+
{{#minItems}}
|
166
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.length < {{{minItems}}}
|
167
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{{minItems}}}.'
|
168
|
+
end
|
169
|
+
|
170
|
+
{{/minItems}}
|
171
|
+
{{/hasValidation}}
|
172
|
+
{{/allParams}}
|
173
|
+
# resource path
|
174
|
+
local_var_path = '{{{path}}}'{{#pathParams}}.sub('{' + '{{baseName}}' + '}', CGI.escape({{paramName}}.to_s){{^strictSpecBehavior}}.gsub('%2F', '/'){{/strictSpecBehavior}}){{/pathParams}}
|
175
|
+
|
176
|
+
# query parameters
|
177
|
+
query_params = opts[:query_params] || {}
|
178
|
+
{{#queryParams}}
|
179
|
+
{{#required}}
|
180
|
+
query_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}
|
181
|
+
{{/required}}
|
182
|
+
{{/queryParams}}
|
183
|
+
{{#queryParams}}
|
184
|
+
{{^required}}
|
185
|
+
query_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{{paramName}}}'].nil?
|
186
|
+
{{/required}}
|
187
|
+
{{/queryParams}}
|
188
|
+
|
189
|
+
# header parameters
|
190
|
+
header_params = opts[:header_params] || {}
|
191
|
+
{{#hasProduces}}
|
192
|
+
# HTTP header 'Accept' (if needed)
|
193
|
+
header_params['Accept'] = @api_client.select_header_accept([{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}]) unless header_params['Accept']
|
194
|
+
{{/hasProduces}}
|
195
|
+
{{#hasConsumes}}
|
196
|
+
# HTTP header 'Content-Type'
|
197
|
+
content_type = @api_client.select_header_content_type([{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}])
|
198
|
+
if !content_type.nil?
|
199
|
+
header_params['Content-Type'] = content_type
|
200
|
+
end
|
201
|
+
{{/hasConsumes}}
|
202
|
+
{{#headerParams}}
|
203
|
+
{{#required}}
|
204
|
+
header_params[{{#lambdaFixHeaderKey}}:'{{{baseName}}}'{{/lambdaFixHeaderKey}}] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}
|
205
|
+
{{/required}}
|
206
|
+
{{/headerParams}}
|
207
|
+
{{#headerParams}}
|
208
|
+
{{^required}}
|
209
|
+
header_params[{{#lambdaFixHeaderKey}}:'{{{baseName}}}'{{/lambdaFixHeaderKey}}] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{{paramName}}}'].nil?
|
210
|
+
{{/required}}
|
211
|
+
{{/headerParams}}
|
212
|
+
|
213
|
+
# form parameters
|
214
|
+
form_params = opts[:form_params] || {}
|
215
|
+
{{#formParams}}
|
216
|
+
{{#required}}
|
217
|
+
form_params['{{baseName}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}
|
218
|
+
{{/required}}
|
219
|
+
{{/formParams}}
|
220
|
+
{{#formParams}}
|
221
|
+
{{^required}}
|
222
|
+
form_params['{{baseName}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{paramName}}'].nil?
|
223
|
+
{{/required}}
|
224
|
+
{{/formParams}}
|
225
|
+
|
226
|
+
# http body (model)
|
227
|
+
post_body = opts[:debug_body]{{#bodyParam}} || @api_client.object_to_http_body({{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}){{/bodyParam}}
|
228
|
+
|
229
|
+
# return_type
|
230
|
+
return_type = opts[:debug_return_type]{{#returnType}} || '{{{.}}}'{{/returnType}}
|
231
|
+
|
232
|
+
# auth_names
|
233
|
+
auth_names = opts[:debug_auth_names] || [{{#authMethods}}'{{name}}'{{^-last}}, {{/-last}}{{/authMethods}}]
|
234
|
+
|
235
|
+
new_options = opts.merge(
|
236
|
+
:operation => :"{{classname}}.{{operationId}}",
|
237
|
+
:header_params => header_params,
|
238
|
+
:query_params => query_params,
|
239
|
+
:form_params => form_params,
|
240
|
+
:body => post_body,
|
241
|
+
:auth_names => auth_names,
|
242
|
+
:return_type => return_type
|
243
|
+
)
|
244
|
+
|
245
|
+
data, status_code, headers = @api_client.call_api(:{{httpMethod}}, local_var_path, new_options)
|
246
|
+
if @api_client.config.debugging
|
247
|
+
@api_client.config.logger.debug "API called: {{classname}}#{{operationId}}\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
248
|
+
end
|
249
|
+
return data, status_code, headers
|
250
|
+
end
|
251
|
+
{{^-last}}
|
252
|
+
|
253
|
+
{{/-last}}
|
254
|
+
{{/operation}}
|
255
|
+
end
|
256
|
+
{{/operations}}
|
257
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
=begin
|
2
|
+
{{> api_info}}
|
3
|
+
=end
|
4
|
+
|
5
|
+
require 'date'
|
6
|
+
require 'json'
|
7
|
+
require 'logger'
|
8
|
+
require 'tempfile'
|
9
|
+
require 'time'
|
10
|
+
{{#isTyphoeus}}
|
11
|
+
require 'typhoeus'
|
12
|
+
{{/isTyphoeus}}
|
13
|
+
{{#isFaraday}}
|
14
|
+
require 'faraday'
|
15
|
+
require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
16
|
+
require 'marcel'
|
17
|
+
{{/isFaraday}}
|
18
|
+
{{#isHttpx}}
|
19
|
+
require 'httpx'
|
20
|
+
require 'net/http/status'
|
21
|
+
{{/isHttpx}}
|
22
|
+
|
23
|
+
|
24
|
+
module {{moduleName}}
|
25
|
+
class ApiClient
|
26
|
+
# The Configuration object holding settings to be used in the API client.
|
27
|
+
attr_accessor :config
|
28
|
+
|
29
|
+
# Defines the headers to be used in HTTP requests of all API calls by default.
|
30
|
+
#
|
31
|
+
# @return [Hash]
|
32
|
+
attr_accessor :default_headers
|
33
|
+
|
34
|
+
# Initializes the ApiClient
|
35
|
+
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
36
|
+
def initialize(config = Configuration.default)
|
37
|
+
@config = config
|
38
|
+
@user_agent = "{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/#{VERSION}/ruby{{/httpUserAgent}}"
|
39
|
+
@default_headers = {
|
40
|
+
'Content-Type' => 'application/json',
|
41
|
+
'User-Agent' => @user_agent
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.default
|
46
|
+
@@default ||= ApiClient.new
|
47
|
+
end
|
48
|
+
|
49
|
+
{{#isTyphoeus}}
|
50
|
+
{{> api_client_typhoeus_partial}}
|
51
|
+
{{/isTyphoeus}}
|
52
|
+
{{#isFaraday}}
|
53
|
+
{{> api_client_faraday_partial}}
|
54
|
+
{{/isFaraday}}
|
55
|
+
{{#isHttpx}}
|
56
|
+
{{> api_client_httpx_partial}}
|
57
|
+
{{/isHttpx}}
|
58
|
+
# Check if the given MIME is a JSON MIME.
|
59
|
+
# JSON MIME examples:
|
60
|
+
# application/json
|
61
|
+
# application/json; charset=UTF8
|
62
|
+
# APPLICATION/JSON
|
63
|
+
# */*
|
64
|
+
# @param [String] mime MIME
|
65
|
+
# @return [Boolean] True if the MIME is application/json
|
66
|
+
def json_mime?(mime)
|
67
|
+
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
|
68
|
+
end
|
69
|
+
|
70
|
+
# Deserialize the response to the given return type.
|
71
|
+
#
|
72
|
+
# @param [Response] response HTTP response
|
73
|
+
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
74
|
+
def deserialize(response, return_type)
|
75
|
+
body = response.body
|
76
|
+
return nil if body.nil? || body.empty?
|
77
|
+
|
78
|
+
# return response body directly for String return type
|
79
|
+
return body.to_s if return_type == 'String'
|
80
|
+
|
81
|
+
# ensuring a default content type
|
82
|
+
content_type = response.headers['Content-Type'] || 'application/json'
|
83
|
+
|
84
|
+
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
|
85
|
+
|
86
|
+
begin
|
87
|
+
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
88
|
+
rescue JSON::ParserError => e
|
89
|
+
if %w(String Date Time).include?(return_type)
|
90
|
+
data = body
|
91
|
+
else
|
92
|
+
raise e
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
convert_to_type data, return_type
|
97
|
+
end
|
98
|
+
|
99
|
+
# Convert data to the given return type.
|
100
|
+
# @param [Object] data Data to be converted
|
101
|
+
# @param [String] return_type Return type
|
102
|
+
# @return [Mixed] Data in a particular type
|
103
|
+
def convert_to_type(data, return_type)
|
104
|
+
return nil if data.nil?
|
105
|
+
case return_type
|
106
|
+
when 'String'
|
107
|
+
data.to_s
|
108
|
+
when 'Integer'
|
109
|
+
data.to_i
|
110
|
+
when 'Float'
|
111
|
+
data.to_f
|
112
|
+
when 'Boolean'
|
113
|
+
data == true
|
114
|
+
when 'Time'
|
115
|
+
# parse date time (expecting ISO 8601 format)
|
116
|
+
Time.parse data
|
117
|
+
when 'Date'
|
118
|
+
# parse date time (expecting ISO 8601 format)
|
119
|
+
Date.parse data
|
120
|
+
when 'Object'
|
121
|
+
# generic object (usually a Hash), return directly
|
122
|
+
data
|
123
|
+
when /\AArray<(.+)>\z/
|
124
|
+
# e.g. Array<Pet>
|
125
|
+
sub_type = $1
|
126
|
+
data.map { |item| convert_to_type(item, sub_type) }
|
127
|
+
when /\AHash\<String, (.+)\>\z/
|
128
|
+
# e.g. Hash<String, Integer>
|
129
|
+
sub_type = $1
|
130
|
+
{}.tap do |hash|
|
131
|
+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
132
|
+
end
|
133
|
+
else
|
134
|
+
# models (e.g. Pet) or oneOf
|
135
|
+
klass = {{moduleName}}.const_get(return_type)
|
136
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# Sanitize filename by removing path.
|
141
|
+
# e.g. ../../sun.gif becomes sun.gif
|
142
|
+
#
|
143
|
+
# @param [String] filename the filename to be sanitized
|
144
|
+
# @return [String] the sanitized filename
|
145
|
+
def sanitize_filename(filename)
|
146
|
+
filename.split(/[\/\\]/).last
|
147
|
+
end
|
148
|
+
|
149
|
+
def build_request_url(path, opts = {})
|
150
|
+
# Add leading and trailing slashes to path
|
151
|
+
path = "/#{path}".gsub(/\/+/, '/')
|
152
|
+
@config.base_url(opts[:operation]) + path
|
153
|
+
end
|
154
|
+
|
155
|
+
# Update header and query params based on authentication settings.
|
156
|
+
#
|
157
|
+
# @param [Hash] header_params Header parameters
|
158
|
+
# @param [Hash] query_params Query parameters
|
159
|
+
# @param [String] auth_names Authentication scheme name
|
160
|
+
def update_params_for_auth!(header_params, query_params, auth_names)
|
161
|
+
Array(auth_names).each do |auth_name|
|
162
|
+
auth_setting = @config.auth_settings[auth_name]
|
163
|
+
next unless auth_setting
|
164
|
+
case auth_setting[:in]
|
165
|
+
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
166
|
+
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
167
|
+
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# Sets user agent in HTTP header
|
173
|
+
#
|
174
|
+
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
|
175
|
+
def user_agent=(user_agent)
|
176
|
+
@user_agent = user_agent
|
177
|
+
@default_headers['User-Agent'] = @user_agent
|
178
|
+
end
|
179
|
+
|
180
|
+
# Return Accept header based on an array of accepts provided.
|
181
|
+
# @param [Array] accepts array for Accept
|
182
|
+
# @return [String] the Accept header (e.g. application/json)
|
183
|
+
def select_header_accept(accepts)
|
184
|
+
return nil if accepts.nil? || accepts.empty?
|
185
|
+
# use JSON when present, otherwise use all of the provided
|
186
|
+
json_accept = accepts.find { |s| json_mime?(s) }
|
187
|
+
json_accept || accepts.join(',')
|
188
|
+
end
|
189
|
+
|
190
|
+
# Return Content-Type header based on an array of content types provided.
|
191
|
+
# @param [Array] content_types array for Content-Type
|
192
|
+
# @return [String] the Content-Type header (e.g. application/json)
|
193
|
+
def select_header_content_type(content_types)
|
194
|
+
# return nil by default
|
195
|
+
return if content_types.nil? || content_types.empty?
|
196
|
+
# use JSON when present, otherwise use the first one
|
197
|
+
json_content_type = content_types.find { |s| json_mime?(s) }
|
198
|
+
json_content_type || content_types.first
|
199
|
+
end
|
200
|
+
|
201
|
+
# Convert object (array, hash, object, etc) to JSON string.
|
202
|
+
# @param [Object] model object to be converted into JSON string
|
203
|
+
# @return [String] JSON string representation of the object
|
204
|
+
def object_to_http_body(model)
|
205
|
+
return model if model.nil? || model.is_a?(String)
|
206
|
+
local_body = nil
|
207
|
+
if model.is_a?(Array)
|
208
|
+
local_body = model.map { |m| object_to_hash(m) }
|
209
|
+
else
|
210
|
+
local_body = object_to_hash(model)
|
211
|
+
end
|
212
|
+
local_body.to_json
|
213
|
+
end
|
214
|
+
|
215
|
+
# Convert object(non-array) to hash.
|
216
|
+
# @param [Object] obj object to be converted into JSON string
|
217
|
+
# @return [String] JSON string representation of the object
|
218
|
+
def object_to_hash(obj)
|
219
|
+
if obj.respond_to?(:to_hash)
|
220
|
+
obj.to_hash
|
221
|
+
else
|
222
|
+
obj
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
# Build parameter value according to the given collection format.
|
227
|
+
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
228
|
+
def build_collection_param(param, collection_format)
|
229
|
+
case collection_format
|
230
|
+
when :csv
|
231
|
+
param.join(',')
|
232
|
+
when :ssv
|
233
|
+
param.join(' ')
|
234
|
+
when :tsv
|
235
|
+
param.join("\t")
|
236
|
+
when :pipes
|
237
|
+
param.join('|')
|
238
|
+
when :multi
|
239
|
+
# return the array directly as typhoeus will handle it as expected
|
240
|
+
param
|
241
|
+
else
|
242
|
+
fail "unknown collection format: #{collection_format.inspect}"
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|