mirror of
https://github.com/LukeHagar/plexruby.git
synced 2025-12-06 04:20:52 +00:00
140 lines
5.1 KiB
Ruby
140 lines
5.1 KiB
Ruby
# 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 Media
|
|
extend T::Sig
|
|
# API Calls interacting with Plex Media Server Media
|
|
#
|
|
|
|
sig { params(sdk_config: SDKConfiguration).void }
|
|
def initialize(sdk_config)
|
|
@sdk_configuration = sdk_config
|
|
end
|
|
|
|
|
|
sig { params(key: ::Float).returns(::OpenApiSDK::Operations::MarkPlayedResponse) }
|
|
def mark_played(key)
|
|
# mark_played - Mark Media Played
|
|
# This will mark the provided media key as Played.
|
|
request = ::OpenApiSDK::Operations::MarkPlayedRequest.new(
|
|
|
|
key: key
|
|
)
|
|
url, params = @sdk_configuration.get_server_details
|
|
base_url = Utils.template_url(url, params)
|
|
url = "#{base_url}/:/scrobble"
|
|
headers = {}
|
|
query_params = Utils.get_query_params(::OpenApiSDK::Operations::MarkPlayedRequest, 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::MarkPlayedResponse.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::MarkPlayedResponseBody)
|
|
res.object = out
|
|
end
|
|
end
|
|
res
|
|
end
|
|
|
|
|
|
sig { params(key: ::Float).returns(::OpenApiSDK::Operations::MarkUnplayedResponse) }
|
|
def mark_unplayed(key)
|
|
# mark_unplayed - Mark Media Unplayed
|
|
# This will mark the provided media key as Unplayed.
|
|
request = ::OpenApiSDK::Operations::MarkUnplayedRequest.new(
|
|
|
|
key: key
|
|
)
|
|
url, params = @sdk_configuration.get_server_details
|
|
base_url = Utils.template_url(url, params)
|
|
url = "#{base_url}/:/unscrobble"
|
|
headers = {}
|
|
query_params = Utils.get_query_params(::OpenApiSDK::Operations::MarkUnplayedRequest, 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::MarkUnplayedResponse.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::MarkUnplayedResponseBody)
|
|
res.object = out
|
|
end
|
|
end
|
|
res
|
|
end
|
|
|
|
|
|
sig { params(key: ::String, time: ::Float, state: ::String).returns(::OpenApiSDK::Operations::UpdatePlayProgressResponse) }
|
|
def update_play_progress(key, time, state)
|
|
# update_play_progress - Update Media Play Progress
|
|
# This API command can be used to update the play progress of a media item.
|
|
#
|
|
request = ::OpenApiSDK::Operations::UpdatePlayProgressRequest.new(
|
|
|
|
key: key,
|
|
time: time,
|
|
state: state
|
|
)
|
|
url, params = @sdk_configuration.get_server_details
|
|
base_url = Utils.template_url(url, params)
|
|
url = "#{base_url}/:/progress"
|
|
headers = {}
|
|
query_params = Utils.get_query_params(::OpenApiSDK::Operations::UpdatePlayProgressRequest, request, @sdk_configuration.globals)
|
|
headers['Accept'] = 'application/json'
|
|
headers['user-agent'] = @sdk_configuration.user_agent
|
|
|
|
r = @sdk_configuration.client.post(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::UpdatePlayProgressResponse.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::UpdatePlayProgressResponseBody)
|
|
res.object = out
|
|
end
|
|
end
|
|
res
|
|
end
|
|
end
|
|
end
|