Class: UspsApi::InternationalPackageResponse

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

Overview

Response containing the international label metadata and Base64-encoded label image for multipart responses.

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(label_metadata: SKIP, label_image: SKIP, label_broker_qr: SKIP, prepaid_duties_taxes_fees: SKIP) ⇒ InternationalPackageResponse

Returns a new instance of InternationalPackageResponse.



58
59
60
61
62
63
64
65
66
67
# File 'lib/usps_api/models/international_package_response.rb', line 58

def initialize(label_metadata: SKIP, label_image: SKIP,
               label_broker_qr: SKIP, prepaid_duties_taxes_fees: SKIP)
  @label_metadata =  unless  == SKIP
  @label_image = label_image unless label_image == SKIP
  @label_broker_qr = label_broker_qr unless label_broker_qr == SKIP
  unless prepaid_duties_taxes_fees == SKIP
    @prepaid_duties_taxes_fees =
      prepaid_duties_taxes_fees
  end
end

Instance Attribute Details

#label_broker_qrString

The Label Broker QR Code image, Base64 encoded file contents. Only provided if ‘imageType` in the `imageInfo` is set to `LABEL_BROKER`.

Returns:

  • (String)


26
27
28
# File 'lib/usps_api/models/international_package_response.rb', line 26

def label_broker_qr
  @label_broker_qr
end

#label_imageString

Contains the Base64-encoded file contents of the label image. Provided only when ‘imageInfo.imageType` is not `NONE`.

Returns:

  • (String)


21
22
23
# File 'lib/usps_api/models/international_package_response.rb', line 21

def label_image
  @label_image
end

#label_metadataInternationalLabelMetadataResponse

Metadata information for an international label including tracking number, pricing details, postage, and extra services.



16
17
18
# File 'lib/usps_api/models/international_package_response.rb', line 16

def 
  @label_metadata
end

#prepaid_duties_taxes_feesPrepaidDutiesTaxesFees

The total landed cost package and item details. Included if ‘prepayDutiesTaxesFees` is `true`.



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

def prepaid_duties_taxes_fees
  @prepaid_duties_taxes_fees
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/usps_api/models/international_package_response.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = InternationalLabelMetadataResponse.from_hash(hash['labelMetadata']) if
    hash['labelMetadata']
  label_image = hash.key?('labelImage') ? hash['labelImage'] : SKIP
  label_broker_qr =
    hash.key?('labelBrokerQR') ? hash['labelBrokerQR'] : SKIP
  if hash['prepaidDutiesTaxesFees']
    prepaid_duties_taxes_fees = PrepaidDutiesTaxesFees.from_hash(hash['prepaidDutiesTaxesFees'])
  end

  # Create object from extracted values.
  InternationalPackageResponse.new(label_metadata: ,
                                   label_image: label_image,
                                   label_broker_qr: label_broker_qr,
                                   prepaid_duties_taxes_fees: prepaid_duties_taxes_fees)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
# File 'lib/usps_api/models/international_package_response.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['label_metadata'] = 'labelMetadata'
  @_hash['label_image'] = 'labelImage'
  @_hash['label_broker_qr'] = 'labelBrokerQR'
  @_hash['prepaid_duties_taxes_fees'] = 'prepaidDutiesTaxesFees'
  @_hash
end

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/usps_api/models/international_package_response.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
47
48
49
50
51
# File 'lib/usps_api/models/international_package_response.rb', line 44

def self.optionals
  %w[
    label_metadata
    label_image
    label_broker_qr
    prepaid_duties_taxes_fees
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



99
100
101
102
103
104
# File 'lib/usps_api/models/international_package_response.rb', line 99

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} label_metadata: #{@label_metadata.inspect}, label_image:"\
  " #{@label_image.inspect}, label_broker_qr: #{@label_broker_qr.inspect},"\
  " prepaid_duties_taxes_fees: #{@prepaid_duties_taxes_fees.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



91
92
93
94
95
96
# File 'lib/usps_api/models/international_package_response.rb', line 91

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} label_metadata: #{@label_metadata}, label_image: #{@label_image},"\
  " label_broker_qr: #{@label_broker_qr}, prepaid_duties_taxes_fees:"\
  " #{@prepaid_duties_taxes_fees}>"
end