class Posthorn::Label

Attributes

price[RW]
product_id[RW]
receiver[RW]
sender[RW]

Public Class Methods

new(sender, receiver, args = {}) click to toggle source
# File lib/posthorn/label.rb, line 5
def initialize(sender, receiver, args = {})
  @sender = sender
  @receiver = receiver
  @product_id = args[:product_id] || 11 # Kompaktbrief
  @price = args[:price] || 0
end

Public Instance Methods

to_h(args = {}) click to toggle source
# File lib/posthorn/label.rb, line 12
def to_h(args = {})
  rtn = {
    productCode: @product_id,
    address: {
      sender: @sender.to_h,
      receiver: @receiver.to_h
    },
    voucherLayout: 'AddressZone',
    position: {
      labelX: 1,
      labelY: 1,
      page: (args[:page] || 0) + 1
    }
  }

  rtn
end