Class: Io::Flow::V0::Models::OrderItemNotAvailableError

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

Overview

When creating an order, if a particular item is not available in the country / destination (either because it was restricted or excluded from that country), we return this error to highlight the specific item numbers which are not available.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OrderError

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ OrderItemNotAvailableError

Returns a new instance of OrderItemNotAvailableError.



13543
13544
13545
13546
13547
13548
13549
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13543

def initialize(incoming={})
  super(:name => OrderError::Types::ORDER_ITEM_NOT_AVAILABLE_ERROR)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:messages, :numbers], 'OrderItemNotAvailableError')
  @messages = HttpClient::Preconditions.assert_class('messages', opts.delete(:messages), Array).map { |v| HttpClient::Preconditions.assert_class('messages', v, String) }
  @numbers = HttpClient::Preconditions.assert_class('numbers', opts.delete(:numbers), Array).map { |v| HttpClient::Preconditions.assert_class('numbers', v, String) }
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



13541
13542
13543
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13541

def messages
  @messages
end

#numbersObject (readonly)

Returns the value of attribute numbers.



13541
13542
13543
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13541

def numbers
  @numbers
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13555
13556
13557
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13555

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

#subtype_to_hashObject



13559
13560
13561
13562
13563
13564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13559

def subtype_to_hash
  {
    :messages => messages,
    :numbers => numbers
  }
end

#to_jsonObject



13551
13552
13553
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13551

def to_json
  JSON.dump(to_hash)
end