Class: LemonWay::ResponseAdapter

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/lemon_way/response_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ResponseAdapter

Returns a new instance of ResponseAdapter.



8
9
10
11
12
13
14
# File 'lib/lemon_way/response_adapter.rb', line 8

def initialize(response)
  response = JSON.parse(response.body)['d'].deep_transform_keys { |key| key.underscore.to_sym }

  raise LemonWay::LemonWayError.new(response[:e]) if response[:e].present?

  super(values_for(response))
end