Sha256: 044780790547f926702b0c76d4e4f1e7c917557118bac1fc6b1e29a73465ab3c

Contents?: true

Size: 1.81 KB

Versions: 3

Compression:

Stored size: 1.81 KB

Contents

# Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.

# typed: true
# frozen_string_literal: true

require 'faraday'
require 'faraday/multipart'
require 'sorbet-runtime'

module SpeakeasyClientSDK
  extend T::Sig
  class Auth
    extend T::Sig
    # REST APIs for managing Authentication

    sig { params(sdk_config: SDKConfiguration).void }
    def initialize(sdk_config)
      @sdk_configuration = sdk_config
    end


    sig { returns(::SpeakeasyClientSDK::Utils::FieldAugmented) }
    def validate_api_key
      # validate_api_key - Validate the current api key.
      url, params = @sdk_configuration.get_server_details
      base_url = Utils.template_url(url, params)
      url = "#{base_url}/v1/auth/validate"
      headers = {}
      headers['Accept'] = 'application/json'
      headers['user-agent'] = @sdk_configuration.user_agent

      r = @sdk_configuration.client.get(url) do |req|
        req.headers = headers
        Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
      end

      content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

      res = ::SpeakeasyClientSDK::Operations::ValidateApiKeyResponse.new(
        status_code: r.status, content_type: content_type, raw_response: r
      )
      if r.status == 200
        if Utils.match_content_type(content_type, 'application/json')
          out = Utils.unmarshal_complex(r.env.response_body, ::SpeakeasyClientSDK::Shared::ApiKeyDetails)
          res.api_key_details = out
        end
      else
                
        if Utils.match_content_type(content_type, 'application/json')
          out = Utils.unmarshal_complex(r.env.response_body, ::SpeakeasyClientSDK::Shared::Error)
          res.error = out
        end
      end
      res
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
speakeasy_client_sdk_ruby-4.0.2 lib/speakeasy_client_sdk/auth.rb
speakeasy_client_sdk_ruby-4.0.1 lib/speakeasy_client_sdk/auth.rb
speakeasy_client_sdk_ruby-4.0.0 lib/speakeasy_client_sdk/auth.rb