Sha256: 4c6a73ad0541cc0fbf6b53068cebd44a8ec94dfbac7e1bf36fdb2db70e5ec49d

Contents?: true

Size: 1.52 KB

Versions: 3

Compression:

Stored size: 1.52 KB

Contents

# bandwidth
#
# This file was automatically generated by APIMATIC v2.0
# ( https://apimatic.io ).

module Bandwidth
  # BandwidthException class.
  class BandwidthException < APIException
    # TODO: Write general description for this method
    # @return [String]
    attr_accessor :type

    # TODO: Write general description for this method
    # @return [String]
    attr_accessor :description

    # TODO: Write general description for this method
    # @return [String]
    attr_accessor :id

    # TODO: Write general description for this method
    # @return [List of FieldError]
    attr_accessor :field_errors

    # The constructor.
    # @param [String] The reason for raising an exception.
    # @param [HttpResponse] The HttpReponse of the API call.
    def initialize(reason, response)
      super(reason, response)
      hash = APIHelper.json_deserialize(@response.raw_body)
      unbox(hash)
    end

    # Populates this object by extracting properties from a hash.
    # @param [Hash] The deserialized response sent by the server in the
    # response body.
    def unbox(hash)
      @type = hash['type']
      @description = hash['description']
      @id = hash['id']
      # Parameter is an array, so we need to iterate through it
      @field_errors = nil
      unless hash['fieldErrors'].nil?
        @field_errors = []
        hash['fieldErrors'].each do |structure|
          @field_errors << (FieldError.from_hash(structure) if structure)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bandwidth-sdk-1.0.1 lib/bandwidth/voice_lib/voice/exceptions/bandwidth_exception.rb
bandwidth-sdk-1.0.0 lib/bandwidth/voice_lib/voice/exceptions/bandwidth_exception.rb
bandwidth-sdk-1.0.0.pre lib/bandwidth/voice_lib/voice/exceptions/bandwidth_exception.rb