class OrangeData::ReceiptContent
Attributes
additional_user_attribute[R]
check_close[R]
positions[R]
Public Class Methods
new(payload={})
click to toggle source
# File lib/orange_data/receipt.rb, line 70 def initialize(payload={}) @payload = payload || {} # TODO: import... # TODO: taxationSystem default in checkclose @check_close = CheckClose.new(@payload['checkClose']) if @payload["additionalUserAttribute"] @additional_user_attribute = AdditionalUserAttribute.new(@payload["additionalUserAttribute"]) end @positions = (@payload['positions'] || []).map{|pos| Position.new(pos) } end
Public Instance Methods
add_payment(amount=nil, type=nil, **options) { |payment| ... }
click to toggle source
# File lib/orange_data/receipt.rb, line 104 def add_payment(amount=nil, type=nil, **options) payment = Payment.new payment.type = type if type payment.amount = amount if amount payment.assign_attributes(options) yield(payment) if block_given? check_close.payments << payment self end
add_position(text=nil, **options) { |pos| ... }
click to toggle source
# File lib/orange_data/receipt.rb, line 95 def add_position(text=nil, **options) pos = Position.new pos.text = text if text pos.assign_attributes(options) yield(pos) if block_given? positions << pos self end
raw_type()
click to toggle source
сырой тип используется в qr_code
# File lib/orange_data/receipt.rb, line 83 def raw_type @payload["type"] end
set_additional_user_attribute(**options)
click to toggle source
# File lib/orange_data/receipt.rb, line 114 def set_additional_user_attribute(**options) @additional_user_attribute = AdditionalUserAttribute.new.assign_attributes(options) end
set_agent_info(**options)
click to toggle source
# File lib/orange_data/receipt.rb, line 118 def set_agent_info(**options) # agent info may have some validations/transformations, so agent_info = AgentInfo.new.assign_attributes(options) assign_attributes(agent_info.attributes.reject{|_k, v| v.nil? }) end
to_hash()
click to toggle source
# File lib/orange_data/receipt.rb, line 87 def to_hash @payload.dup.tap{|h| h["positions"] = @positions.map(&:to_hash) h["checkClose"] = check_close.to_hash if check_close h["additionalUserAttribute"] = additional_user_attribute.to_hash if additional_user_attribute } end