Sha256: c658295aab320ac718e7f9232a6ced493119d29aa20d3816e45bacb7a5ef50e6

Contents?: true

Size: 713 Bytes

Versions: 3

Compression:

Stored size: 713 Bytes

Contents

class Smartsend::Parcel
  attr_accessor :id, :tracking_code, :tracking_url, :shipped_at, :reference, :weight, :height, :width, :length, :size, :freetext_lines, :items

  def initialize(args={})
    args.each do |k, v|
      instance_variable_set "@#{k}", v
    end

    @items ||= []
  end

  def serialize
    params = {
      :shipdate  => @shipped_at,
      :reference => @reference,
      :weight    => @weight,
      :height    => @height,
      :width     => @width,
      :length    => @length,
      :size      => @size,
      :items     => @items.map(&:serialize)
    }

    freetext_lines.to_a.each_with_index do |line, i|
      params["freetext#{i.next}".to_sym] = line
    end

    params

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smartsend-ruby-0.1.1 lib/smartsend/parcel.rb
smartsend-ruby-0.1.0 lib/smartsend/parcel.rb
smartsend-ruby-0.0.3 lib/smartsend/parcel.rb