Class: FriendlyShipping::Services::TForceFreight::DocumentOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/services/tforce_freight/document_options.rb

Overview

Options for getting documents (BOLs, labels, etc.) from the API.

Constant Summary collapse

DOCUMENT_TYPES =

Maps friendly names to document types.

{
  label: "30",
  tforce_bol: "20",
  vics_bol: "21"
}.freeze
DOCUMENT_FORMATS =

Maps friendly names to document formats.

{
  pdf: "01"
}.freeze
THERMAL_CODE =

Maps booleans to thermal codes.

{
  false => "01",
  true => "02"
}.freeze
LABEL_TYPE_CODES =

Maps friendly names to label types.

{
  address_labels_with_pro_nums: "01",
  address_labels_without_pro_nums: "02",
  pro_stickers: "03",
  address_labels_1x1: "04",
  address_labels_2x1: "05",
  address_labels_2x2: "06",
  thermal_labels_4x6: "07",
  thermal_labels_4x8: "08"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: :label, format: :pdf, thermal: false, label_type: :thermal_labels_4x6, start_position: 1, number_of_stickers: 1) ⇒ DocumentOptions

Returns a new instance of DocumentOptions.

Parameters:

  • type (Symbol) (defaults to: :label)

    the document type (see [DOCUMENT_TYPES])

  • format (Symbol) (defaults to: :pdf)

    the document format (see [DOCUMENT_FORMATS])

  • thermal (Boolean) (defaults to: false)

    whether or not the label is for thermal printers (DEPRECATED: use label_type instead)

  • start_position (Integer) (defaults to: 1)

    the start position of the sticker

  • number_of_stickers (Integer) (defaults to: 1)

    the number of stickers



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 61

def initialize(
  type: :label,
  format: :pdf,
  thermal: false,
  label_type: :thermal_labels_4x6,
  start_position: 1,
  number_of_stickers: 1
)
  @type = type
  @format = format
  @thermal = thermal
  @label_type = label_type
  @start_position = start_position
  @number_of_stickers = number_of_stickers
end

Instance Attribute Details

#formatSymbol (readonly)

Returns the document format (see DOCUMENT_FORMATS).

Returns:



12
13
14
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 12

def format
  @format
end

#label_typeString (readonly)

Returns the type of label.

Returns:

  • (String)

    the type of label



18
19
20
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 18

def label_type
  @label_type
end

#number_of_stickersInteger (readonly)

Returns the number of stickers.

Returns:

  • (Integer)

    the number of stickers



24
25
26
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 24

def number_of_stickers
  @number_of_stickers
end

#start_positionInteger (readonly)

Returns the start position of the sticker.

Returns:

  • (Integer)

    the start position of the sticker



21
22
23
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 21

def start_position
  @start_position
end

#thermalBoolean (readonly)

Returns whether or not the label is for thermal printers (DEPRECATED: use label_type instead).

Returns:

  • (Boolean)

    whether or not the label is for thermal printers (DEPRECATED: use label_type instead)



15
16
17
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 15

def thermal
  @thermal
end

#typeSymbol (readonly)

Returns the document type (see DOCUMENT_TYPES).

Returns:



9
10
11
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 9

def type
  @type
end

Instance Method Details

#document_type_codeString

Returns:

  • (String)


83
84
85
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 83

def document_type_code
  DOCUMENT_TYPES.fetch(type)
end

#format_codeString

Returns:

  • (String)


78
79
80
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 78

def format_code
  DOCUMENT_FORMATS.fetch(format)
end

#label_type_codeString

Returns:

  • (String)


94
95
96
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 94

def label_type_code
  LABEL_TYPE_CODES.fetch(label_type)
end

#thermal_codeString

Deprecated.

Use label_type instead.

Returns:

  • (String)


89
90
91
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 89

def thermal_code
  THERMAL_CODE.fetch(thermal)
end