Class: OrangeData::ReceiptContent::Position

Inherits:
PayloadContent show all
Defined in:
lib/orange_data/receipt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PayloadContent

#==, #assign_attributes, #to_json

Constructor Details

#initialize(payload = {}) ⇒ Position

Returns a new instance of Position.



101
102
103
104
105
# File 'lib/orange_data/receipt.rb', line 101

def initialize(payload={})
  @payload = payload
  @supplier_info = SupplierInfo.new(@payload['supplierInfo']) if @payload['supplierInfo']
  @agent_info = AgentInfo.new(@payload['agentInfo']) if @payload['agentInfo']
end

Instance Attribute Details

#agent_infoObject (readonly)

Returns the value of attribute agent_info.



124
125
126
# File 'lib/orange_data/receipt.rb', line 124

def agent_info
  @agent_info
end

#supplier_infoObject (readonly)

Returns the value of attribute supplier_info.



124
125
126
# File 'lib/orange_data/receipt.rb', line 124

def supplier_info
  @supplier_info
end

Instance Method Details

#set_agent_info(**options) ⇒ Object



119
120
121
122
# File 'lib/orange_data/receipt.rb', line 119

def set_agent_info(**options)
  @agent_info = AgentInfo.new.assign_attributes(options)
  self
end

#set_supplier_info(**options) ⇒ Object



114
115
116
117
# File 'lib/orange_data/receipt.rb', line 114

def set_supplier_info(**options)
  @supplier_info = SupplierInfo.new.assign_attributes(options)
  self
end

#to_hashObject



107
108
109
110
111
112
# File 'lib/orange_data/receipt.rb', line 107

def to_hash
  @payload.dup.tap{|h|
    h["supplierInfo"] = supplier_info.to_hash if supplier_info
    h["agentInfo"] = agent_info.to_hash if agent_info
  }
end