Class: Clerk::OpenAPIClient

Inherits:
Object
  • Object
show all
Defined in:
lib/clerk/openapiclient.rb

Direct Known Subclasses

SDK

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: nil, retry_config: nil, timeout_ms: nil, bearer_auth: nil, security_source: nil, server_idx: nil, server_url: nil, url_params: nil) ⇒ OpenAPIClient

Instantiates the SDK, configuring it with the provided parameters.

Parameters:

  • client (Faraday::Connection, nil) (defaults to: nil)

    The faraday HTTP client to use for all operations

  • retry_config (::Clerk::Utils::RetryConfig, nil) (defaults to: nil)

    The retry configuration to use for all operations

  • timeout_ms (Integer, nil) (defaults to: nil)

    Request timeout in milliseconds for all operations

  • security (Models::Components::Security, nil)

    The security details required for authentication

  • security_source (Proc{|| Models::Components::Security, nil}) (defaults to: nil)

    A function that returns security details required for authentication

  • server_idx (Integer, nil) (defaults to: nil)

    The index of the server to use for all operations

  • server_url (String, nil) (defaults to: nil)

    The server URL to use for all operations

  • url_params (Hash{Symbol => String}, nil) (defaults to: nil)

    Parameters to optionally template the server URL with



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/clerk/openapiclient.rb', line 30

def initialize(client: nil, retry_config: nil, timeout_ms: nil, bearer_auth: nil, security_source: nil, server_idx: nil, server_url: nil, url_params: nil)

  connection_options = {
    request: {
      params_encoder: Faraday::FlatParamsEncoder
    }
  }
  connection_options[:request][:timeout] = (timeout_ms.to_f / 1000) unless timeout_ms.nil?

  client ||= Faraday.new(**connection_options) do |f|
    f.request :multipart, { flat_encode: true }
    # f.response :logger, nil, { headers: true, bodies: true, errors: true }
  end
  
  if !server_url.nil?
    if !url_params.nil?
      server_url = Utils.template_url(server_url, url_params)
    end
  end

  server_idx = 0 if server_idx.nil?
  hooks = SDKHooks::Hooks.new
  @sdk_configuration = SDKConfiguration.new(
    client,
    hooks,
    retry_config,
    timeout_ms,
    bearer_auth,
    security_source,
    server_url,
    server_idx
  )
  @sdk_configuration = hooks.sdk_init(config: @sdk_configuration)
  init_sdks
end

Instance Attribute Details

#actor_tokensObject

Returns the value of attribute actor_tokens.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def actor_tokens
  @actor_tokens
end

#allowlist_identifiersObject

Returns the value of attribute allowlist_identifiers.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def allowlist_identifiers
  @allowlist_identifiers
end

#api_keysObject

Returns the value of attribute api_keys.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def api_keys
  @api_keys
end

#beta_featuresObject

Returns the value of attribute beta_features.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def beta_features
  @beta_features
end

#billingObject

Returns the value of attribute billing.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def billing
  @billing
end

#blocklist_identifiersObject

Returns the value of attribute blocklist_identifiers.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def blocklist_identifiers
  @blocklist_identifiers
end

#clientsObject

Returns the value of attribute clients.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def clients
  @clients
end

#domainsObject

Returns the value of attribute domains.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def domains
  @domains
end

#email_addressesObject

Returns the value of attribute email_addresses.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def email_addresses
  @email_addresses
end

#email_and_sms_templatesObject

Returns the value of attribute email_and_sms_templates.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def email_and_sms_templates
  @email_and_sms_templates
end

#email_sms_templatesObject

Returns the value of attribute email_sms_templates.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def email_sms_templates
  @email_sms_templates
end

#instance_settingsObject

Returns the value of attribute instance_settings.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def instance_settings
  @instance_settings
end

#invitationsObject

Returns the value of attribute invitations.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def invitations
  @invitations
end

#jwksObject

Returns the value of attribute jwks.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def jwks
  @jwks
end

#jwt_templatesObject

Returns the value of attribute jwt_templates.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def jwt_templates
  @jwt_templates
end

#m2mObject

Returns the value of attribute m2m.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def m2m
  @m2m
end

#machinesObject

Returns the value of attribute machines.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def machines
  @machines
end

#miscellaneousObject

Returns the value of attribute miscellaneous.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def miscellaneous
  @miscellaneous
end

#oauth_access_tokensObject

Returns the value of attribute oauth_access_tokens.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def oauth_access_tokens
  @oauth_access_tokens
end

#oauth_applicationsObject

Returns the value of attribute oauth_applications.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def oauth_applications
  @oauth_applications
end

#organization_domainsObject

Returns the value of attribute organization_domains.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def organization_domains
  @organization_domains
end

#organization_invitationsObject

Returns the value of attribute organization_invitations.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def organization_invitations
  @organization_invitations
end

#organization_membershipsObject

Returns the value of attribute organization_memberships.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def organization_memberships
  @organization_memberships
