Class: WalmartApIs::RegulatedInfo
- Defined in:
- lib/walmart_ap_is/models/regulated_info.rb
Overview
Verification requirements for an order containing regulated items. Mirrors
Amazon SP-API Orders v0 RegulatedInformation plus a regulatedCategory
discriminator so a caller can short- circuit when the order is not regulated
at all.
Instance Attribute Summary collapse
-
#buyer_date_of_birth_required ⇒ TrueClass | FalseClass
True when the buyer's date of birth must be captured / cross-checked.
-
#regulated_category ⇒ RegulatedCategory
Top-level category of regulation that applies.
-
#required_age_minimum ⇒ Integer
Minimum buyer age in years (e.g. 21 for alcohol in the US).
-
#required_verification_method ⇒ RequiredVerificationMethod
How the buyer must prove identity at delivery.
-
#signature_required ⇒ TrueClass | FalseClass
True when the carrier must capture a signature on delivery.
-
#value_added_services ⇒ Array[ValueAddedService]
Any value-added services attached to the order that are relevant to the regulated workflow (e.g. signed-delivery, adult-signature).
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(regulated_category:, required_verification_method:, required_age_minimum: SKIP, signature_required: SKIP, buyer_date_of_birth_required: SKIP, value_added_services: SKIP, additional_properties: nil) ⇒ RegulatedInfo
constructor
A new instance of RegulatedInfo.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(regulated_category:, required_verification_method:, required_age_minimum: SKIP, signature_required: SKIP, buyer_date_of_birth_required: SKIP, value_added_services: SKIP, additional_properties: nil) ⇒ RegulatedInfo
Returns a new instance of RegulatedInfo.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 72 def initialize(regulated_category:, required_verification_method:, required_age_minimum: SKIP, signature_required: SKIP, buyer_date_of_birth_required: SKIP, value_added_services: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @regulated_category = regulated_category @required_verification_method = required_verification_method @required_age_minimum = required_age_minimum unless required_age_minimum == SKIP @signature_required = signature_required unless signature_required == SKIP unless buyer_date_of_birth_required == SKIP @buyer_date_of_birth_required = buyer_date_of_birth_required end @value_added_services = value_added_services unless value_added_services == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#buyer_date_of_birth_required ⇒ TrueClass | FalseClass
True when the buyer's date of birth must be captured / cross-checked.
37 38 39 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 37 def buyer_date_of_birth_required @buyer_date_of_birth_required end |
#regulated_category ⇒ RegulatedCategory
Top-level category of regulation that applies. NOT_REGULATED means no verification is required and the rest of the fields are informational only.
19 20 21 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 19 def regulated_category @regulated_category end |
#required_age_minimum ⇒ Integer
Minimum buyer age in years (e.g. 21 for alcohol in the US).
29 30 31 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 29 def required_age_minimum @required_age_minimum end |
#required_verification_method ⇒ RequiredVerificationMethod
How the buyer must prove identity at delivery. NONE means no verification is required (NOT_REGULATED orders always return NONE).
25 26 27 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 25 def required_verification_method @required_verification_method end |
#signature_required ⇒ TrueClass | FalseClass
True when the carrier must capture a signature on delivery.
33 34 35 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 33 def signature_required @signature_required end |
#value_added_services ⇒ Array[ValueAddedService]
Any value-added services attached to the order that are relevant to the regulated workflow (e.g. signed-delivery, adult-signature). Empty when none apply.
43 44 45 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 43 def value_added_services @value_added_services end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
92 93 94 95 96 97 98 99 100 101 102 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 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 92 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. regulated_category = hash.key?('regulatedCategory') ? hash['regulatedCategory'] : nil required_verification_method = hash.key?('requiredVerificationMethod') ? hash['requiredVerificationMethod'] : nil required_age_minimum = hash.key?('requiredAgeMinimum') ? hash['requiredAgeMinimum'] : SKIP signature_required = hash.key?('signatureRequired') ? hash['signatureRequired'] : SKIP buyer_date_of_birth_required = hash.key?('buyerDateOfBirthRequired') ? hash['buyerDateOfBirthRequired'] : SKIP # Parameter is an array, so we need to iterate through it value_added_services = nil unless hash['valueAddedServices'].nil? value_added_services = [] hash['valueAddedServices'].each do |structure| value_added_services << (ValueAddedService.from_hash(structure) if structure) end end value_added_services = SKIP unless hash.key?('valueAddedServices') # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. RegulatedInfo.new(regulated_category: regulated_category, required_verification_method: required_verification_method, required_age_minimum: required_age_minimum, signature_required: signature_required, buyer_date_of_birth_required: buyer_date_of_birth_required, value_added_services: value_added_services, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 46 def self.names @_hash = {} if @_hash.nil? @_hash['regulated_category'] = 'regulatedCategory' @_hash['required_verification_method'] = 'requiredVerificationMethod' @_hash['required_age_minimum'] = 'requiredAgeMinimum' @_hash['signature_required'] = 'signatureRequired' @_hash['buyer_date_of_birth_required'] = 'buyerDateOfBirthRequired' @_hash['value_added_services'] = 'valueAddedServices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
68 69 70 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 68 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
58 59 60 61 62 63 64 65 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 58 def self.optionals %w[ required_age_minimum signature_required buyer_date_of_birth_required value_added_services ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
145 146 147 148 149 150 151 152 153 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 145 def inspect class_name = self.class.name.split('::').last "<#{class_name} regulated_category: #{@regulated_category.inspect},"\ " required_verification_method: #{@required_verification_method.inspect},"\ " required_age_minimum: #{@required_age_minimum.inspect}, signature_required:"\ " #{@signature_required.inspect}, buyer_date_of_birth_required:"\ " #{@buyer_date_of_birth_required.inspect}, value_added_services:"\ " #{@value_added_services.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
135 136 137 138 139 140 141 142 |
# File 'lib/walmart_ap_is/models/regulated_info.rb', line 135 def to_s class_name = self.class.name.split('::').last "<#{class_name} regulated_category: #{@regulated_category}, required_verification_method:"\ " #{@required_verification_method}, required_age_minimum: #{@required_age_minimum},"\ " signature_required: #{@signature_required}, buyer_date_of_birth_required:"\ " #{@buyer_date_of_birth_required}, value_added_services: #{@value_added_services},"\ " additional_properties: #{@additional_properties}>" end |