joy_ussd_engine 0.1.3 → 0.1.7

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: a604dfd6d12b293936040a84184ef0c2e9db87481306f092bfda2d7f34fc24cc
4
- data.tar.gz: 8c385b17128c1617228b04edabc55b17c77dad1f2629bff5bf32d7f441f53cf0
3
+ metadata.gz: ea7dfcf9e47f093a01d6b8214510d28f671971735521f1f4b2c0a787802bdf63
4
+ data.tar.gz: bd7438052940100e6285f822d49badc91e37181eba894a0129430168b0704adf
5
5
  SHA512:
6
- metadata.gz: b19012528c1a3e8fd021a16fc2953877fec56f9f543d1092e53d0452e365cc16699e0190374f11581ad23def254f9494557a285d386269dca709630fe254a509
7
- data.tar.gz: d3ba5cdaaf1072085c0c13574d06900a9653cb97c0b3f70c0654b5a018f20b74a03dc9de09c7ca330b8dafeaefeaf6ed4c56bf61661f0c0aa8ea4b0fc5ebcef3
6
+ metadata.gz: 5e4f4f4674c530f0c5815f9d17015722112657705e3c6f584e7965278cd47bcbc2f650e59369d99c7fd08939cec8e316d98e651ce0cc735ca82ecbce1bd075d2
7
+ data.tar.gz: 0f35cf308a6236af3fdb86f074a07c8fa4cc78f2cd455dc1a6394596ea85c54e733747fcc00af6a92039b0859844f16e511067b6b588e777a33269fcc3111392
data/CHANGELOG.md CHANGED
@@ -7,3 +7,11 @@
7
7
  ## [0.1.2] - 2022-03-16
8
8
 
9
9
  - Fixed bug in routing menu
10
+
11
+ ## [0.1.5] - 2022-04-06
12
+
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.7)
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
@@ -1,4 +1,3 @@
1
- require 'data_transformer'
2
1
 
3
2
  module JoyUssdEngine
4
3
  class HubtelTransformer < JoyUssdEngine::DataTransformer
@@ -7,8 +6,9 @@ module JoyUssdEngine
7
6
  {
8
7
  session_id: params[:Mobile],
9
8
  message: params[:Message],
9
+ Mobile: params[:Mobile],
10
10
  ClientState: params[:ClientState],
11
- Type: params[:Type]
11
+ Type: params[:Type],
12
12
  data: params
13
13
  }
14
14
  end
@@ -105,6 +105,7 @@ 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?
108
109
  # @context.set_state({"#{data[:field]}".to_sym => @context.params[:message]}) unless data[:field].blank?
109
110
  @context.set_state({ClientState: state, PrevClientState: @previous_client_state , field: @field_name, field_error: @field_error, error_text: @error_text})
110
111
  end
@@ -112,9 +113,26 @@ module JoyUssdEngine
112
113
  def save_field_value
113
114
  data = get_previous_state
114
115
  return if @skip_save
116
+ return if data[:"#{data[:field]}"].present?
115
117
  @context.set_state({"#{data[:field]}".to_sym => @context.params[:message]}) unless data[:field].blank?
116
118
  end
117
119
 
120
+ # def save_state_load_menu(state)
121
+ # return if @skip_save
122
+ # data = @context.get_state
123
+ # @previous_client_state = @current_client_state
124
+ # # @context.set_state({"#{data[:field]}".to_sym => @context.params[:message]}) unless data[:field].blank?
125
+ # return if data[:"#{@field_name}"].present?
126
+ # @context.set_state({ClientState: state, PrevClientState: @previous_client_state , field: @field_name, field_error: @field_error, error_text: @error_text})
127
+ # end
128
+
129
+ # def save_field_value_load_menu
130
+ # data = get_previous_state
131
+ # return if @skip_save
132
+ # return if data[:"#{data[:field]}"].present?
133
+ # @context.set_state({"#{data[:field]}".to_sym => @context.params[:message]}) unless data[:field].blank?
134
+ # end
135
+
118
136
  def get_previous_state
119
137
  data = @context.get_state
120
138
  @previous_client_state = data[:PrevClientState]
@@ -148,10 +166,16 @@ module JoyUssdEngine
148
166
  joy_release(@error_text)
149
167
  end
150
168
 
169
+ def remove_error_field
170
+ data = @context.get_state
171
+ @context.set_state({"#{@field_name}".to_sym => nil})
172
+ end
173
+
151
174
  def render_field_error
152
175
  before_show_menu
153
176
  before_render
154
177
  on_error
178
+ remove_error_field
155
179
  return render_menu_error[:data] if menu_error
156
180
  response = render
157
181
  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.3"
4
+ VERSION = "0.1.7"
5
5
  end
Binary file
Binary file
Binary file
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.3
4
+ version: 0.1.7
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-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: will_paginate
@@ -101,6 +101,11 @@ files:
101
101
  - lib/joy_ussd_engine/version.rb
102
102
  - pkg/joy_ussd_engine-0.1.1.gem
103
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
+ - pkg/joy_ussd_engine-0.1.5.gem
107
+ - pkg/joy_ussd_engine-0.1.6.gem
108
+ - pkg/joy_ussd_engine-0.1.7.gem
104
109
  - spec/joy_ussd_engine_spec.rb
105
110
  - spec/joy_ussd_engine_transformer.spec
106
111
  - spec/spec_helper.rb