Class: Io::Flow::V0::Models::TrackingEvent

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TrackingEvent

Returns a new instance of TrackingEvent.



33442
33443
33444
33445
33446
33447
33448
33449
33450
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33442

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :address, :status, :timestamp], 'TrackingEvent')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @address = (x = opts.delete(:address); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::TrackingStatus) ? x : ::Io::Flow::V0::Models::TrackingStatus.apply(x))
  @timestamp = HttpClient::Preconditions.assert_class('timestamp', HttpClient::Helper.to_date_time_iso8601(opts.delete(:timestamp)), DateTime)
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



33440
33441
33442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33440

def address
  @address
end

#descriptionObject (readonly)

Returns the value of attribute description.



33440
33441
33442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33440

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



33440
33441
33442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33440

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



33440
33441
33442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33440

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



33440
33441
33442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33440

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



33456
33457
33458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33456

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

#to_hashObject



33460
33461
33462
33463
33464
33465
33466
33467
33468
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33460

def to_hash
  {
    :id => id,
    :address => address.to_hash,
    :status => status.value,
    :timestamp => timestamp,
    :description => description
  }
end

#to_jsonObject



33452
33453
33454
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33452

def to_json
  JSON.dump(to_hash)
end