mirror of
https://github.com/LukeHagar/plexruby.git
synced 2025-12-07 12:47:45 +00:00
regenerated with newest spec, reconfigured actions and adding publishing
This commit is contained in:
77
lib/plex_ruby_sdk/watchlist.rb
Normal file
77
lib/plex_ruby_sdk/watchlist.rb
Normal file
@@ -0,0 +1,77 @@
|
||||
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
||||
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'faraday'
|
||||
require 'faraday/multipart'
|
||||
require 'sorbet-runtime'
|
||||
|
||||
module PlexRubySDK
|
||||
extend T::Sig
|
||||
class Watchlist
|
||||
extend T::Sig
|
||||
|
||||
# GET_WATCH_LIST_SERVERS contains the list of server urls available to the SDK.
|
||||
GET_WATCH_LIST_SERVERS = [
|
||||
'https://metadata.provider.plex.tv', # The plex metadata provider server
|
||||
].freeze
|
||||
# API Calls that perform operations with Plex Media Server Watchlists
|
||||
#
|
||||
|
||||
sig { params(sdk_config: SDKConfiguration).void }
|
||||
def initialize(sdk_config)
|
||||
@sdk_configuration = sdk_config
|
||||
end
|
||||
|
||||
|
||||
sig { params(request: T.nilable(::PlexRubySDK::Operations::GetWatchListRequest), server_url: T.nilable(String)).returns(::PlexRubySDK::Operations::GetWatchListResponse) }
|
||||
def get_watch_list(request, server_url = nil)
|
||||
# get_watch_list - Get User Watchlist
|
||||
# Get User Watchlist
|
||||
base_url = Utils.template_url(GET_WATCH_LIST_SERVERS[0], {
|
||||
})
|
||||
base_url = server_url if !server_url.nil?
|
||||
url = Utils.generate_url(
|
||||
::PlexRubySDK::Operations::GetWatchListRequest,
|
||||
base_url,
|
||||
'/library/sections/watchlist/{filter}',
|
||||
request,
|
||||
@sdk_configuration.globals
|
||||
)
|
||||
headers = {}
|
||||
query_params = Utils.get_query_params(::PlexRubySDK::Operations::GetWatchListRequest, 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 = ::PlexRubySDK::Operations::GetWatchListResponse.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, ::PlexRubySDK::Operations::GetWatchListResponseBody)
|
||||
res.object = out
|
||||
end
|
||||
elsif r.status == 400
|
||||
if Utils.match_content_type(content_type, 'application/json')
|
||||
out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetWatchListBadRequest)
|
||||
res.bad_request = out
|
||||
end
|
||||
elsif r.status == 401
|
||||
if Utils.match_content_type(content_type, 'application/json')
|
||||
out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetWatchListUnauthorized)
|
||||
res.unauthorized = out
|
||||
end
|
||||
end
|
||||
res
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user