Class: SingtelSdp::ReturnCode
- Inherits:
-
Object
- Object
- SingtelSdp::ReturnCode
- Defined in:
- app/models/singtel_sdp/return_code.rb
Constant Summary collapse
- ORIGINS =
{ no_error: 0, target: 1, source: 2, customer_data: 3, select_method: 6 }
- ACTIONS =
{ general: 0, create: 2, update: 4, delete: 6, select: 0 }
- ENTITIES =
{ general: 0, other: 1, customer: 2, product: 4, user: 6, customer_for_select: 0 }
- CUSTOM_DIGIT =
{ general: 0, invalid_application: 1, invalid_product_name: 1, invalid_user_role: 1, invalid_environment: 3, invalid_adapterversion: 4, duplicated_subscription: 4, invalid_xml: 5, customer_not_found: 5, customer_not_found_for_select: 1, invalid_selectfrom_value: 2 }
- RETURN_MESSAGES =
{ 0 => 'Success', -1 => 'In Progress', 1000 => 'General Error', 1220 => 'Failed to Create Customer', 1240 => 'Failed to Create Product', 1260 => 'Failed to Create User', 1420 => 'Failed to Update Customer', 1440 => 'Failed to Update Product', 1460 => 'Failed to Update User', 1620 => 'Failed to Delete Customer', 1640 => 'Failed to Delete Product', 1660 => 'Failed to Delete User', 2000 => 'Invalid OTP', 2010 => 'Invalid Source Server', 2015 => 'Invalid Request XML', 2016 => 'Invalid Response XML', 2020 => 'Invalid UserID and Password', 2021 => 'Invalid application name', 2023 => 'Invalid environment', 2024 => 'Invalid adapter version', 2025 => 'Invalid CreateDatetime', 2026 => 'Duplicated requestno', 2040 => 'Invalid Entity type', 2041 => 'Invalid Action type', 2220 => 'Duplicated Customer', 2240 => 'Duplicated Subscription', 2241 => 'Invalid Product Name', 2242 => 'Invalid Trial Indicator', 2243 => 'Invalid Quantity', 2245 => 'Customer not found', 2260 => 'Duplicated User', 2261 => 'Invalid User Role', 2265 => 'Customer not found', 2266 => 'Subscription not found', 2420 => 'Customer Not found', 2440 => 'Subscription Not found', 2441 => 'Invalid Product Name', 2442 => 'Invalid Trial Indicator', 2443 => 'Invalid Quantity', 2444 => 'Duplicated Subscription', 2460 => 'User Not Found', 2461 => 'Invalid User Role', 2620 => 'Customer not found', 2640 => 'Subscription not found', 2645 => 'Customer not found', 2660 => 'User not found', 2665 => 'Customer not found', 2666 => 'Subscription not found', 3260 => 'Email cannot be null', 3261 => 'Invalid Email account', 3262 => 'Existing Email account detected', 3263 => 'Exceeded allowed number of total users license', 3264 => 'Exceeded allowed number of admin users license', 3460 => 'Invalid Email account', 3462 => 'Existing Email account', 6001 => 'Customer not found', 6002 => 'Invalid SELECTFROM value', }
Instance Method Summary collapse
- #action=(key) ⇒ Object
- #custom=(key) ⇒ Object
- #entity=(key) ⇒ Object
- #generate ⇒ Object
- #has_errors? ⇒ Boolean
-
#initialize ⇒ ReturnCode
constructor
A new instance of ReturnCode.
- #message ⇒ Object
- #origin=(key) ⇒ Object
Constructor Details
#initialize ⇒ ReturnCode
Returns a new instance of ReturnCode.
72 73 74 75 76 77 78 79 |
# File 'app/models/singtel_sdp/return_code.rb', line 72 def initialize # These are the four digits that will compose # the final returncode self.origin = :no_error self.action = :general self.entity = :general self.custom = :general end |
Instance Method Details
#action=(key) ⇒ Object
85 86 87 |
# File 'app/models/singtel_sdp/return_code.rb', line 85 def action=(key) @action = ACTIONS[key] end |
#custom=(key) ⇒ Object
93 94 95 |
# File 'app/models/singtel_sdp/return_code.rb', line 93 def custom=(key) @custom = CUSTOM_DIGIT[key] end |
#entity=(key) ⇒ Object
89 90 91 |
# File 'app/models/singtel_sdp/return_code.rb', line 89 def entity=(key) @entity = ENTITIES[key] end |
#generate ⇒ Object
97 98 99 100 |
# File 'app/models/singtel_sdp/return_code.rb', line 97 def generate return 0 unless has_errors? "#{@origin}#{@action}#{@entity}#{@custom}".to_i end |
#has_errors? ⇒ Boolean
106 107 108 109 110 111 112 |
# File 'app/models/singtel_sdp/return_code.rb', line 106 def has_errors? if @origin == ORIGINS[:select_method] @custom != 0 else @origin != 0 end end |
#message ⇒ Object
102 103 104 |
# File 'app/models/singtel_sdp/return_code.rb', line 102 def RETURN_MESSAGES[generate] end |
#origin=(key) ⇒ Object
81 82 83 |
# File 'app/models/singtel_sdp/return_code.rb', line 81 def origin=(key) @origin = ORIGINS[key] end |