Module: TinyAppstoreConnect::Parser

Defined in:
lib/tiny_appstore_connect/model.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.typesObject

Returns the value of attribute types.



72
73
74
# File 'lib/tiny_appstore_connect/model.rb', line 72

def types
  @types
end

.types_cacheObject

Returns the value of attribute types_cache.



73
74
75
# File 'lib/tiny_appstore_connect/model.rb', line 73

def types_cache
  @types_cache
end

Class Method Details

.parse(response, rate) ⇒ Object

Raises:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/tiny_appstore_connect/model.rb', line 76

def self.parse(response, rate)
  body = response.body
  data = body['data']
  raise ConnectAPIError, 'No data' unless data

  included = body['included'] || []
  case data
  when Hash
    inflate_model(data, included, rate: rate)
  when Array
    data.map do |model_data|
      inflate_model(model_data, included, rate: rate)
    end
  else
    raise ConnectAPIError, "'data' is neither a hash nor an array"
  end
end