Class: Immobilienscout::ResponseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/immobilienscout/response_parser.rb

Defined Under Namespace

Classes: Message

Constant Summary collapse

HTTP_OK =
%w[200 201].freeze

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ResponseParser

Returns a new instance of ResponseParser.

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/immobilienscout/response_parser.rb', line 9

def initialize(response)
  @response = response

  raise ArgumentError unless valid?
end

Instance Method Details

#callObject



15
16
17
18
19
# File 'lib/immobilienscout/response_parser.rb', line 15

def call
  response_body = JSON.parse(@response.body)

  Message.new(success?, code, messages(response_body), id(response_body))
end