Class: SynergyWholesale::BaseResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/synergy_wholesale/base_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, command) ⇒ BaseResponse

Returns a new instance of BaseResponse.



6
7
8
9
10
11
12
13
# File 'lib/synergy_wholesale/base_response.rb', line 6

def initialize(response, command)
  @response = response
  @command  = command

  validate_status
  validate_expected_fields
  validate_data
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



4
5
6
# File 'lib/synergy_wholesale/base_response.rb', line 4

def command
  @command
end

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/synergy_wholesale/base_response.rb', line 4

def response
  @response
end

Instance Method Details

#bodyObject



23
24
25
# File 'lib/synergy_wholesale/base_response.rb', line 23

def body
  response
end

#messageObject



19
20
21
# File 'lib/synergy_wholesale/base_response.rb', line 19

def message
  response[:error_message]
end

#successful?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/synergy_wholesale/base_response.rb', line 15

def successful?
  [*success_statuses].include?(response[:status])
end