class ShotgridApiRuby::Client
Main class for connection.
This should be only instanciated once to re-use tokens
Attributes
connection[R]
Faraday connection
Public Class Methods
new(auth:, site_url: nil, shotgun_site: nil, shotgrid_site: nil)
click to toggle source
# File lib/shotgrid_api_ruby/client.rb, line 11 def initialize(auth:, site_url: nil, shotgun_site: nil, shotgrid_site: nil) raise 'No site given' unless site_url || shotgun_site || shotgrid_site raise 'auth param not valid' unless auth && Auth::Validator.valid?(**auth) site_url ||= if shotgun_site "https://#{shotgun_site}.shotgunstudio.com/api/v1" elsif shotgrid_site "https://#{shotgrid_site}.shotgrid.autodesk.com/api/v1" end @connection = Faraday.new(url: site_url) do |faraday| faraday.use(ShotgridApiRuby::Auth, auth: auth, site_url: site_url) faraday.adapter Faraday.default_adapter end end
Public Instance Methods
entities(type)
click to toggle source
Access entities related APIs
# File lib/shotgrid_api_ruby/client.rb, line 40 def entities(type) public_send(type) end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/shotgrid_api_ruby/client.rb, line 48 def method_missing(name, *args, &block) if args.empty? fname = formated_name(name) self .class .define_method(fname) do if entities_client = instance_variable_get("@#{fname}") entities_client else entities_client = entities_aux(fname) instance_variable_set("@#{fname}", entities_client) end end self.class.instance_eval { alias_method name, fname } send(fname) else super end end
preferences()
click to toggle source
Access preferences APIs
# File lib/shotgrid_api_ruby/client.rb, line 30 def preferences @preferences = Preferences.new(connection) end
respond_to_missing?(_name, _include_private = false)
click to toggle source
# File lib/shotgrid_api_ruby/client.rb, line 44 def respond_to_missing?(_name, _include_private = false) true end
server_info()
click to toggle source
Access server_info
APIs
# File lib/shotgrid_api_ruby/client.rb, line 35 def server_info @server_info || ServerInfo.new(connection) end
Private Instance Methods
entities_aux(type)
click to toggle source
# File lib/shotgrid_api_ruby/client.rb, line 74 def entities_aux(type) type = formated_name(type) @entity_caller = Entities.new(connection, type) end
formated_name(name)
click to toggle source
# File lib/shotgrid_api_ruby/client.rb, line 70 def formated_name(name) name.to_s.camelize.singularize end