Class: UspsApi::InternationalLabelsExtraServiceResponse

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

Overview

InternationalLabelsExtraServiceResponse Model.

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(service_id: SKIP, service_name: SKIP, sku: SKIP, price: SKIP, warnings: SKIP) ⇒ InternationalLabelsExtraServiceResponse

Returns a new instance of InternationalLabelsExtraServiceResponse.



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

def initialize(service_id: SKIP, service_name: SKIP, sku: SKIP, price: SKIP,
               warnings: SKIP)
  @service_id = service_id unless service_id == SKIP
  @service_name = service_name unless service_name == SKIP
  @sku = sku unless sku == SKIP
  @price = price unless price == SKIP
  @warnings = warnings unless warnings == SKIP
end

Instance Attribute Details

#priceFloat

The price for the extra service.

Returns:

  • (Float)


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

def price
  @price
end

#service_idString

The unique identifier of the extra service.

Returns:

  • (String)


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

def service_id
  @service_id
end

#service_nameString

Name of the extra service.

Returns:

  • (String)


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

def service_name
  @service_name
end

#skuString

SKU of the extra service.

Returns:

  • (String)


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

def sku
  @sku
end

#warningsArray[Warning]

Warnings and additional details around the Extra Services.

Returns:



30
31
32
# File 'lib/usps_api/models/international_labels_extra_service_response.rb', line 30

def warnings
  @warnings
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/usps_api/models/international_labels_extra_service_response.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  service_id = hash.key?('serviceID') ? hash['serviceID'] : SKIP
  service_name = hash.key?('serviceName') ? hash['serviceName'] : SKIP
  sku = hash.key?('sku') ? hash['sku'] : SKIP
  price = hash.key?('price') ? hash['price'] : SKIP
  # Parameter is an array, so we need to iterate through it
  warnings = nil
  unless hash['warnings'].nil?
    warnings = []
    hash['warnings'].each do |structure|
      warnings << (Warning.from_hash(structure) if structure)
    end
  end

  warnings = SKIP unless hash.key?('warnings')

  # Create object from extracted values.
  InternationalLabelsExtraServiceResponse.new(service_id: service_id,
                                              service_name: service_name,
                                              sku: sku,
                                              price: price,
                                              warnings: warnings)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['service_id'] = 'serviceID'
  @_hash['service_name'] = 'serviceName'
  @_hash['sku'] = 'sku'
  @_hash['price'] = 'price'
  @_hash['warnings'] = 'warnings'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/usps_api/models/international_labels_extra_service_response.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    service_id
    service_name
    sku
    price
    warnings
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



104
105
106
107
108
# File 'lib/usps_api/models/international_labels_extra_service_response.rb', line 104

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} service_id: #{@service_id.inspect}, service_name: #{@service_name.inspect},"\
  " sku: #{@sku.inspect}, price: #{@price.inspect}, warnings: #{@warnings.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



97
98
99
100
101
# File 'lib/usps_api/models/international_labels_extra_service_response.rb', line 97

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} service_id: #{@service_id}, service_name: #{@service_name}, sku: #{@sku},"\
  " price: #{@price}, warnings: #{@warnings}>"
end