Class: Io::Flow::V0::Models::OrderBooking

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

Overview

Represents an order that has been booked. Booked orders can no longer be deleted as they represent transactions in the real world.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderBooking

Returns a new instance of OrderBooking.



14426
14427
14428
14429
14430
14431
14432
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14426

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :order, :created_at], 'OrderBooking')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::OrderReference) ? x : ::Io::Flow::V0::Models::OrderReference.new(x))
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



14424
14425
14426
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14424

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



14424
14425
14426
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14424

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



14424
14425
14426
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14424

def order
  @order
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14438
14439
14440
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14438

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

#to_hashObject



14442
14443
14444
14445
14446
14447
14448
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14442

def to_hash
  {
    :id => id,
    :order => order.to_hash,
    :created_at => created_at
  }
end

#to_jsonObject



14434
14435
14436
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14434

def to_json
  JSON.dump(to_hash)
end