Class: JoyUssdEngine::DataTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/joy_ussd_engine/data_transformer.rb

Direct Known Subclasses

HubtelTransformer

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contextObject (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

#expirationObject



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(message)
    # 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(message, next_menu = nil)
    # Returns a tranformed ussd response for a particular provider and wait for user feedback
end