Sha256: a64602f88ce32ada4f6399f55828247162fb2b8ccb422e229df0871dee96dfd8

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

=begin
Wallee API: 1.0.0

The wallee API allows an easy interaction with the wallee web service.



Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=end

module Wallee
  class ApiError < StandardError
    attr_reader :code, :response_headers, :response_body

    # Usage examples:
    #   ApiError.new
    #   ApiError.new("message")
    #   ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
    #   ApiError.new(:code => 404, :message => "Not Found")
    def initialize(arg = nil)
      if arg.is_a? Hash
        if arg.key?(:message) || arg.key?('message')
          super(arg[:message] || arg['message'])
        else
          super arg
        end

        arg.each do |k, v|
          instance_variable_set "@#{k}", v
        end
      else
        super arg
      end
    end
  end
end

Version data entries

5 entries across 4 versions & 1 rubygems

Version Path
wallee-ruby-sdk-1.0.3 lib/wallee-ruby-sdk/api_error.rb
wallee-ruby-sdk-1.0.1 lib/wallee-ruby-sdk/api_error.rb
wallee-ruby-sdk-1.0.0 lib/wallee-ruby-sdk/api_error.rb
wallee-ruby-sdk-1.0.0 lib/wallee/api_error.rb
wallee-ruby-sdk-0.0.0 lib/wallee-ruby-sdk/api_error.rb