Class: ShotgridApiRuby::ServerInfo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ void

Parameters:

  • connection (Faraday::Connection)


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

def initialize(connection)
  @connection = T.let(connection, Faraday::Connection)
end

Instance Attribute Details

#connectionFaraday::Connection (readonly)

Returns:

  • (Faraday::Connection)


14
15
16
# File 'lib/shotgrid_api_ruby/server_info.rb', line 14

def connection
  @connection
end

Instance Method Details

#getOpenStruct

Returns:

  • (OpenStruct)


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

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

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

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