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,200 @@
|
|
1
|
+
# Call an API with given options.
|
2
|
+
#
|
3
|
+
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
4
|
+
# the data deserialized from response body (could be nil), response status code and response headers.
|
5
|
+
def call_api(http_method, path, opts = {})
|
6
|
+
stream = nil
|
7
|
+
begin
|
8
|
+
response = connection(opts).public_send(http_method.to_sym.downcase) do |req|
|
9
|
+
request = build_request(http_method, path, req, opts)
|
10
|
+
stream = download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
|
11
|
+
end
|
12
|
+
|
13
|
+
if config.debugging
|
14
|
+
config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
15
|
+
end
|
16
|
+
|
17
|
+
unless response.success?
|
18
|
+
if response.status == 0 && response.respond_to?(:return_message)
|
19
|
+
# Errors from libcurl will be made visible here
|
20
|
+
fail ApiError.new(code: 0,
|
21
|
+
message: response.return_message)
|
22
|
+
else
|
23
|
+
fail ApiError.new(code: response.status,
|
24
|
+
response_headers: response.headers,
|
25
|
+
response_body: response.body),
|
26
|
+
response.reason_phrase
|
27
|
+
end
|
28
|
+
end
|
29
|
+
rescue Faraday::TimeoutError
|
30
|
+
fail ApiError.new('Connection timed out')
|
31
|
+
rescue Faraday::ConnectionFailed
|
32
|
+
fail ApiError.new('Connection failed')
|
33
|
+
end
|
34
|
+
|
35
|
+
if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
|
36
|
+
data = deserialize_file(response, stream)
|
37
|
+
elsif opts[:return_type]
|
38
|
+
data = deserialize(response, opts[:return_type])
|
39
|
+
else
|
40
|
+
data = nil
|
41
|
+
end
|
42
|
+
return data, response.status, response.headers
|
43
|
+
end
|
44
|
+
|
45
|
+
# Builds the HTTP request
|
46
|
+
#
|
47
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
48
|
+
# @param [String] path URL path (e.g. /account/new)
|
49
|
+
# @option opts [Hash] :header_params Header parameters
|
50
|
+
# @option opts [Hash] :query_params Query parameters
|
51
|
+
# @option opts [Hash] :form_params Query parameters
|
52
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
53
|
+
# @return [Faraday::Request] A Faraday Request
|
54
|
+
def build_request(http_method, path, request, opts = {})
|
55
|
+
url = build_request_url(path, opts)
|
56
|
+
http_method = http_method.to_sym.downcase
|
57
|
+
|
58
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
59
|
+
query_params = opts[:query_params] || {}
|
60
|
+
form_params = opts[:form_params] || {}
|
61
|
+
|
62
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
63
|
+
|
64
|
+
if [:post, :patch, :put, :delete].include?(http_method)
|
65
|
+
req_body = build_request_body(header_params, form_params, opts[:body])
|
66
|
+
if config.debugging
|
67
|
+
config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
request.headers = header_params
|
71
|
+
request.body = req_body
|
72
|
+
|
73
|
+
# Overload default options only if provided
|
74
|
+
request.options.params_encoder = config.params_encoder if config.params_encoder
|
75
|
+
request.options.timeout = config.timeout if config.timeout
|
76
|
+
|
77
|
+
request.url url
|
78
|
+
request.params = query_params
|
79
|
+
request
|
80
|
+
end
|
81
|
+
|
82
|
+
# Builds the HTTP request body
|
83
|
+
#
|
84
|
+
# @param [Hash] header_params Header parameters
|
85
|
+
# @param [Hash] form_params Query parameters
|
86
|
+
# @param [Object] body HTTP body (JSON/XML)
|
87
|
+
# @return [String] HTTP body data in the form of string
|
88
|
+
def build_request_body(header_params, form_params, body)
|
89
|
+
# http form
|
90
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
|
91
|
+
data = URI.encode_www_form(form_params)
|
92
|
+
elsif header_params['Content-Type'] == 'multipart/form-data'
|
93
|
+
data = {}
|
94
|
+
form_params.each do |key, value|
|
95
|
+
case value
|
96
|
+
when ::File, ::Tempfile
|
97
|
+
data[key] = Faraday::FilePart.new(value.path, Marcel::MimeType.for(Pathname.new(value.path)))
|
98
|
+
when ::Array, nil
|
99
|
+
# let Faraday handle Array and nil parameters
|
100
|
+
data[key] = value
|
101
|
+
else
|
102
|
+
data[key] = value.to_s
|
103
|
+
end
|
104
|
+
end
|
105
|
+
elsif body
|
106
|
+
data = body.is_a?(String) ? body : body.to_json
|
107
|
+
else
|
108
|
+
data = nil
|
109
|
+
end
|
110
|
+
data
|
111
|
+
end
|
112
|
+
|
113
|
+
def download_file(request)
|
114
|
+
stream = []
|
115
|
+
|
116
|
+
# handle streaming Responses
|
117
|
+
request.options.on_data = Proc.new do |chunk, overall_received_bytes|
|
118
|
+
stream << chunk
|
119
|
+
end
|
120
|
+
|
121
|
+
stream
|
122
|
+
end
|
123
|
+
|
124
|
+
def deserialize_file(response, stream)
|
125
|
+
body = response.body
|
126
|
+
encoding = body.encoding
|
127
|
+
|
128
|
+
# reconstruct content
|
129
|
+
content = stream.join
|
130
|
+
content = content.unpack('m').join if response.headers['Content-Transfer-Encoding'] == 'binary'
|
131
|
+
content = content.force_encoding(encoding)
|
132
|
+
|
133
|
+
# return byte stream
|
134
|
+
return content if @config.return_binary_data == true
|
135
|
+
|
136
|
+
# return file instead of binary data
|
137
|
+
content_disposition = response.headers['Content-Disposition']
|
138
|
+
if content_disposition && content_disposition =~ /filename=/i
|
139
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
140
|
+
prefix = sanitize_filename(filename)
|
141
|
+
else
|
142
|
+
prefix = 'download-'
|
143
|
+
end
|
144
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
145
|
+
|
146
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
147
|
+
tempfile.write(content)
|
148
|
+
tempfile.close
|
149
|
+
|
150
|
+
config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
151
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
152
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
153
|
+
"explicitly with `tempfile.delete`"
|
154
|
+
tempfile
|
155
|
+
end
|
156
|
+
|
157
|
+
def connection(opts)
|
158
|
+
opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular
|
159
|
+
end
|
160
|
+
|
161
|
+
def connection_multipart
|
162
|
+
@connection_multipart ||= build_connection do |conn|
|
163
|
+
conn.request :multipart
|
164
|
+
conn.request :url_encoded
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def connection_regular
|
169
|
+
@connection_regular ||= build_connection
|
170
|
+
end
|
171
|
+
|
172
|
+
def build_connection
|
173
|
+
Faraday.new(url: config.base_url, ssl: ssl_options, proxy: config.proxy) do |conn|
|
174
|
+
basic_auth(conn)
|
175
|
+
config.configure_middleware(conn)
|
176
|
+
yield(conn) if block_given?
|
177
|
+
conn.adapter(Faraday.default_adapter)
|
178
|
+
config.configure_connection(conn)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def ssl_options
|
183
|
+
{
|
184
|
+
ca_file: config.ssl_ca_file,
|
185
|
+
verify: config.ssl_verify,
|
186
|
+
verify_mode: config.ssl_verify_mode,
|
187
|
+
client_cert: config.ssl_client_cert,
|
188
|
+
client_key: config.ssl_client_key
|
189
|
+
}
|
190
|
+
end
|
191
|
+
|
192
|
+
def basic_auth(conn)
|
193
|
+
if config.username && config.password
|
194
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
195
|
+
conn.request(:authorization, :basic, config.username, config.password)
|
196
|
+
else
|
197
|
+
conn.request(:basic_auth, config.username, config.password)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# Call an API with given options.
|
2
|
+
#
|
3
|
+
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
4
|
+
# the data deserialized from response body (could be nil), response status code and response headers.
|
5
|
+
def call_api(http_method, path, opts = {})
|
6
|
+
begin
|
7
|
+
response = build_request(http_method.to_s, path, opts)
|
8
|
+
|
9
|
+
if config.debugging
|
10
|
+
config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
response.raise_for_status
|
14
|
+
|
15
|
+
rescue HTTPX::HTTPError
|
16
|
+
fail ApiError.new(code: response.status,
|
17
|
+
response_headers: response.headers.to_h,
|
18
|
+
response_body: response.body.to_s),
|
19
|
+
Net::HTTP::STATUS_CODES.fetch(response.status, "HTTP Error (#{response.status})")
|
20
|
+
rescue HTTPX::TimeoutError
|
21
|
+
fail ApiError.new('Connection timed out')
|
22
|
+
rescue HTTPX::ConnectionError, HTTPX::ResolveError
|
23
|
+
fail ApiError.new('Connection failed')
|
24
|
+
end
|
25
|
+
|
26
|
+
if opts[:return_type] == 'File'
|
27
|
+
data = deserialize_file(response)
|
28
|
+
elsif opts[:return_type]
|
29
|
+
data = deserialize(response, opts[:return_type])
|
30
|
+
else
|
31
|
+
data = nil
|
32
|
+
end
|
33
|
+
return data, response.status, response.headers.to_h
|
34
|
+
end
|
35
|
+
|
36
|
+
# Builds the HTTP request
|
37
|
+
#
|
38
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
39
|
+
# @param [String] path URL path (e.g. /account/new)
|
40
|
+
# @option opts [Hash] :header_params Header parameters
|
41
|
+
# @option opts [Hash] :query_params Query parameters
|
42
|
+
# @option opts [Hash] :form_params Query parameters
|
43
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
44
|
+
# @return [HTTPX::Request] A Request object
|
45
|
+
def build_request(http_method, path, opts = {})
|
46
|
+
url = build_request_url(path, opts)
|
47
|
+
|
48
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
49
|
+
query_params = opts[:query_params] || {}
|
50
|
+
form_params = opts[:form_params] || {}
|
51
|
+
|
52
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
53
|
+
|
54
|
+
if %w[POST PATCH PUT DELETE].include?(http_method)
|
55
|
+
body_params = build_request_body(header_params, form_params, opts[:body])
|
56
|
+
if config.debugging
|
57
|
+
config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
req_opts = {
|
61
|
+
:headers => HTTPX::Headers.new(header_params)
|
62
|
+
}
|
63
|
+
req_opts.merge!(body_params) if body_params
|
64
|
+
req_opts[:params] = query_params if query_params && !query_params.empty?
|
65
|
+
session.request(http_method, url, **req_opts)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Builds the HTTP request body
|
69
|
+
#
|
70
|
+
# @param [Hash] header_params Header parameters
|
71
|
+
# @param [Hash] form_params Query parameters
|
72
|
+
# @param [Object] body HTTP body (JSON/XML)
|
73
|
+
# @return [Hash{Symbol => Object}] body options as HTTPX handles them
|
74
|
+
def build_request_body(header_params, form_params, body)
|
75
|
+
# http form
|
76
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
77
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
78
|
+
header_params.delete('Content-Type') # httpx takes care of this
|
79
|
+
{ form: form_params }
|
80
|
+
elsif body
|
81
|
+
body.is_a?(String) ? { body: body } : { json: body }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def deserialize_file(response)
|
86
|
+
body = response.body
|
87
|
+
if @config.return_binary_data == true
|
88
|
+
# TODO: force response encoding
|
89
|
+
body.to_s
|
90
|
+
else
|
91
|
+
content_disposition = response.headers['content-disposition']
|
92
|
+
if content_disposition && content_disposition =~ /filename=/i
|
93
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
94
|
+
prefix = sanitize_filename(filename)
|
95
|
+
else
|
96
|
+
prefix = 'download-'
|
97
|
+
end
|
98
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
99
|
+
encoding = response.body.encoding
|
100
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
101
|
+
response.copy_to(tempfile)
|
102
|
+
tempfile.close
|
103
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
104
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
105
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
106
|
+
"explicitly with `tempfile.delete`"
|
107
|
+
|
108
|
+
tempfile
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def session
|
113
|
+
return @session if defined?(@session)
|
114
|
+
|
115
|
+
session = HTTPX.with(
|
116
|
+
ssl: @config.ssl,
|
117
|
+
timeout: ({ request_timeout: @config.timeout } if @config.timeout && @config.timeout.positive?),
|
118
|
+
origin: "#{@config.scheme}://#{@config.host}",
|
119
|
+
base_path: (@config.base_path.sub(/\/+\z/, '') if @config.base_path)
|
120
|
+
)
|
121
|
+
|
122
|
+
if @config.proxy
|
123
|
+
session = session.plugin(:proxy, proxy: @config.proxy)
|
124
|
+
end
|
125
|
+
|
126
|
+
if @config.username && @config.password
|
127
|
+
session = session.plugin(:basic_auth).basic_auth(@config.username, @config.password)
|
128
|
+
end
|
129
|
+
|
130
|
+
session = @config.configure(session)
|
131
|
+
|
132
|
+
@session = session
|
133
|
+
|
134
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
# Call an API with given options.
|
2
|
+
#
|
3
|
+
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
4
|
+
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
|
5
|
+
def call_api(http_method, path, opts = {})
|
6
|
+
request = build_request(http_method, path, opts)
|
7
|
+
tempfile = download_file(request) if opts[:return_type] == 'File'
|
8
|
+
response = request.run
|
9
|
+
|
10
|
+
if @config.debugging
|
11
|
+
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
12
|
+
end
|
13
|
+
|
14
|
+
unless response.success?
|
15
|
+
if response.timed_out?
|
16
|
+
fail ApiError.new('Connection timed out')
|
17
|
+
elsif response.code == 0
|
18
|
+
# Errors from libcurl will be made visible here
|
19
|
+
fail ApiError.new(:code => 0,
|
20
|
+
:message => response.return_message)
|
21
|
+
else
|
22
|
+
fail ApiError.new(:code => response.code,
|
23
|
+
:response_headers => response.headers,
|
24
|
+
:response_body => response.body),
|
25
|
+
response.status_message
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if opts[:return_type] == 'File'
|
30
|
+
data = tempfile
|
31
|
+
elsif opts[:return_type]
|
32
|
+
data = deserialize(response, opts[:return_type])
|
33
|
+
else
|
34
|
+
data = nil
|
35
|
+
end
|
36
|
+
return data, response.code, response.headers
|
37
|
+
end
|
38
|
+
|
39
|
+
# Builds the HTTP request
|
40
|
+
#
|
41
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
42
|
+
# @param [String] path URL path (e.g. /account/new)
|
43
|
+
# @option opts [Hash] :header_params Header parameters
|
44
|
+
# @option opts [Hash] :query_params Query parameters
|
45
|
+
# @option opts [Hash] :form_params Query parameters
|
46
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
47
|
+
# @return [Typhoeus::Request] A Typhoeus Request
|
48
|
+
def build_request(http_method, path, opts = {})
|
49
|
+
url = build_request_url(path, opts)
|
50
|
+
http_method = http_method.to_sym.downcase
|
51
|
+
|
52
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
53
|
+
query_params = opts[:query_params] || {}
|
54
|
+
form_params = opts[:form_params] || {}
|
55
|
+
follow_location = opts[:follow_location] || true
|
56
|
+
|
57
|
+
{{#hasAuthMethods}}
|
58
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
59
|
+
{{/hasAuthMethods}}
|
60
|
+
|
61
|
+
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
62
|
+
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
63
|
+
|
64
|
+
req_opts = {
|
65
|
+
:method => http_method,
|
66
|
+
:headers => header_params,
|
67
|
+
:params => query_params,
|
68
|
+
:params_encoding => @config.params_encoding,
|
69
|
+
:timeout => @config.timeout,
|
70
|
+
:ssl_verifypeer => @config.verify_ssl,
|
71
|
+
:ssl_verifyhost => _verify_ssl_host,
|
72
|
+
:sslcert => @config.cert_file,
|
73
|
+
:sslkey => @config.key_file,
|
74
|
+
:verbose => @config.debugging,
|
75
|
+
:followlocation => follow_location
|
76
|
+
}
|
77
|
+
|
78
|
+
# set custom cert, if provided
|
79
|
+
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
80
|
+
|
81
|
+
if [:post, :patch, :put, :delete].include?(http_method)
|
82
|
+
req_body = build_request_body(header_params, form_params, opts[:body])
|
83
|
+
req_opts.update :body => req_body
|
84
|
+
if @config.debugging
|
85
|
+
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
Typhoeus::Request.new(url, req_opts)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Builds the HTTP request body
|
93
|
+
#
|
94
|
+
# @param [Hash] header_params Header parameters
|
95
|
+
# @param [Hash] form_params Query parameters
|
96
|
+
# @param [Object] body HTTP body (JSON/XML)
|
97
|
+
# @return [String] HTTP body data in the form of string
|
98
|
+
def build_request_body(header_params, form_params, body)
|
99
|
+
# http form
|
100
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
101
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
102
|
+
data = {}
|
103
|
+
form_params.each do |key, value|
|
104
|
+
case value
|
105
|
+
when ::File, ::Array, nil
|
106
|
+
# let typhoeus handle File, Array and nil parameters
|
107
|
+
data[key] = value
|
108
|
+
else
|
109
|
+
data[key] = value.to_s
|
110
|
+
end
|
111
|
+
end
|
112
|
+
elsif body
|
113
|
+
data = body.is_a?(String) ? body : body.to_json
|
114
|
+
else
|
115
|
+
data = nil
|
116
|
+
end
|
117
|
+
data
|
118
|
+
end
|
119
|
+
|
120
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
121
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
122
|
+
# The response body is written to the file in chunks in order to handle files which
|
123
|
+
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
124
|
+
# process can use.
|
125
|
+
#
|
126
|
+
# @see Configuration#temp_folder_path
|
127
|
+
#
|
128
|
+
# @return [Tempfile] the tempfile generated
|
129
|
+
def download_file(request)
|
130
|
+
tempfile = nil
|
131
|
+
encoding = nil
|
132
|
+
request.on_headers do |response|
|
133
|
+
content_disposition = response.headers['Content-Disposition']
|
134
|
+
if content_disposition && content_disposition =~ /filename=/i
|
135
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
136
|
+
prefix = sanitize_filename(filename)
|
137
|
+
else
|
138
|
+
prefix = 'download-'
|
139
|
+
end
|
140
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
141
|
+
encoding = response.body.encoding
|
142
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
143
|
+
end
|
144
|
+
request.on_body do |chunk|
|
145
|
+
chunk.force_encoding(encoding)
|
146
|
+
tempfile.write(chunk)
|
147
|
+
end
|
148
|
+
# run the request to ensure the tempfile is created successfully before returning it
|
149
|
+
request.run
|
150
|
+
if tempfile
|
151
|
+
tempfile.close
|
152
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
153
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
154
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
155
|
+
"explicitly with `tempfile.delete`"
|
156
|
+
else
|
157
|
+
fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
|
158
|
+
end
|
159
|
+
|
160
|
+
tempfile
|
161
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# {{moduleName}}::{{classname}}{{#description}}
|
2
|
+
|
3
|
+
{{.}}{{/description}}
|
4
|
+
|
5
|
+
All URIs are relative to *{{basePath}}*
|
6
|
+
|
7
|
+
| Method | HTTP request | Description |
|
8
|
+
| ------ | ------------ | ----------- |
|
9
|
+
{{#operations}}
|
10
|
+
{{#operation}}
|
11
|
+
| [**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{summary}} |
|
12
|
+
{{/operation}}
|
13
|
+
{{/operations}}
|
14
|
+
|
15
|
+
{{#operations}}
|
16
|
+
{{#operation}}
|
17
|
+
|
18
|
+
## {{operationId}}
|
19
|
+
|
20
|
+
> {{#returnType}}{{#returnTypeIsPrimitive}}{{returnType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}<{{{returnType}}}>{{/returnTypeIsPrimitive}} {{/returnType}}{{operationId}}{{#hasParams}}({{^vendorExtensions.x-group-parameters}}{{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}opts{{/vendorExtensions.x-group-parameters}}){{/hasParams}}
|
21
|
+
|
22
|
+
{{{summary}}}{{#notes}}
|
23
|
+
|
24
|
+
{{{.}}}{{/notes}}
|
25
|
+
|
26
|
+
### Examples
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'time'
|
30
|
+
require '{{{gemName}}}'
|
31
|
+
{{#hasAuthMethods}}
|
32
|
+
# setup authorization
|
33
|
+
{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
34
|
+
# Configure HTTP basic authorization: {{{name}}}
|
35
|
+
config.username = 'YOUR USERNAME'
|
36
|
+
config.password = 'YOUR PASSWORD'{{/isBasicBasic}}{{#isBasicBearer}}
|
37
|
+
# Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}}
|
38
|
+
config.access_token = 'YOUR_BEARER_TOKEN'{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}
|
39
|
+
# Configure API key authorization: {{{name}}}
|
40
|
+
config.api_key['{{{keyParamName}}}'] = 'YOUR API KEY'
|
41
|
+
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
|
42
|
+
# config.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}}
|
43
|
+
# Configure OAuth2 access token for authorization: {{{name}}}
|
44
|
+
config.access_token = 'YOUR ACCESS TOKEN'{{/isOAuth}}
|
45
|
+
{{/authMethods}}end
|
46
|
+
{{/hasAuthMethods}}
|
47
|
+
|
48
|
+
api_instance = {{{moduleName}}}::{{{classname}}}.new
|
49
|
+
{{^vendorExtensions.x-group-parameters}}
|
50
|
+
{{#requiredParams}}
|
51
|
+
{{{paramName}}} = {{{vendorExtensions.x-ruby-example}}} # {{{dataType}}} | {{{description}}}
|
52
|
+
{{/requiredParams}}
|
53
|
+
{{#optionalParams}}
|
54
|
+
{{#-first}}
|
55
|
+
opts = {
|
56
|
+
{{/-first}}
|
57
|
+
{{{paramName}}}: {{{vendorExtensions.x-ruby-example}}}{{^-last}},{{/-last}} # {{{dataType}}} | {{{description}}}
|
58
|
+
{{#-last}}
|
59
|
+
}
|
60
|
+
{{/-last}}
|
61
|
+
{{/optionalParams}}
|
62
|
+
{{/vendorExtensions.x-group-parameters}}
|
63
|
+
{{#vendorExtensions.x-group-parameters}}
|
64
|
+
{{#hasParams}}
|
65
|
+
opts = {
|
66
|
+
{{#requiredParams}}
|
67
|
+
{{{paramName}}}: {{{vendorExtensions.x-ruby-example}}}, # {{{dataType}}} | {{{description}}} (required)
|
68
|
+
{{/requiredParams}}
|
69
|
+
{{#optionalParams}}
|
70
|
+
{{{paramName}}}: {{{vendorExtensions.x-ruby-example}}}, # {{{dataType}}} | {{{description}}}
|
71
|
+
{{/optionalParams}}
|
72
|
+
}
|
73
|
+
{{/hasParams}}
|
74
|
+
{{/vendorExtensions.x-group-parameters}}
|
75
|
+
|
76
|
+
begin
|
77
|
+
{{#summary}}# {{{.}}}{{/summary}}
|
78
|
+
{{#returnType}}result = {{/returnType}}api_instance.{{{operationId}}}{{#hasParams}}({{^vendorExtensions.x-group-parameters}}{{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}opts{{/vendorExtensions.x-group-parameters}}){{/hasParams}}
|
79
|
+
{{#returnType}}
|
80
|
+
p result
|
81
|
+
{{/returnType}}
|
82
|
+
rescue {{{moduleName}}}::ApiError => e
|
83
|
+
puts "Error when calling {{classname}}->{{{operationId}}}: #{e}"
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
#### Using the {{operationId}}_with_http_info variant
|
88
|
+
|
89
|
+
This returns an Array which contains the response data{{^returnType}} (`nil` in this case){{/returnType}}, status code and headers.
|
90
|
+
|
91
|
+
> <Array({{#returnType}}{{#returnTypeIsPrimitive}}{{returnType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}<{{{returnType}}}>{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}nil{{/returnType}}, Integer, Hash)> {{operationId}}_with_http_info{{#hasParams}}({{^vendorExtensions.x-group-parameters}}{{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}opts{{/vendorExtensions.x-group-parameters}}){{/hasParams}}
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
begin
|
95
|
+
{{#summary}}# {{{.}}}{{/summary}}
|
96
|
+
data, status_code, headers = api_instance.{{{operationId}}}_with_http_info{{#hasParams}}({{^vendorExtensions.x-group-parameters}}{{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}opts{{/vendorExtensions.x-group-parameters}}){{/hasParams}}
|
97
|
+
p status_code # => 2xx
|
98
|
+
p headers # => { ... }
|
99
|
+
p data # => {{#returnType}}{{#returnTypeIsPrimitive}}{{returnType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}<{{{returnType}}}>{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}nil{{/returnType}}
|
100
|
+
rescue {{{moduleName}}}::ApiError => e
|
101
|
+
puts "Error when calling {{classname}}->{{{operationId}}}_with_http_info: #{e}"
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
### Parameters
|
106
|
+
|
107
|
+
{{^allParams}}
|
108
|
+
This endpoint does not need any parameter.
|
109
|
+
{{/allParams}}
|
110
|
+
{{#allParams}}
|
111
|
+
{{#-first}}
|
112
|
+
| Name | Type | Description | Notes |
|
113
|
+
| ---- | ---- | ----------- | ----- |
|
114
|
+
{{/-first}}
|
115
|
+
| **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}} | {{description}} | {{^required}}[optional]{{/required}}{{#defaultValue}}[default to {{.}}]{{/defaultValue}} |
|
116
|
+
{{/allParams}}
|
117
|
+
|
118
|
+
### Return type
|
119
|
+
|
120
|
+
{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}nil (empty response body){{/returnType}}
|
121
|
+
|
122
|
+
### Authorization
|
123
|
+
|
124
|
+
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}}
|
125
|
+
|
126
|
+
### HTTP request headers
|
127
|
+
|
128
|
+
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
129
|
+
- **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
130
|
+
|
131
|
+
{{/operation}}
|
132
|
+
{{/operations}}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
=begin
|
2
|
+
{{> api_info}}
|
3
|
+
=end
|
4
|
+
|
5
|
+
module {{moduleName}}
|
6
|
+
class ApiError < StandardError
|
7
|
+
attr_reader :code, :response_headers, :response_body
|
8
|
+
|
9
|
+
# Usage examples:
|
10
|
+
# ApiError.new
|
11
|
+
# ApiError.new("message")
|
12
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
13
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
14
|
+
def initialize(arg = nil)
|
15
|
+
if arg.is_a? Hash
|
16
|
+
if arg.key?(:message) || arg.key?('message')
|
17
|
+
super(arg[:message] || arg['message'])
|
18
|
+
else
|
19
|
+
super arg
|
20
|
+
end
|
21
|
+
|
22
|
+
arg.each do |k, v|
|
23
|
+
instance_variable_set "@#{k}", v
|
24
|
+
end
|
25
|
+
else
|
26
|
+
super arg
|
27
|
+
@message = arg
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Override to_s to display a friendly error message
|
32
|
+
def to_s
|
33
|
+
message
|
34
|
+
end
|
35
|
+
|
36
|
+
def message
|
37
|
+
if @message.nil?
|
38
|
+
msg = "Error message: the server returns an error"
|
39
|
+
else
|
40
|
+
msg = @message
|
41
|
+
end
|
42
|
+
|
43
|
+
msg += "\nHTTP status code: #{code}" if code
|
44
|
+
msg += "\nResponse headers: #{response_headers}" if response_headers
|
45
|
+
msg += "\nResponse body: #{response_body}" if response_body
|
46
|
+
|
47
|
+
msg
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{{#appName}}
|
2
|
+
#{{{.}}}
|
3
|
+
|
4
|
+
{{/appName}}
|
5
|
+
{{#appDescription}}
|
6
|
+
#{{{.}}}
|
7
|
+
|
8
|
+
{{/appDescription}}
|
9
|
+
{{#version}}The version of the OpenAPI document: {{.}}{{/version}}
|
10
|
+
{{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
|
11
|
+
Generated by: https://openapi-generator.tech
|
12
|
+
Generator version: {{{generatorVersion}}}
|