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.



40788
40789
40790
40791
40792
40793
40794
40795
40796
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40788

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.



40786
40787
40788
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40786

def address
  @address
end

#descriptionObject (readonly)

Returns the value of attribute description.



40786
40787
40788
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40786

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



40786
40787
40788
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40786

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



40786
40787
40788
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40786

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



40786
40787
40788
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40786

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40802
40803
40804
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40802

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

#to_hashObject



40806
40807
40808
40809
40810
40811
40812
40813
40814
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40806

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

#to_jsonObject



40798
40799
40800
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40798

def to_json
  JSON.dump(to_hash)
end