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

#==, #as_json, #assign_attributes, #attributes, #to_json

Constructor Details

#initialize(payload = {}) ⇒ Position

Returns a new instance of Position.



125
126
127
128
129
# File 'lib/orange_data/receipt.rb', line 125

def initialize(payload={})
  super(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.



148
149
150
# File 'lib/orange_data/receipt.rb', line 148

def agent_info
  @agent_info
end

#supplier_infoObject (readonly)

Returns the value of attribute supplier_info.



148
149
150
# File 'lib/orange_data/receipt.rb', line 148

def supplier_info
  @supplier_info
end

Instance Method Details

#set_agent_info(**options) ⇒ Object



143
144
145
146
# File 'lib/orange_data/receipt.rb', line 143

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

#set_supplier_info(**options) ⇒ Object



138
139
140
141
# File 'lib/orange_data/receipt.rb', line 138

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

#to_hashObject



131
132
133
134
135
136
# File 'lib/orange_data/receipt.rb', line 131

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