Exception: SpreeAvatax::Shared::FailedApiResponse

Inherits:
StandardError
  • Object
show all
Defined in:
app/models/spree_avatax/shared.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ FailedApiResponse

Returns a new instance of FailedApiResponse.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/spree_avatax/shared.rb', line 5

def initialize(response)
  @response = response
  # avatax seems to have two different error message formats:
  # https://gist.github.com/jordan-brough/a22163e4551c692365b8
  # https://gist.github.com/jordan-brough/c778a3417850dfa2307c
  # We should pester Avatax about this sometime.
  if @response[:messages].is_a?(Array)
    @messages = response[:messages]
  else
    @messages = Array.wrap(response[:messages][:message])
  end

  super(messages.map { |msg| msg[:summary] })
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



3
4
5
# File 'app/models/spree_avatax/shared.rb', line 3

def messages
  @messages
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'app/models/spree_avatax/shared.rb', line 3

def response
  @response
end