joy_ussd_engine 0.1.8 → 0.1.11

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: be9eefb4a12df8afda79befef8e0e53798ebf2a013205f82ceff655e29a9a84e
4
- data.tar.gz: 39d08095974931300dc44efb3f443936feb69687daa58c012b813594a32468a0
3
+ metadata.gz: fc56828dccd4668a5061b1c23faaf67963ed9953286d25ee8b229727b5f3f0e6
4
+ data.tar.gz: 227c2f217a2fe270dcb25e9bb3dc645051f6d878c41fd6f58c7c4002a913cf09
5
5
  SHA512:
6
- metadata.gz: f287009e3b1933a18d0d8796d39f04e91b85b8bdca52385a40fc7d5596ebdc27953d5fb68561e8d535cbd1294e74bb292741c1df7b6be47f731db3b085f1e279
7
- data.tar.gz: 1a5a8bfe5fc507d0235a358ab04b3dcba66178f81d35de3d7d50d6e3ebb056823c81ebbc682b1b65ff1bec7bd3de128b3060e9e03e00b9ad4e2b1b71f9be7d0b
6
+ metadata.gz: 1047ef6a5a1efe1b786448c3338817dd477603128088349a13a2bbb7642e0687a8d73a8dfb30f027d4e86ee98404bb2c442766cdbd3d2373686272c7f0c9e63a
7
+ data.tar.gz: 660a1a32faac859e44284e60f1112c3c3d95db2c6bb2de9e1affc5b2d35dc9e702324c687c3951d3a05fcaf05eef0269e45ea1ce95b3d86cae0d3e490b65a0db
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- joy_ussd_engine (0.1.8)
4
+ joy_ussd_engine (0.1.11)
5
5
  will_paginate (~> 3.3.0)
6
6
 
7
7
  GEM
@@ -209,12 +209,12 @@ module JoyUssdEngine
209
209
  def run
210
210
  save_field_value
211
211
  do_validation
212
- before_show_menu
213
- before_render
214
212
  return render_menu_error[:data] if @menu_error
215
213
  if allow_validation
216
214
  return render_previous if @previous_menu.field_error
217
215
  end
216
+ before_show_menu
217
+ before_render
218
218
  response = render
219
219
  response = response.blank? ? joy_response(@current_client_state) : response
220
220
  after_render
@@ -226,12 +226,12 @@ module JoyUssdEngine
226
226
  def execute
227
227
  save_field_value
228
228
  do_validation
229
- before_show_menu
230
- before_render
231
229
  return render_menu_error[:data] if @menu_error
232
230
  if allow_validation
233
231
  return render_previous if @previous_menu.field_error
234
232
  end
233
+ before_show_menu
234
+ before_render
235
235
  response = render
236
236
  response = response.blank? ? joy_response(@current_client_state) : response
237
237
  after_render
@@ -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.8"
4
+ VERSION = "0.1.11"
5
5
  end
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.8
4
+ version: 0.1.11
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-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: will_paginate
@@ -99,6 +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.11.gem
102
103
  - spec/joy_ussd_engine_spec.rb
103
104
  - spec/joy_ussd_engine_transformer.spec
104
105
  - spec/spec_helper.rb