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.531.4
This commit is contained in:
@@ -27,7 +27,7 @@ module PlexRubySDK
|
||||
end
|
||||
|
||||
|
||||
sig { params(request: T.nilable(::PlexRubySDK::Operations::GetUsersRequest), server_url: T.nilable(String), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetUsersResponse) }
|
||||
sig { params(request: T.nilable(Models::Operations::GetUsersRequest), server_url: T.nilable(String), timeout_ms: T.nilable(Integer)).returns(Models::Operations::GetUsersResponse) }
|
||||
def get_users(request, server_url = nil, timeout_ms = nil)
|
||||
# get_users - Get list of all connected users
|
||||
# Get list of all users that are friends and have library access with the provided Plex authentication token
|
||||
@@ -36,7 +36,7 @@ module PlexRubySDK
|
||||
base_url = server_url if !server_url.nil?
|
||||
url = "#{base_url}/users"
|
||||
headers = Utils.get_headers(request)
|
||||
headers['Accept'] = 'application/json;q=1, application/xml;q=0'
|
||||
headers['Accept'] = 'application/xml'
|
||||
headers['user-agent'] = @sdk_configuration.user_agent
|
||||
|
||||
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
||||
@@ -52,10 +52,11 @@ module PlexRubySDK
|
||||
)
|
||||
|
||||
error = T.let(nil, T.nilable(StandardError))
|
||||
r = T.let(nil, T.nilable(Faraday::Response))
|
||||
http_response = T.let(nil, T.nilable(Faraday::Response))
|
||||
|
||||
|
||||
begin
|
||||
r = connection.get(url) do |req|
|
||||
http_response = connection.get(url) do |req|
|
||||
req.headers.merge!(headers)
|
||||
req.options.timeout = timeout unless timeout.nil?
|
||||
|
||||
@@ -69,49 +70,85 @@ module PlexRubySDK
|
||||
rescue StandardError => e
|
||||
error = e
|
||||
ensure
|
||||
if r.nil? || Utils.error_status?(r.status)
|
||||
r = @sdk_configuration.hooks.after_error(
|
||||
if http_response.nil? || Utils.error_status?(http_response.status)
|
||||
http_response = @sdk_configuration.hooks.after_error(
|
||||
error: error,
|
||||
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
||||
hook_ctx: hook_ctx
|
||||
),
|
||||
response: r
|
||||
response: http_response
|
||||
)
|
||||
else
|
||||
r = @sdk_configuration.hooks.after_success(
|
||||
http_response = @sdk_configuration.hooks.after_success(
|
||||
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
||||
hook_ctx: hook_ctx
|
||||
),
|
||||
response: r
|
||||
response: http_response
|
||||
)
|
||||
end
|
||||
|
||||
if r.nil?
|
||||
if http_response.nil?
|
||||
raise error if !error.nil?
|
||||
raise 'no response'
|
||||
end
|
||||
end
|
||||
|
||||
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
||||
if Utils.match_status_code(http_response.status, ['200'])
|
||||
if Utils.match_content_type(content_type, 'application/xml')
|
||||
http_response = @sdk_configuration.hooks.after_success(
|
||||
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
||||
hook_ctx: hook_ctx
|
||||
),
|
||||
response: http_response
|
||||
)
|
||||
obj = http_response.env.body
|
||||
|
||||
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
||||
return Models::Operations::GetUsersResponse.new(
|
||||
status_code: http_response.status,
|
||||
content_type: content_type,
|
||||
raw_response: http_response,
|
||||
body: obj
|
||||
)
|
||||
else
|
||||
raise ::PlexRubySDK::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
||||
end
|
||||
elsif Utils.match_status_code(http_response.status, ['400'])
|
||||
if Utils.match_content_type(content_type, 'application/json')
|
||||
http_response = @sdk_configuration.hooks.after_success(
|
||||
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
||||
hook_ctx: hook_ctx
|
||||
),
|
||||
response: http_response
|
||||
)
|
||||
obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), Models::Errors::GetUsersBadRequest)
|
||||
obj.raw_response = http_response
|
||||
throw obj
|
||||
else
|
||||
raise ::PlexRubySDK::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
||||
end
|
||||
elsif Utils.match_status_code(http_response.status, ['401'])
|
||||
if Utils.match_content_type(content_type, 'application/json')
|
||||
http_response = @sdk_configuration.hooks.after_success(
|
||||
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
||||
hook_ctx: hook_ctx
|
||||
),
|
||||
response: http_response
|
||||
)
|
||||
obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), Models::Errors::GetUsersUnauthorized)
|
||||
obj.raw_response = http_response
|
||||
throw obj
|
||||
else
|
||||
raise ::PlexRubySDK::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
||||
end
|
||||
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
||||
raise ::PlexRubySDK::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
||||
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
||||
raise ::PlexRubySDK::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
||||
else
|
||||
raise ::PlexRubySDK::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown status code received'
|
||||
|
||||
res = ::PlexRubySDK::Operations::GetUsersResponse.new(
|
||||
status_code: r.status, content_type: content_type, raw_response: r
|
||||
)
|
||||
if r.status == 200
|
||||
res.body = r.env.response_body if Utils.match_content_type(content_type, 'application/xml')
|
||||
elsif r.status == 400
|
||||
if Utils.match_content_type(content_type, 'application/json')
|
||||
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetUsersBadRequest)
|
||||
res.bad_request = out
|
||||
end
|
||||
elsif r.status == 401
|
||||
if Utils.match_content_type(content_type, 'application/json')
|
||||
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetUsersUnauthorized)
|
||||
res.unauthorized = out
|
||||
end
|
||||
end
|
||||
|
||||
res
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user