joy_ussd_engine 0.1.5 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80f97294b96fb0c861b5d65226138e0f3b16e86fb71ced93371b62c2a22537b5
4
- data.tar.gz: d28f4cfbac9b181baa531ecee3256d243b4a8c2ca09d893f7f60e55ca4221dd8
3
+ metadata.gz: be9eefb4a12df8afda79befef8e0e53798ebf2a013205f82ceff655e29a9a84e
4
+ data.tar.gz: 39d08095974931300dc44efb3f443936feb69687daa58c012b813594a32468a0
5
5
  SHA512:
6
- metadata.gz: d72616d570bea38872ec4d7c6c0294aa89891e43637735f87750d8f94ee66e94b999a14ecb690b18e0b0bcb3959e740077ee8b245c7b6a57640099f61f50893e
7
- data.tar.gz: c22582c624b22a21d6a4e711ff72ef398b5a0bc693c6125a11ec4b04a121bee943faa6926aac714129fe440c1c5700c2c42532a737701af992f740185522ef10
6
+ metadata.gz: f287009e3b1933a18d0d8796d39f04e91b85b8bdca52385a40fc7d5596ebdc27953d5fb68561e8d535cbd1294e74bb292741c1df7b6be47f731db3b085f1e279
7
+ data.tar.gz: 1a5a8bfe5fc507d0235a358ab04b3dcba66178f81d35de3d7d50d6e3ebb056823c81ebbc682b1b65ff1bec7bd3de128b3060e9e03e00b9ad4e2b1b71f9be7d0b
data/CHANGELOG.md CHANGED
@@ -8,6 +8,10 @@
8
8
 
9
9
  - Fixed bug in routing menu
10
10
 
11
- ## [0.1.4] - 2022-04-06
11
+ ## [0.1.5] - 2022-04-06
12
12
 
13
- - Added configs for using hubtel ussd
13
+ - Added configs for hubtel
14
+
15
+ ## [0.1.6] - 2022-04-06
16
+
17
+ - Fixed bug in hubtel configs
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- joy_ussd_engine (0.1.2)
4
+ joy_ussd_engine (0.1.8)
5
5
  will_paginate (~> 3.3.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -89,7 +89,7 @@ class MyController < ApplicationController
89
89
  skip_before_action :verify_authenticity_token
90
90
 
91
91
  def create
92
- joy_ussd_engine = JoyUssdEngine::Core.new(ussd_params, Ussd::Transformers::HubtelTransformer, start_point: Ussd::Menus::StartMenu, end_point: Ussd::Menus::EndMenu)
92
+ joy_ussd_engine = JoyUssdEngine::Core.new(ussd_params, JoyUssdEngine::HubtelTransformer, start_point: Ussd::Menus::StartMenu, end_point: Ussd::Menus::EndMenu)
93
93
  response = joy_ussd_engine.process
94
94
  render json: response, status: :created
95
95
  end
@@ -146,7 +146,8 @@ class Ussd::Transformers::HubtelTransformer < JoyUssdEngine::DataTransformer
146
146
  session_id: params[:Mobile],
147
147
  message: params[:Message],
148
148
  ClientState: params[:ClientState],
149
- Type: params[:Type]
149
+ Type: params[:Type],
150
+ data: params
150
151
  }
151
152
  end
152
153
 
@@ -1,7 +1,4 @@
1
1
  class Ussd::Menus::<%= menu_name.camelcase %>Menu < JoyUssdEngine::Menu
2
- def on_validate
3
- # User input validation
4
- end
5
2
 
6
3
  def before_render
7
4
  # Implement before call backs
@@ -9,9 +6,20 @@ class Ussd::Menus::<%= menu_name.camelcase %>Menu < JoyUssdEngine::Menu
9
6
  @menu_text = "Welcome to the <%= menu_name.camelcase %> menu"
10
7
  end
11
8
 
9
+ def on_validate
10
+ # User input validation
11
+ # if @context.get_state[:<%= menu_name.underscore %>] == "Hello"
12
+ # @field_error = true
13
+ # @error_text = "Sorry! Make sure you entered `Hello`."
14
+ # end
15
+ end
16
+
12
17
  def on_error
13
- # Render error
18
+ # Render error and wait for new user input
14
19
  # @menu_text = "#{@error_text}\n#{@menu_text }"
