flow_chat 0.4.0 → 0.4.2

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.
@@ -0,0 +1,78 @@
1
+ module FlowChat
2
+ module Simulator
3
+ module Controller
4
+ def flowchat_simulator
5
+ respond_to do |format|
6
+ format.html do
7
+ render inline: simulator_view_template, layout: false, locals: simulator_locals
8
+ end
9
+ end
10
+ end
11
+
12
+ protected
13
+
14
+ def default_phone_number
15
+ "+233244123456"
16
+ end
17
+
18
+ def default_contact_name
19
+ "John Doe"
20
+ end
21
+
22
+ def default_config_key
23
+ "ussd"
24
+ end
25
+
26
+ def simulator_configurations
27
+ {
28
+ "ussd" => {
29
+ name: "USSD (Nalo)",
30
+ description: "Local development USSD testing",
31
+ processor_type: "ussd",
32
+ provider: "nalo",
33
+ endpoint: "/ussd",
34
+ icon: "📱",
35
+ color: "#28a745",
36
+ settings: {
37
+ phone_number: default_phone_number,
38
+ session_timeout: 300
39
+ }
40
+ },
41
+ "whatsapp" => {
42
+ name: "WhatsApp",
43
+ description: "Local development WhatsApp testing",
44
+ processor_type: "whatsapp",
45
+ provider: "cloud_api",
46
+ endpoint: "/whatsapp/webhook",
47
+ icon: "💬",
48
+ color: "#25D366",
49
+ settings: {
50
+ phone_number: default_phone_number,
51
+ contact_name: default_contact_name,
52
+ verify_token: "local_verify_token",
53
+ webhook_url: "http://localhost:3000/whatsapp/webhook"
54
+ }
55
+ }
56
+ }
57
+ end
58
+
59
+ def simulator_view_template
60
+ File.read simulator_view_path
61
+ end
62
+
63
+ def simulator_view_path
64
+ File.join FlowChat.root.join("flow_chat", "simulator", "views", "simulator.html.erb")
65
+ end
66
+
67
+ def simulator_locals
68
+ {
69
+ pagesize: FlowChat::Config.ussd.pagination_page_size,
70
+ default_phone_number: default_phone_number,
71
+ default_contact_name: default_contact_name,
72
+ default_config_key: default_config_key,
73
+ configurations: simulator_configurations
74
+ }
75
+ end
76
+ end
77
+ end
78
+ end