joy_ussd_engine 0.1.9 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ade8de5e760c7b722295f11d76e842bbcec0c0fb8bebddf011be1ca90bf7be2f
4
- data.tar.gz: a6b4b4ff1caa34b30612fe60dd8fbc4bef81f32e4493bf872f45ba75ee7c104d
3
+ metadata.gz: 3cf6a8217108c8642a72b12ed5a375785551c3e48820f1f0013a4e4ebf7dd0a7
4
+ data.tar.gz: b72121272082de46a31fa8c7238a121f73999d6dede1a2f1f26cdbe2e9b8b700
5
5
  SHA512:
6
- metadata.gz: b3c507ae3094f6da68393f5fa99bf0e32db83eb1c38926702a89a284378eae506629decdc9cdd50fe06a22bf9b91e7d968d4392cc20b311fe7fa60cfcb827111
7
- data.tar.gz: 865bade511b0a484f4da15eb98b2076d9bcfdae40327b18c13ea183a0d4f70b4da7066e2424d154fb1c1a6ac660a2f3cb9840a975ba5cdc26e83ab2868a804c2
6
+ metadata.gz: 53485cbbf16a64e24f7800a75f0475b071da09fcc370ea88a34c4401042578dcd21f776de9772f61d69696d598c8c6889306897b2ce5ca4493573e093795e3d0
7
+ data.tar.gz: 44b1ea2fa623bbedc93befe4ddd3fcab62caa8500e17c7189ca228f933f7651c8b8ca5331905ebb15c89abb2c868f6f6eaf7ea12a065a9fdceb7170fcdbcb05a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- joy_ussd_engine (0.1.9)
4
+ joy_ussd_engine (0.1.12)
5
5
  will_paginate (~> 3.3.0)
6
6
 
7
7
  GEM
@@ -13,6 +13,10 @@ module JoyUssdEngine
13
13
  }
14
14
  end
15
15
 
16
+ def app_initiator(params)
17
+ params[:Type] == 'Initiation'
18
+ end
19
+
16
20
  def app_terminator(params)
17
21
  params[:Type] == 'Release' || (params[:Type] != "Initiation" && @context.get_state.blank?)
18
22
  end
@@ -1,41 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JoyUssdEngine::SessionManager
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[:"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)
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
- # 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)
30
- end
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
- # Delete Session payload
34
- def reset_state
35
- session_id = params["session_id"]
36
- REDIS.with do |conn|
37
- conn.del(session_id)
38
- end
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JoyUssdEngine
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.12"
5
5
  end
@@ -29,7 +29,7 @@ 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
- @current_menu = @data[:ClientState].blank? ? start_point.to_s : @data[:ClientState]
32
+ @current_menu = @data[:ClientState].blank? || @selected_provider.send("app_initiator", params) ? start_point.to_s : @data[:ClientState]
33
33
  end
34
34
 
35
35
  def load_menu(name)
Binary file
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.9
4
+ version: 0.1.12
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-06-07 00:00:00.000000000 Z
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,8 +99,8 @@ 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.8.gem
103
- - pkg/joy_ussd_engine-0.1.9.gem
102
+ - pkg/joy_ussd_engine-0.1.11.gem
103
+ - pkg/joy_ussd_engine-0.1.12.gem
104
104
  - spec/joy_ussd_engine_spec.rb
105
105
  - spec/joy_ussd_engine_transformer.spec
106
106
  - spec/spec_helper.rb
Binary file
Binary file