Class: LoyaltyApIs::ErrorPresenter
- Defined in:
- lib/loyalty_ap_is/models/error_presenter.rb
Overview
ErrorPresenter Model.
Instance Attribute Summary collapse
-
#app_error_code ⇒ String
custom error code for developer or user Note: One of the following values will be returned: 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1009, 1010, 1011, 1012, 1014, 1015, 1016.
-
#message ⇒ String
Custom error message
Note: One of the following values will be returned: - Offer does not exist - Customer does not exist - Valid from date is invalid - ValidityPeriod is invalid - Offer is by default assigned to all customers, which cannot be changed. -
#reason ⇒ String
reason for the error.
-
#subject ⇒ String
subject of the error.
-
#subject_type ⇒ String
subject type of the error.
-
#type ⇒ String
Type of error.
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(app_error_code:, message:, reason: SKIP, subject: SKIP, subject_type: SKIP, type: SKIP, additional_properties: nil) ⇒ ErrorPresenter
constructor
A new instance of ErrorPresenter.
-
#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(app_error_code:, message:, reason: SKIP, subject: SKIP, subject_type: SKIP, type: SKIP, additional_properties: nil) ⇒ ErrorPresenter
Returns a new instance of ErrorPresenter.
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 90 def initialize(app_error_code:, message:, reason: SKIP, subject: SKIP, subject_type: SKIP, type: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @app_error_code = app_error_code @message = @reason = reason unless reason == SKIP @subject = subject unless subject == SKIP @subject_type = subject_type unless subject_type == SKIP @type = type unless type == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#app_error_code ⇒ String
custom error code for developer or user Note: One of the following values will be returned: 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1009, 1010, 1011, 1012, 1014, 1015, 1016
17 18 19 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 17 def app_error_code @app_error_code end |
#message ⇒ String
Custom error message
Note: One of the following values will be returned:
- Offer does not exist
- Customer does not exist
- Valid from date is invalid
- ValidityPeriod is invalid
- Offer is by default assigned to all customers, which cannot be
changed.
- Assignment is not allowed
- Customer assign should have validity dates.
- Customer assign validity start date should be before the validity end date.
- Customer assign validity dates must be between the offer assignable dates.
- Offer validity start date should not be in the past.
- Customer already assigned to this offer.
- Offer module is disabled
- Partner code is not valid for this offer
- Reference ID already used
- Partner assignment already ended for this customer
40 41 42 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 40 def @message end |
#reason ⇒ String
reason for the error
44 45 46 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 44 def reason @reason end |
#subject ⇒ String
subject of the error. Examples will be shared later
48 49 50 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 48 def subject @subject end |
#subject_type ⇒ String
subject type of the error. Examples will be shared later.
52 53 54 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 52 def subject_type @subject_type end |
#type ⇒ String
Type of error. Examples will be shared later.
56 57 58 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 56 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 105 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. app_error_code = hash.key?('appErrorCode') ? hash['appErrorCode'] : nil = hash.key?('message') ? hash['message'] : nil reason = hash.key?('reason') ? hash['reason'] : SKIP subject = hash.key?('subject') ? hash['subject'] : SKIP subject_type = hash.key?('subjectType') ? hash['subjectType'] : SKIP type = hash.key?('type') ? hash['type'] : SKIP # 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. ErrorPresenter.new(app_error_code: app_error_code, message: , reason: reason, subject: subject, subject_type: subject_type, type: type, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 59 def self.names @_hash = {} if @_hash.nil? @_hash['app_error_code'] = 'appErrorCode' @_hash['message'] = 'message' @_hash['reason'] = 'reason' @_hash['subject'] = 'subject' @_hash['subject_type'] = 'subjectType' @_hash['type'] = 'type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
81 82 83 84 85 86 87 88 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 81 def self.nullables %w[ reason subject subject_type type ] end |
.optionals ⇒ Object
An array for optional fields
71 72 73 74 75 76 77 78 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 71 def self.optionals %w[ reason subject subject_type type ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
142 143 144 145 146 147 148 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 142 def inspect class_name = self.class.name.split('::').last "<#{class_name} app_error_code: #{@app_error_code.inspect}, message: #{@message.inspect},"\ " reason: #{@reason.inspect}, subject: #{@subject.inspect}, subject_type:"\ " #{@subject_type.inspect}, type: #{@type.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
134 135 136 137 138 139 |
# File 'lib/loyalty_ap_is/models/error_presenter.rb', line 134 def to_s class_name = self.class.name.split('::').last "<#{class_name} app_error_code: #{@app_error_code}, message: #{@message}, reason:"\ " #{@reason}, subject: #{@subject}, subject_type: #{@subject_type}, type: #{@type},"\ " additional_properties: #{@additional_properties}>" end |