Class: UspsApi::CreateOpenAndDistributeContainerMetadata

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/create_open_and_distribute_container_metadata.rb

Overview

Create OD Container Response

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(container_id: SKIP, tracking_number: SKIP, commitment: SKIP, facility_info: SKIP, construct_code: SKIP, retail_distribution_code: SKIP, postage: SKIP, fees: SKIP, extra_services: SKIP) ⇒ CreateOpenAndDistributeContainerMetadata

Returns a new instance of CreateOpenAndDistributeContainerMetadata.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 87

def initialize(container_id: SKIP, tracking_number: SKIP, commitment: SKIP,
               facility_info: SKIP, construct_code: SKIP,
               retail_distribution_code: SKIP, postage: SKIP, fees: SKIP,
               extra_services: SKIP)
  @container_id = container_id unless container_id == SKIP
  @tracking_number = tracking_number unless tracking_number == SKIP
  @commitment = commitment unless commitment == SKIP
  @facility_info = facility_info unless facility_info == SKIP
  @construct_code = construct_code unless construct_code == SKIP
  @retail_distribution_code = retail_distribution_code unless retail_distribution_code == SKIP
  @postage = postage unless postage == SKIP
  @fees = fees unless fees == SKIP
  @extra_services = extra_services unless extra_services == SKIP
end

Instance Attribute Details

#commitmentPmodCommitment

The commitment and scheduled delivery date of the package.

Returns:



22
23
24
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 22

def commitment
  @commitment
end

#construct_codeString

The barcode construct code associated with the tracking number

Returns:

  • (String)


31
32
33
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 31

def construct_code
  @construct_code
end

#container_idString

The 99M IMcb number for the created container.

Returns:

  • (String)


14
15
16
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 14

def container_id
  @container_id
end

#extra_servicesArray[LabelsExtraServiceResponse]

Amount of postage required, does not include insurance or other extra service fees

Returns:



50
51
52
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 50

def extra_services
  @extra_services
end

#facility_infoFacilityInfo

Address of the destination entry facility the container will be brought to.

Returns:



27
28
29
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 27

def facility_info
  @facility_info
end

#feesArray[Fee2]

Amount of postage required, does not include insurance or other extra service fees

Returns:



45
46
47
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 45

def fees
  @fees
end

#postageFloat

Amount of postage required, does not include insurance or other extra service fees

Returns:

  • (Float)


40
41
42
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 40

def postage
  @postage
end

#retail_distribution_codeString

Retail Description Code associated with label

Returns:

  • (String)


35
36
37
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 35

def retail_distribution_code
  @retail_distribution_code
end

#tracking_numberString

The IMpb tracking number associated with the container.

Returns:

  • (String)


18
19
20
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 18

def tracking_number
  @tracking_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 103

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  container_id = hash.key?('containerID') ? hash['containerID'] : SKIP
  tracking_number =
    hash.key?('trackingNumber') ? hash['trackingNumber'] : SKIP
  commitment = PmodCommitment.from_hash(hash['commitment']) if hash['commitment']
  facility_info = FacilityInfo.from_hash(hash['facilityInfo']) if hash['facilityInfo']
  construct_code = hash.key?('constructCode') ? hash['constructCode'] : SKIP
  retail_distribution_code =
    hash.key?('retailDistributionCode') ? hash['retailDistributionCode'] : SKIP
  postage = hash.key?('postage') ? hash['postage'] : SKIP
  # Parameter is an array, so we need to iterate through it
  fees = nil
  unless hash['fees'].nil?
    fees = []
    hash['fees'].each do |structure|
      fees << (Fee2.from_hash(structure) if structure)
    end
  end

  fees = SKIP unless hash.key?('fees')
  # Parameter is an array, so we need to iterate through it
  extra_services = nil
  unless hash['extraServices'].nil?
    extra_services = []
    hash['extraServices'].each do |structure|
      extra_services << (LabelsExtraServiceResponse.from_hash(structure) if structure)
    end
  end

  extra_services = SKIP unless hash.key?('extraServices')

  # Create object from extracted values.
  CreateOpenAndDistributeContainerMetadata.new(container_id: container_id,
                                               tracking_number: tracking_number,
                                               commitment: commitment,
                                               facility_info: facility_info,
                                               construct_code: construct_code,
                                               retail_distribution_code: retail_distribution_code,
                                               postage: postage,
                                               fees: fees,
                                               extra_services: extra_services)
end

.namesObject

A mapping from model property names to API property names.



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 53

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['container_id'] = 'containerID'
  @_hash['tracking_number'] = 'trackingNumber'
  @_hash['commitment'] = 'commitment'
  @_hash['facility_info'] = 'facilityInfo'
  @_hash['construct_code'] = 'constructCode'
  @_hash['retail_distribution_code'] = 'retailDistributionCode'
  @_hash['postage'] = 'postage'
  @_hash['fees'] = 'fees'
  @_hash['extra_services'] = 'extraServices'
  @_hash
end

.nullablesObject

An array for nullable fields



83
84
85
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 83

def self.nullables
  []
end

.optionalsObject

An array for optional fields



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 68

def self.optionals
  %w[
    container_id
    tracking_number
    commitment
    facility_info
    construct_code
    retail_distribution_code
    postage
    fees
    extra_services
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



159
160
161
162
163
164
165
166
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 159

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} container_id: #{@container_id.inspect}, tracking_number:"\
  " #{@tracking_number.inspect}, commitment: #{@commitment.inspect}, facility_info:"\
  " #{@facility_info.inspect}, construct_code: #{@construct_code.inspect},"\
  " retail_distribution_code: #{@retail_distribution_code.inspect}, postage:"\
  " #{@postage.inspect}, fees: #{@fees.inspect}, extra_services: #{@extra_services.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



150
151
152
153
154
155
156
# File 'lib/usps_api/models/create_open_and_distribute_container_metadata.rb', line 150

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} container_id: #{@container_id}, tracking_number: #{@tracking_number},"\
  " commitment: #{@commitment}, facility_info: #{@facility_info}, construct_code:"\
  " #{@construct_code}, retail_distribution_code: #{@retail_distribution_code}, postage:"\
  " #{@postage}, fees: #{@fees}, extra_services: #{@extra_services}>"
end