end

#organization_permissionsObject

Returns the value of attribute organization_permissions.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def organization_permissions
  @organization_permissions
end

#organization_rolesObject

Returns the value of attribute organization_roles.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def organization_roles
  @organization_roles
end

#organizationsObject

Returns the value of attribute organizations.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def organizations
  @organizations
end

#phone_numbersObject

Returns the value of attribute phone_numbers.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def phone_numbers
  @phone_numbers
end

#proxy_checksObject

Returns the value of attribute proxy_checks.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def proxy_checks
  @proxy_checks
end

#redirect_urlsObject

Returns the value of attribute redirect_urls.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def redirect_urls
  @redirect_urls
end

#role_setsObject

Returns the value of attribute role_sets.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def role_sets
  @role_sets
end

#saml_connectionsObject

Returns the value of attribute saml_connections.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def saml_connections
  @saml_connections
end

#sessionsObject

Returns the value of attribute sessions.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def sessions
  @sessions
end

#sign_in_tokensObject

Returns the value of attribute sign_in_tokens.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def 
  @sign_in_tokens
end

#sign_upsObject

Returns the value of attribute sign_ups.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def sign_ups
  @sign_ups
end

#templatesObject

Returns the value of attribute templates.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def templates
  @templates
end

#testing_tokensObject

Returns the value of attribute testing_tokens.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def testing_tokens
  @testing_tokens
end

#usersObject

Returns the value of attribute users.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def users
  @users
end

#waitlist_entriesObject

Returns the value of attribute waitlist_entries.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def waitlist_entries
  @waitlist_entries
end

#webhooksObject

Returns the value of attribute webhooks.



18
19
20
# File 'lib/clerk/openapiclient.rb', line 18

def webhooks
  @webhooks
end

Instance Method Details

#get_url(base_url:, url_variables: nil) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/clerk/openapiclient.rb', line 110

def get_url(base_url:, url_variables: nil)
  sd_base_url, sd_options = @sdk_configuration.get_server_details

  if base_url.nil?
    base_url = sd_base_url
  end

  if url_variables.nil?
    url_variables = sd_options
  end

  return Utils.template_url base_url, url_variables
end

#init_sdksObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/clerk/openapiclient.rb', line 67

def init_sdks
  @miscellaneous = Miscellaneous.new(@sdk_configuration)
  @jwks = Jwks.new(@sdk_configuration)
  @clients = Clients.new(@sdk_configuration)
  @email_addresses = EmailAddresses.new(@sdk_configuration)
  @phone_numbers = PhoneNumbers.new(@sdk_configuration)
  @sessions = Sessions.new(@sdk_configuration)
  @email_sms_templates = EmailSMSTemplates.new(@sdk_configuration)
  @email_and_sms_templates = EmailAndSmsTemplates.new(@sdk_configuration)
  @templates = Templates.new(@sdk_configuration)
  @users = Users.new(@sdk_configuration)
  @invitations = Invitations.new(@sdk_configuration)
  @organization_invitations = OrganizationInvitations.new(@sdk_configuration)
  @allowlist_identifiers = AllowlistIdentifiers.new(@sdk_configuration)
  @blocklist_identifiers = BlocklistIdentifiers.new(@sdk_configuration)
  @beta_features = BetaFeatures.new(@sdk_configuration)
  @actor_tokens = ActorTokens.new(@sdk_configuration)
  @domains = Domains.new(@sdk_configuration)
  @instance_settings = InstanceSettings.new(@sdk_configuration)
  @webhooks = Webhooks.new(@sdk_configuration)
  @jwt_templates = JwtTemplates.new(@sdk_configuration)
  @machines = Machines.new(@sdk_configuration)
  @organizations = Organizations.new(@sdk_configuration)
  @organization_roles = OrganizationRoles.new(@sdk_configuration)
  @organization_memberships = OrganizationMemberships.new(@sdk_configuration)
  @organization_domains = OrganizationDomains.new(@sdk_configuration)
  @proxy_checks = ProxyChecks.new(@sdk_configuration)
  @redirect_urls = RedirectUrls.new(@sdk_configuration)
  @sign_in_tokens = SignInTokens.new(@sdk_configuration)
  @sign_ups = SignUps.new(@sdk_configuration)
  @oauth_applications = OauthApplications.new(@sdk_configuration)
  @saml_connections = SamlConnections.new(@sdk_configuration)
  @testing_tokens = TestingTokens.new(@sdk_configuration)
  @waitlist_entries = WaitlistEntries.new(@sdk_configuration)
  @billing = Billing.new(@sdk_configuration)
  @organization_permissions = OrganizationPermissions.new(@sdk_configuration)
  @role_sets = RoleSets.new(@sdk_configuration)
  @api_keys = APIKeys.new(@sdk_configuration)
  @m2m = M2m.new(@sdk_configuration)
  @oauth_access_tokens = OauthAccessTokens.new(@sdk_configuration)
end