Class: Io::Flow::V0::Models::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Represents an error of some sort (e.g. invalid input). Each error will contain a code and a specific message describing the failure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Error

Returns a new instance of Error.



8088
8089
8090
8091
8092
8093
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8088

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:code, :message], 'Error')
  @code = HttpClient::Preconditions.assert_class('code', opts.delete(:code), String)
  @message = HttpClient::Preconditions.assert_class('message', opts.delete(:message), String)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



8086
8087
8088
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8086

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message.



8086
8087
8088
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8086

def message
  @message
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



8099
8100
8101
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8099

def copy(incoming={})
  Error.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



8103
8104
8105
8106
8107
8108
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8103

def to_hash
  {
    :code => code,
    :message => message
  }
end

#to_jsonObject



8095
8096
8097
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8095

def to_json
  JSON.dump(to_hash)
end