# 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 OpenApiSDK extend T::Sig class Server extend T::Sig # Operations against the Plex Media Server System. # sig { params(sdk_config: SDKConfiguration).void } def initialize(sdk_config) @sdk_configuration = sdk_config end sig { returns(::OpenApiSDK::Operations::GetServerCapabilitiesResponse) } def get_server_capabilities # get_server_capabilities - Server Capabilities # Server Capabilities url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/" 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 = ::OpenApiSDK::Operations::GetServerCapabilitiesResponse.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, ::OpenApiSDK::Operations::GetServerCapabilitiesResponseBody) res.two_hundred_application_json_object = out end elsif r.status == 400 elsif r.status == 401 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Operations::GetServerCapabilitiesServerResponseBody) res.four_hundred_and_one_application_json_object = out end end res end sig { returns(::OpenApiSDK::Operations::GetServerPreferencesResponse) } def get_server_preferences # get_server_preferences - Get Server Preferences # Get Server Preferences url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/:/prefs" 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 = ::OpenApiSDK::Operations::GetServerPreferencesResponse.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, ::OpenApiSDK::Operations::GetServerPreferencesResponseBody) res.two_hundred_application_json_object = out end elsif r.status == 400 elsif r.status == 401 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Operations::GetServerPreferencesServerResponseBody) res.four_hundred_and_one_application_json_object = out end end res end sig { returns(::OpenApiSDK::Operations::GetAvailableClientsResponse) } def get_available_clients # get_available_clients - Get Available Clients # Get Available Clients url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/clients" 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 = ::OpenApiSDK::Operations::GetAvailableClientsResponse.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, ::OpenApiSDK::Operations::GetAvailableClientsResponseBody) res.two_hundred_application_json_object = out end elsif r.status == 400 elsif r.status == 401 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Operations::GetAvailableClientsServerResponseBody) res.four_hundred_and_one_application_json_object = out end end res end sig { returns(::OpenApiSDK::Operations::GetDevicesResponse) } def get_devices # get_devices - Get Devices # Get Devices url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/devices" 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 = ::OpenApiSDK::Operations::GetDevicesResponse.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, ::OpenApiSDK::Operations::GetDevicesResponseBody) res.two_hundred_application_json_object = out end elsif r.status == 400 elsif r.status == 401 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Operations::GetDevicesServerResponseBody) res.four_hundred_and_one_application_json_object = out end end res end sig { returns(::OpenApiSDK::Operations::GetServerIdentityResponse) } def get_server_identity # get_server_identity - Get Server Identity # Get Server Identity url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/identity" 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 = ::OpenApiSDK::Operations::GetServerIdentityResponse.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, ::OpenApiSDK::Operations::GetServerIdentityResponseBody) res.two_hundred_application_json_object = out end elsif r.status == 400 elsif r.status == 401 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Operations::GetServerIdentityServerResponseBody) res.four_hundred_and_one_application_json_object = out end end res end sig { returns(::OpenApiSDK::Operations::GetMyPlexAccountResponse) } def get_my_plex_account # get_my_plex_account - Get MyPlex Account # Returns MyPlex Account Information url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/myplex/account" 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 = ::OpenApiSDK::Operations::GetMyPlexAccountResponse.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, ::OpenApiSDK::Operations::GetMyPlexAccountResponseBody) res.two_hundred_application_json_object = out end elsif r.status == 400 elsif r.status == 401 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Operations::GetMyPlexAccountServerResponseBody) res.four_hundred_and_one_application_json_object = out end end res end sig { params(request: T.nilable(::OpenApiSDK::Operations::GetResizedPhotoRequest)).returns(::OpenApiSDK::Operations::GetResizedPhotoResponse) } def get_resized_photo(request) # get_resized_photo - Get a Resized Photo # Plex's Photo transcoder is used throughout the service to serve images at specified sizes. # url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/photo/:/transcode" headers = {} query_params = Utils.get_query_params(::OpenApiSDK::Operations::GetResizedPhotoRequest, request, @sdk_configuration.globals) headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers req.params = query_params 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 = ::OpenApiSDK::Operations::GetResizedPhotoResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if [200, 400].include?(r.status) elsif r.status == 401 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Operations::GetResizedPhotoResponseBody) res.object = out end end res end sig { returns(::OpenApiSDK::Operations::GetServerListResponse) } def get_server_list # get_server_list - Get Server List # Get Server List url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/servers" 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 = ::OpenApiSDK::Operations::GetServerListResponse.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, ::OpenApiSDK::Operations::GetServerListResponseBody) res.two_hundred_application_json_object = out end elsif r.status == 400 elsif r.status == 401 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Operations::GetServerListServerResponseBody) res.four_hundred_and_one_application_json_object = out end end res end end end