mirror of
https://github.com/LukeHagar/plexruby.git
synced 2025-12-07 04:20:54 +00:00
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.526.6
This commit is contained in:
103
lib/plex_ruby_sdk/sdk_hooks/hooks.rb
Normal file
103
lib/plex_ruby_sdk/sdk_hooks/hooks.rb
Normal file
@@ -0,0 +1,103 @@
|
||||
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
||||
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative './registration'
|
||||
require_relative './types'
|
||||
|
||||
require 'sorbet-runtime'
|
||||
|
||||
module PlexRubySDK
|
||||
module SDKHooks
|
||||
class Hooks
|
||||
extend T::Sig
|
||||
|
||||
sig { void }
|
||||
def initialize
|
||||
@sdk_init_hooks = T.let([], T::Array[AbstractSDKInitHook])
|
||||
@before_request_hooks = T.let([], T::Array[AbstractBeforeRequestHook])
|
||||
@after_success_hooks = T.let([], T::Array[AbstractAfterSuccessHook])
|
||||
@after_error_hooks = T.let([], T::Array[AbstractAfterErrorHook])
|
||||
Registration.init_hooks self
|
||||
end
|
||||
|
||||
sig { params(hook: AbstractSDKInitHook).void }
|
||||
def register_sdk_init_hook(hook)
|
||||
@sdk_init_hooks << hook
|
||||
end
|
||||
|
||||
sig { params(hook: AbstractBeforeRequestHook).void }
|
||||
def register_before_request_hook(hook)
|
||||
@before_request_hooks << hook
|
||||
end
|
||||
|
||||
sig { params(hook: AbstractAfterSuccessHook).void }
|
||||
def register_after_success_hook(hook)
|
||||
@after_success_hooks << hook
|
||||
end
|
||||
|
||||
sig { params(hook: AbstractAfterErrorHook).void }
|
||||
def register_after_error_hook(hook)
|
||||
@after_error_hooks << hook
|
||||
end
|
||||
|
||||
sig do
|
||||
params(
|
||||
base_url: String,
|
||||
client: Faraday::Connection
|
||||
).returns([String, Faraday::Connection])
|
||||
end
|
||||
def sdk_init(base_url:, client:)
|
||||
@sdk_init_hooks.each do |hook|
|
||||
base_url, client = hook.sdk_init(base_url: base_url, client: client)
|
||||
end
|
||||
|
||||
return base_url, client
|
||||
end
|
||||
|
||||
sig do
|
||||
params(
|
||||
hook_ctx: BeforeRequestHookContext,
|
||||
request: Faraday::Request
|
||||
).returns(Faraday::Request)
|
||||
end
|
||||
def before_request(hook_ctx:, request:)
|
||||
@before_request_hooks.each do |hook|
|
||||
request = hook.before_request(hook_ctx: hook_ctx, request: request)
|
||||
end
|
||||
|
||||
request
|
||||
end
|
||||
|
||||
sig do
|
||||
params(
|
||||
hook_ctx: AfterSuccessHookContext,
|
||||
response: Faraday::Response
|
||||
).returns(Faraday::Response)
|
||||
end
|
||||
def after_success(hook_ctx:, response:)
|
||||
@after_success_hooks.each do |hook|
|
||||
response = hook.after_success(hook_ctx: hook_ctx, response: response)
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
sig do
|
||||
params(
|
||||
error: T.nilable(StandardError),
|
||||
hook_ctx: AfterErrorHookContext,
|
||||
response: T.nilable(Faraday::Response)
|
||||
).returns(T.nilable(Faraday::Response))
|
||||
end
|
||||
def after_error(error:, hook_ctx:, response:)
|
||||
@after_error_hooks.each do |hook|
|
||||
response = hook.after_error(error: error, hook_ctx: hook_ctx, response: response)
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
35
lib/plex_ruby_sdk/sdk_hooks/registration.rb
Normal file
35
lib/plex_ruby_sdk/sdk_hooks/registration.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file is only ever generated once on the first generation and then is free to be modified.
|
||||
# Any hooks you wish to add should be registered in the init_hooks method.
|
||||
#
|
||||
# Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance.
|
||||
#
|
||||
|
||||
require_relative './types'
|
||||
|
||||
require 'sorbet-runtime'
|
||||
|
||||
module PlexRubySDK
|
||||
module SDKHooks
|
||||
class Registration
|
||||
extend T::Sig
|
||||
|
||||
sig do
|
||||
params(
|
||||
hooks: Hooks
|
||||
).void
|
||||
end
|
||||
def self.init_hooks(hooks)
|
||||
# example_hook = ExampleHook.new
|
||||
|
||||
# hooks.register_sdk_init_hook example_hook
|
||||
# hooks.register_before_request_hook example_hook
|
||||
# hooks.register_after_error_hook example_hook
|
||||
# hooks.register_after_success_hook example_hook
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
152
lib/plex_ruby_sdk/sdk_hooks/types.rb
Normal file
152
lib/plex_ruby_sdk/sdk_hooks/types.rb
Normal file
@@ -0,0 +1,152 @@
|
||||
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
||||
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'sorbet-runtime'
|
||||
|
||||
module PlexRubySDK
|
||||
module SDKHooks
|
||||
class HookContext
|
||||
extend T::Sig
|
||||
|
||||
sig { returns(String) }
|
||||
attr_accessor :base_url
|
||||
|
||||
sig { returns(T.nilable(T::Array[String])) }
|
||||
attr_accessor :oauth2_scopes
|
||||
|
||||
sig { returns(String) }
|
||||
attr_accessor :operation_id
|
||||
|
||||
sig { returns(T.nilable(T.proc.returns(T.untyped))) }
|
||||
attr_accessor :security_source
|
||||
|
||||
sig do
|
||||
params(
|
||||
base_url: String,
|
||||
oauth2_scopes: T.nilable(T::Array[String]),
|
||||
operation_id: String,
|
||||
security_source: T.nilable(T.proc.returns(T.untyped))
|
||||
).void
|
||||
end
|
||||
def initialize(base_url:, oauth2_scopes:, operation_id:, security_source:)
|
||||
@base_url = T.let(base_url, String)
|
||||
@oauth2_scopes = T.let(oauth2_scopes, T.nilable(T::Array[String]))
|
||||
@operation_id = T.let(operation_id, String)
|
||||
@security_source = T.let(security_source, T.nilable(T.proc.returns(T.untyped)))
|
||||
end
|
||||
end
|
||||
|
||||
class BeforeRequestHookContext < HookContext
|
||||
extend T::Sig
|
||||
|
||||
sig do
|
||||
params(
|
||||
hook_ctx: HookContext
|
||||
).void
|
||||
end
|
||||
def initialize(hook_ctx:)
|
||||
super(
|
||||
base_url: hook_ctx.base_url,
|
||||
operation_id: hook_ctx.operation_id,
|
||||
oauth2_scopes: hook_ctx.oauth2_scopes,
|
||||
security_source: hook_ctx.security_source
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class AfterSuccessHookContext < HookContext
|
||||
extend T::Sig
|
||||
|
||||
sig do
|
||||
params(
|
||||
hook_ctx: HookContext
|
||||
).void
|
||||
end
|
||||
def initialize(hook_ctx:)
|
||||
super(
|
||||
base_url: hook_ctx.base_url,
|
||||
operation_id: hook_ctx.operation_id,
|
||||
oauth2_scopes: hook_ctx.oauth2_scopes,
|
||||
security_source: hook_ctx.security_source
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class AfterErrorHookContext < HookContext
|
||||
extend T::Sig
|
||||
|
||||
sig do
|
||||
params(
|
||||
hook_ctx: HookContext
|
||||
).void
|
||||
end
|
||||
def initialize(hook_ctx:)
|
||||
super(
|
||||
base_url: hook_ctx.base_url,
|
||||
operation_id: hook_ctx.operation_id,
|
||||
oauth2_scopes: hook_ctx.oauth2_scopes,
|
||||
security_source: hook_ctx.security_source
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
module AbstractSDKInitHook
|
||||
extend T::Sig
|
||||
extend T::Helpers
|
||||
abstract!
|
||||
|
||||
sig do
|
||||
abstract.params(
|
||||
base_url: String,
|
||||
client: Faraday::Connection
|
||||
).returns([String, Faraday::Connection])
|
||||
end
|
||||
def sdk_init(base_url:, client:); end
|
||||
end
|
||||
|
||||
module AbstractBeforeRequestHook
|
||||
extend T::Sig
|
||||
extend T::Helpers
|
||||
abstract!
|
||||
|
||||
sig do
|
||||
abstract.params(
|
||||
hook_ctx: BeforeRequestHookContext,
|
||||
request: Faraday::Request
|
||||
).returns(Faraday::Request)
|
||||
end
|
||||
def before_request(hook_ctx:, request:); end
|
||||
end
|
||||
|
||||
module AbstractAfterSuccessHook
|
||||
extend T::Sig
|
||||
extend T::Helpers
|
||||
abstract!
|
||||
|
||||
sig do
|
||||
abstract.params(
|
||||
hook_ctx: AfterSuccessHookContext,
|
||||
response: Faraday::Response
|
||||
).returns(Faraday::Response)
|
||||
end
|
||||
def after_success(hook_ctx:, response:); end
|
||||
end
|
||||
|
||||
module AbstractAfterErrorHook
|
||||
extend T::Sig
|
||||
extend T::Helpers
|
||||
abstract!
|
||||
|
||||
sig do
|
||||
abstract.params(
|
||||
error: T.nilable(StandardError),
|
||||
hook_ctx: AfterErrorHookContext,
|
||||
response: T.nilable(Faraday::Response)
|
||||
).returns(T.nilable(Faraday::Response))
|
||||
end
|
||||
def after_error(error:, hook_ctx:, response:); end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user