Sha256: fe1106b1518cb50f1635f83d27438a67fd5924925f3c1165a1124574c23c35d3

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

module JoyUssdEngine
    class HubtelTransformer < JoyUssdEngine::DataTransformer
        # Tranforms request and response payload between hubtel and our application
        def request_params(params)
            {
                session_id: params[:Mobile],
                message: params[:Message],
                Mobile: params[:Mobile],
                ClientState: params[:ClientState],
                Type: params[:Type],
                data: params
            }
        end

        def app_initiator(params)
            params[:Type] == 'Initiation'
        end

        def app_terminator(params)
            params[:Type] == 'Release' || (params[:Type] != "Initiation" && @context.get_state.blank?)
        end

        def response(message, client_state)
            {
                Type: "Response",
                Message: message,
                ClientState: client_state
            }
        end
    
        def release(message)
            {
                Type: "Release",
                Message: message,
                ClientState: "EndJoyUssdEngine"
            }
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
joy_ussd_engine-0.1.14 lib/joy_ussd_engine/hubtel_transformer.rb
joy_ussd_engine-0.1.13 lib/joy_ussd_engine/hubtel_transformer.rb
joy_ussd_engine-0.1.12 lib/joy_ussd_engine/hubtel_transformer.rb