Class: ShotgunApiRuby::Preferences

Inherits:
Object
  • Object
show all
Defined in:
lib/shotgun_api_ruby/preferences.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Preferences

Returns a new instance of Preferences.



5
6
7
8
# File 'lib/shotgun_api_ruby/preferences.rb', line 5

def initialize(connection)
  @connection = connection.dup
  @connection.url_prefix = "#{@connection.url_prefix}/preferences"
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



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

def connection
  @connection
end

Instance Method Details

#allObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/shotgun_api_ruby/preferences.rb', line 12

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

  if resp.status >= 300
    raise "Error while getting server preferences: #{resp_body['errors']}"
  end

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