20
+
21
+ # OR Render Error and Terminate App Session
22
+ # return raise_error(@error_text)
15
23
  end
16
24
 
17
25
  def after_render
@@ -1,40 +1,48 @@
1
1
  class Ussd::Menus::<%= paginating_menu_name.camelcase %>Menu < JoyUssdEngine::PaginateMenu
2
- def on_validate
3
- # User input validation
4
- end
5
2
 
6
3
  def before_render
7
4
  # Implement before call backs
8
5
  @field_name="<%= paginating_menu_name.underscore %>"
9
6
 
10
- # Store paginating items in @paginating_items array variable
11
- # @paginating_items = [
12
- # {title: "Data Structures", item: {id: 1}},
13
- # {title: "Excel Programming", item: {id: 2}},
14
- # {title: "Economics", item: {id: 3}},
15
- # {title: "Big Bang", item: {id: 4}},
16
- # {title: "Democracy Building", item: {id: 5}},
17
- # {title: "Python for Data Scientist", item: {id: 6}},
18
- # {title: "Money Mind", item: {id: 7}},
19
- # {title: "Design Patterns In C#", item: {id: 8}}
20
- # ]
21
-
22
- # Call the paginate method and store the return value in paginated_list
23
- # paginated_list = paginate
24
-
25
- # Use the show menu method to get the paginated list items and return them as text and store in @menu_text
26
- # @menu_text = show_menu(paginated_list, title: "Welcome to the <%= paginating_menu_name.camelcase %> menu", key: 'title')
27
-
28
- # Get the selected item from the user with the `get_selected_item` method and save in state with @context.set_state
29
- # if has_selected?
30
- # selected_book = get_selected_item
31
- # @context.set_state(selected_book: selected_book)
32
- # end
7
+ # Store paginating items in @paginating_items array variable
8
+ # @paginating_items = [
9
+ # {title: "Data Structures", item: {id: 1}},
10
+ # {title: "Excel Programming", item: {id: 2}},
11
+ # {title: "Economics", item: {id: 3}},
12
+ # {title: "Big Bang", item: {id: 4}},
13
+ # {title: "Democracy Building", item: {id: 5}},
14
+ # {title: "Python for Data Scientist", item: {id: 6}},
15
+ # {title: "Money Mind", item: {id: 7}},
16
+ # {title: "Design Patterns In C#", item: {id: 8}}
17
+ # ]
18
+
19
+ # Call the paginate method and store the return value in paginated_list
20
+ # paginated_list = paginate
21
+
22
+ # Use the show menu method to get the paginated list items and return them as text and store in @menu_text
23
+ # @menu_text = show_menu(paginated_list, title: "Welcome to the <%= paginating_menu_name.camelcase %> menu", key: 'title')
24
+
25
+ # Get the selected item from the user with the `get_selected_item` method and save in state with @context.set_state
26
+ # if has_selected?
27
+ # selected_book = get_selected_item
28
+ # @context.set_state(selected_book: selected_book)
29
+ # end
30
+ end
31
+
32
+ def on_validate
33
+ # User input validation
34
+ # if @context.get_state[:<%= menu_name.underscore %>] == "Hello"
35
+ # @field_error = true
36
+ # @error_text = "Sorry! Make sure you entered `Hello`."
37
+ # end
33
38
  end
34
39
 
35
40
  def on_error
36
- # Render error
41
+ # Render error and wait for new user input
37
42
  # @menu_text = "#{@error_text}\n#{@menu_text }"
43
+
44
+ # OR Render Error and Terminate App Session
45
+ # return raise_error(@error_text)
38
46
  end
39
47
 
40
48
  def after_render
@@ -1,11 +1,7 @@
1
1
  class Ussd::Menus::<%= menu_name.camelcase %>Menu < JoyUssdEngine::Menu
2
- def on_validate
3
- # User input validation
4
- end
5
-
6
2
  def before_render
7
3
  # Implement before call backs
8
- # @field_name="<%= menu_name.underscore %>"
4
+ @field_name="<%= menu_name.underscore %>"
9
5
 
10
6
  # title = "Welcome to the <%= menu_name.camelcase %> menu"
11
7
 
@@ -20,9 +16,20 @@ class Ussd::Menus::<%= menu_name.camelcase %>Menu < JoyUssdEngine::Menu
20
16
  # @menu_text = show_menu(title)
