Module: OstKycSdkRuby::Util::ServicesHelper
- Included in:
- Saas::Base
- Defined in:
- lib/ost-kyc-sdk-ruby/util/services_helper.rb
Instance Method Summary collapse
-
#error_with_data(code, msg, data = {}) ⇒ Object
Error with data.
-
#exception_with_data(e, code, msg, data = {}) ⇒ Object
Exception with data and without action.
-
#perform_and_handle_exceptions(err_code = 'swt', err_message = 'Something Went Wrong', &block) ⇒ Object
Wrapper Method which could be used to execute business logic Error handling code wraps execution of business logic.
-
#success ⇒ Object
Success.
-
#success_with_data(data) ⇒ Object
Success with data.
Instance Method Details
#error_with_data(code, msg, data = {}) ⇒ Object
Error with data
Arguments:
code: (String)
msg: (String)
data: (Hash)
Returns:
OstKycSdkRuby::Util::Result
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ost-kyc-sdk-ruby/util/services_helper.rb', line 62 def error_with_data(code, msg, data = {}) OstKycSdkRuby::Util::Result.error( { error: code, error_message: msg, data: data } ) end |
#exception_with_data(e, code, msg, data = {}) ⇒ Object
Exception with data and without action
Arguments:
e: (Exception)
code: (String)
msg: (String)
data: (Hash optional)
Returns:
OstKycSdkRuby::Util::Result
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ost-kyc-sdk-ruby/util/services_helper.rb', line 86 def exception_with_data(e, code, msg, data = {}) OstKycSdkRuby::Util::Result.exception( e, { error: code, error_message: msg, data: data } ) end |
#perform_and_handle_exceptions(err_code = 'swt', err_message = 'Something Went Wrong', &block) ⇒ Object
Wrapper Method which could be used to execute business logic Error handling code wraps execution of business logic
Arguments:
err_code: (String)
err_message: (String)
block: (Proc)
Returns:
OstKycSdkRuby::Util::Result
18 19 20 21 22 23 24 |
# File 'lib/ost-kyc-sdk-ruby/util/services_helper.rb', line 18 def perform_and_handle_exceptions(err_code = 'swt', = 'Something Went Wrong', &block) begin yield if block_given? rescue StandardError => se OstKycSdkRuby::Util::Result.exception(se, {error: err_code, error_message: , data: @params} ) end end |
#success ⇒ Object
31 32 33 |
# File 'lib/ost-kyc-sdk-ruby/util/services_helper.rb', line 31 def success success_with_data({}) end |
#success_with_data(data) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/ost-kyc-sdk-ruby/util/services_helper.rb', line 43 def success_with_data(data) # Allow only Hash data to pass ahead data = {} unless Util::CommonValidator.is_a_hash?(data) OstKycSdkRuby::Util::Result.success({data: data}) end |