Class: AppStoreConnectApi::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/app_store_connect_api/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(raw_response, relationships = '') ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
13
# File 'lib/app_store_connect_api/response.rb', line 7

def initialize(raw_response, relationships = '')
  relationships = '' if relationships.nil?
  relationships = relationships.split(",")

  @raw_response = snake_case(raw_response)
  @relationships = snake_case(relationships)
end

Instance Method Details

#responseObject

Raises:



15
16
17
18
19
20
21
22
23
24
# File 'lib/app_store_connect_api/response.rb', line 15

def response
  return if @raw_response.empty?
  raise Error, @raw_response unless @raw_response.is_a? Hash

  if @raw_response.key? :errors
    raise ApiError, @raw_response[:errors]
  elsif @raw_response.key? :data
    process_data_from_response
  end
end