Class: LoyaltyApIs::CommonErrorException
- Inherits:
-
APIException
- Object
- CoreLibrary::ApiException
- APIException
- LoyaltyApIs::CommonErrorException
- Defined in:
- lib/loyalty_ap_is/exceptions/common_error_exception.rb
Overview
Common Error class.
Instance Attribute Summary collapse
-
#error ⇒ ErrorBaseContainer
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. -
#error_code ⇒ Float
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.
Instance Method Summary collapse
-
#initialize(reason, response) ⇒ CommonErrorException
constructor
The constructor.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
-
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash.
Constructor Details
#initialize(reason, response) ⇒ CommonErrorException
The constructor.
68 69 70 71 72 |
# File 'lib/loyalty_ap_is/exceptions/common_error_exception.rb', line 68 def initialize(reason, response) super(reason, response) hash = APIHelper.json_deserialize(@response.raw_body) unbox(hash) end |
Instance Attribute Details
#error ⇒ ErrorBaseContainer
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
63 64 65 |
# File 'lib/loyalty_ap_is/exceptions/common_error_exception.rb', line 63 def error @error end |
#error_code ⇒ Float
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/exceptions/common_error_exception.rb', line 17 def error_code @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/exceptions/common_error_exception.rb', line 40 def @message end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
92 93 94 95 96 |
# File 'lib/loyalty_ap_is/exceptions/common_error_exception.rb', line 92 def inspect class_name = self.class.name.split('::').last "<#{class_name} error_code: #{@error_code.inspect}, message: #{@message.inspect}, error:"\ " #{@error.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
86 87 88 89 |
# File 'lib/loyalty_ap_is/exceptions/common_error_exception.rb', line 86 def to_s class_name = self.class.name.split('::').last "<#{class_name} error_code: #{@error_code}, message: #{@message}, error: #{@error}>" end |
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash. response body.
77 78 79 80 81 82 83 |
# File 'lib/loyalty_ap_is/exceptions/common_error_exception.rb', line 77 def unbox(hash) return nil unless hash @error_code = hash.key?('errorCode') ? hash['errorCode'] : nil @message = hash.key?('message') ? hash['message'] : nil @error = ErrorBaseContainer.from_hash(hash['error']) if hash['error'] end |