joy_ussd_engine 0.1.10 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/joy_ussd_engine/hubtel_transformer.rb +4 -0
- data/lib/joy_ussd_engine/session_manager.rb +33 -33
- data/lib/joy_ussd_engine/version.rb +1 -1
- data/lib/joy_ussd_engine.rb +5 -0
- data/pkg/joy_ussd_engine-0.1.13.gem +0 -0
- metadata +3 -3
- data/pkg/joy_ussd_engine-0.1.10.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a0caadc4f86815e553db92686d324b244c51627777a21dfd7ef3e548142a6c8
|
4
|
+
data.tar.gz: b7471162a7c88c2ae1b7fb5f8f3d806af47cb456d66e0c04724cd265d24f6db4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d3753253b039d771f70a821a21baf1c2cf3cece98cb3bfea543b38365746959c6a09ceed0e302f6257327bfb10ae3c7ff5aca8c8cfb2c7b63b036ff760cce53
|
7
|
+
data.tar.gz: 0f175497f911d7b5f36e3f8cabb34208789aa3e644f5e85968cb4c1f2385abfac4ccd7b982b84272d03b35f9daa314a337eed0ed8410fd26dcd8f21b05c6ede4
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module JoyUssdEngine::SessionManager
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
4
|
+
def expire_mins
|
5
|
+
@selected_provider.expiration.blank? ? 60.seconds : @selected_provider.expiration
|
6
|
+
end
|
7
|
+
|
8
|
+
def user_mobile_number
|
9
|
+
@user_mobile_number ||= get_state[:"#{@params[:session_id]}"]
|
10
|
+
end
|
11
|
+
|
12
|
+
# Retrive Session Data
|
13
|
+
def get_state
|
14
|
+
session_id = @params[:session_id]
|
15
|
+
REDIS.with do |conn|
|
16
|
+
data = conn.get(session_id)
|
17
|
+
return {} if data.blank?
|
18
|
+
JSON.parse(data, symbolize_names: true)
|
20
19
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
end
|
21
|
+
|
22
|
+
# Store USSD sessions in Redis with Expiry
|
23
|
+
def set_state(payload = {})
|
24
|
+
session_id = @params[:session_id]
|
25
|
+
current_data = get_state
|
26
|
+
REDIS.with do |conn|
|
27
|
+
payload = current_data.merge(params.merge(payload))
|
28
|
+
conn.set(session_id, payload.to_json)
|
29
|
+
conn.expire(session_id, expire_mins)
|
31
30
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
end
|
32
|
+
|
33
|
+
# Delete Session payload
|
34
|
+
def reset_state
|
35
|
+
session_id = @params[:session_id]
|
36
|
+
REDIS.with do |conn|
|
37
|
+
conn.del(session_id)
|
39
38
|
end
|
40
39
|
end
|
40
|
+
end
|
41
41
|
|
data/lib/joy_ussd_engine.rb
CHANGED
@@ -29,6 +29,11 @@ module JoyUssdEngine
|
|
29
29
|
# If a particular provider returns some sort of response that can terminate the app we do that check here
|
30
30
|
return @current_menu = end_point.to_s if @selected_provider.send("app_terminator", params) || @data[:ClientState] == 'EndJoyUssdEngine'
|
31
31
|
|
32
|
+
if(@selected_provider.send("app_initiator", params) ){
|
33
|
+
@current_menu = start_point.to_s
|
34
|
+
reset_state
|
35
|
+
return
|
36
|
+
}
|
32
37
|
@current_menu = @data[:ClientState].blank? ? start_point.to_s : @data[:ClientState]
|
33
38
|
end
|
34
39
|
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joy_ussd_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caleb Mantey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: will_paginate
|
@@ -99,7 +99,7 @@ files:
|
|
99
99
|
- lib/joy_ussd_engine/paginate_menu.rb
|
100
100
|
- lib/joy_ussd_engine/session_manager.rb
|
101
101
|
- lib/joy_ussd_engine/version.rb
|
102
|
-
- pkg/joy_ussd_engine-0.1.
|
102
|
+
- pkg/joy_ussd_engine-0.1.13.gem
|
103
103
|
- spec/joy_ussd_engine_spec.rb
|
104
104
|
- spec/joy_ussd_engine_transformer.spec
|
105
105
|
- spec/spec_helper.rb
|
Binary file
|