Class: ShotgridApiRuby::Preferences

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/shotgrid_api_ruby/preferences.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ void

Parameters:

  • connection (Faraday::Connection)


9
10
11
12
# File 'lib/shotgrid_api_ruby/preferences.rb', line 9

def initialize(connection)
  @connection = T.let(connection.dup, Faraday::Connection)
  @connection.url_prefix = "#{@connection.url_prefix}/preferences"
end

Instance Attribute Details

#connectionFaraday::Connection (readonly)

Returns:

  • (Faraday::Connection)


15
16
17
# File 'lib/shotgrid_api_ruby/preferences.rb', line 15

def connection
  @connection
end

Instance Method Details

#allOpenStruct

Returns:

  • (OpenStruct)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/shotgrid_api_ruby/preferences.rb', line 18

def all
  resp = @connection.get
  resp_body = JSON.parse(resp.body)

  if resp.status >= 300
    raise ShotgridCallError.new(
            response: resp,
            message:
              "Error while getting server preferences: #{resp_body['errors']}",
          )
  end

  data = resp_body['data']
  OpenStruct.new(data)
end