21
17
  end
22
18
 
19
+ def on_validate
20
+ # User input validation
21
+ # if @context.get_state[:<%= menu_name.underscore %>] == "Hello"
22
+ # @field_error = true
23
+ # @error_text = "Sorry! Make sure you entered `Hello`."
24
+ # end
25
+ end
26
+
23
27
  def on_error
24
- # Render error
28
+ # Render error and wait for new user input
25
29
  # @menu_text = "#{@error_text}\n#{@menu_text }"
30
+
31
+ # OR Render Error and Terminate App Session
32
+ # return raise_error(@error_text)
26
33
  end
27
34
 
28
35
  def after_render
@@ -6,6 +6,7 @@ module JoyUssdEngine
6
6
  {
7
7
  session_id: params[:Mobile],
8
8
  message: params[:Message],
9
+ Mobile: params[:Mobile],
9
10
  ClientState: params[:ClientState],
10
11
  Type: params[:Type],
11
12
  data: params
@@ -105,6 +105,8 @@ module JoyUssdEngine
105
105
  return if @skip_save
106
106
  data = @context.get_state
107
107
  @previous_client_state = @current_client_state
108
+ return if data[:"#{@field_name}"].present?
109
+ return @context.set_state({ClientState: state, PrevClientState: @previous_client_state}) if @field_name.blank?
108
110
  # @context.set_state({"#{data[:field]}".to_sym => @context.params[:message]}) unless data[:field].blank?
109
111
  @context.set_state({ClientState: state, PrevClientState: @previous_client_state , field: @field_name, field_error: @field_error, error_text: @error_text})
110
112
  end
@@ -112,9 +114,26 @@ module JoyUssdEngine
112
114
  def save_field_value
113
115
  data = get_previous_state
114
116
  return if @skip_save
117
+ return if data[:"#{data[:field]}"].present?
115
118
  @context.set_state({"#{data[:field]}".to_sym => @context.params[:message]}) unless data[:field].blank?
116
119
  end
117
120
 
121
+ # def save_state_load_menu(state)
122
+ # return if @skip_save
123
+ # data = @context.get_state
124
+ # @previous_client_state = @current_client_state
125
+ # # @context.set_state({"#{data[:field]}".to_sym => @context.params[:message]}) unless data[:field].blank?
126
+ # return if data[:"#{@field_name}"].present?
127
+ # @context.set_state({ClientState: state, PrevClientState: @previous_client_state , field: @field_name, field_error: @field_error, error_text: @error_text})
128
+ # end
129
+
130
+ # def save_field_value_load_menu
131
+ # data = get_previous_state
132
+ # return if @skip_save
133
+ # return if data[:"#{data[:field]}"].present?
134
+ # @context.set_state({"#{data[:field]}".to_sym => @context.params[:message]}) unless data[:field].blank?
135
+ # end
136
+
118
137
  def get_previous_state
119
138
  data = @context.get_state
120
139
  @previous_client_state = data[:PrevClientState]
@@ -148,10 +167,16 @@ module JoyUssdEngine
148
167
  joy_release(@error_text)
149
168
  end
150
169
 
170
+ def remove_error_field
171
+ data = @context.get_state
172
+ @context.set_state({"#{@field_name}".to_sym => nil})
173
+ end
174
+
151
175
  def render_field_error
152
176
  before_show_menu
153
177
  before_render
154
178
  on_error
179
+ remove_error_field
155
180
  return render_menu_error[:data] if menu_error
156
181
  response = render
157
182
  response = response.blank? ? joy_response(current_client_state) : response
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JoyUssdEngine
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.8"
5
5
  end
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.5
4
+ version: 0.1.8
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-04-06 00:00:00.000000000 Z
11
+ date: 2022-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: will_paginate
@@ -99,10 +99,6 @@ 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.1.gem
103
- - pkg/joy_ussd_engine-0.1.2.gem
104
- - pkg/joy_ussd_engine-0.1.3.gem
105
- - pkg/joy_ussd_engine-0.1.4.gem
106
102
  - spec/joy_ussd_engine_spec.rb
107
103
  - spec/joy_ussd_engine_transformer.spec
108
104
  - spec/spec_helper.rb
Binary file
Binary file
Binary file
Binary file