Class: JoyUssdEngine::DataTransformer
- Inherits:
-
Object
- Object
- JoyUssdEngine::DataTransformer
- Defined in:
- lib/joy_ussd_engine/data_transformer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Responsible for transforming ussd requests and responses from different providers into what our application can understand.
Instance Method Summary collapse
- #app_terminator(params) ⇒ Object
- #expiration ⇒ Object
-
#initialize(context) ⇒ DataTransformer
constructor
A new instance of DataTransformer.
- #release(message) ⇒ Object
- #request_params(params) ⇒ Object
- #response(message, next_menu = nil) ⇒ Object
Constructor Details
#initialize(context) ⇒ DataTransformer
Returns a new instance of DataTransformer.
10 11 12 |
# File 'lib/joy_ussd_engine/data_transformer.rb', line 10 def initialize(context) @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Responsible for transforming ussd requests and responses from different providers into what our application can understand
9 10 11 |
# File 'lib/joy_ussd_engine/data_transformer.rb', line 9 def context @context end |
Instance Method Details
#app_terminator(params) ⇒ Object
18 19 20 21 |
# File 'lib/joy_ussd_engine/data_transformer.rb', line 18 def app_terminator(params) #Checks to see if ussd app can be terminated by a particular provider depending on the response return false end |
#expiration ⇒ Object
31 32 33 34 |
# File 'lib/joy_ussd_engine/data_transformer.rb', line 31 def expiration # set expiration for different providers @context.expiration.blank? ? 60.seconds : @expiration end |
#release(message) ⇒ Object
27 28 29 |
# File 'lib/joy_ussd_engine/data_transformer.rb', line 27 def release() # Returns a tranformed ussd response for a particular provider and ends the ussd session end |
#request_params(params) ⇒ Object
14 15 16 |
# File 'lib/joy_ussd_engine/data_transformer.rb', line 14 def request_params(params) # transform request body of ussd provider currently in use to match the ussd engine request type end |
#response(message, next_menu = nil) ⇒ Object
23 24 25 |
# File 'lib/joy_ussd_engine/data_transformer.rb', line 23 def response(, = nil) # Returns a tranformed ussd response for a particular provider and wait for user feedback end |