Class: FriendlyShipping::Services::TForceFreight::DocumentOptions
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::TForceFreight::DocumentOptions
- 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
-
#format ⇒ Symbol
readonly
The document format (see DOCUMENT_FORMATS).
-
#label_type ⇒ String
readonly
The type of label.
-
#number_of_stickers ⇒ Integer
readonly
The number of stickers.
-
#start_position ⇒ Integer
readonly
The start position of the sticker.
-
#thermal ⇒ Boolean
readonly
Whether or not the label is for thermal printers (DEPRECATED: use
label_type
instead). -
#type ⇒ Symbol
readonly
The document type (see DOCUMENT_TYPES).
Instance Method Summary collapse
- #document_type_code ⇒ String
- #format_code ⇒ String
-
#initialize(type: :label, format: :pdf, thermal: false, label_type: :thermal_labels_4x6, start_position: 1, number_of_stickers: 1) ⇒ DocumentOptions
constructor
A new instance of DocumentOptions.
- #label_type_code ⇒ String
-
#thermal_code ⇒ String
deprecated
Deprecated.
Use
label_type
instead.
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.
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
#format ⇒ Symbol (readonly)
Returns the document format (see DOCUMENT_FORMATS).
12 13 14 |
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 12 def format @format end |
#label_type ⇒ String (readonly)
Returns 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_stickers ⇒ Integer (readonly)
Returns 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_position ⇒ Integer (readonly)
Returns 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 |
#thermal ⇒ Boolean (readonly)
Returns 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 |
#type ⇒ Symbol (readonly)
Returns the document type (see DOCUMENT_TYPES).
9 10 11 |
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 9 def type @type end |
Instance Method Details
#document_type_code ⇒ 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_code ⇒ 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_code ⇒ 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_code ⇒ String
Use label_type
instead.
89 90 91 |
# File 'lib/friendly_shipping/services/tforce_freight/document_options.rb', line 89 def thermal_code THERMAL_CODE.fetch(thermal) end |