Skip to content

Commit bc81cec

Browse files
committed
Updated example.rb to perform requests to /v1/prefill_forms and to work with mock service
1 parent 254ce13 commit bc81cec

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

example.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
require 'campact_user_service'
44
require 'faraday/detailed_logger'
55

6+
service_host = ENV['SERVICE_HOST'] || 'weact-adapter.staging.campact.de'
7+
68
def instrument_connection_with_extended_logging(client)
79
default_options = {
8-
ssl: { verify: true },
10+
ssl: { verify: false },
911
headers: {
1012
'Accept' => "application/json;q=0.1",
1113
'Accept-Charset' => "utf-8",
@@ -29,7 +31,7 @@ def instrument_connection_with_extended_logging(client)
2931
# Pick which API to connect to
3032
# 1 for session
3133
# 2 for user
32-
puts "Which user service are you going to use?\n\t1) session\n\t2) user"
34+
puts "Which user service are you going to use?\n\t1) session\n\t2) user\n\t3) prefill forms"
3335
option = gets.chomp
3436

3537
# Get TOTP credentials
@@ -57,7 +59,7 @@ def instrument_connection_with_extended_logging(client)
5759
token,
5860
'campact-staging-session',
5961
{
60-
host: 'weact-adapter.staging.campact.de',
62+
host: service_host,
6163
topt_authorization: {user: username, secret: secret}
6264
}
6365
)
@@ -67,7 +69,15 @@ def instrument_connection_with_extended_logging(client)
6769
account = CampactUserService.account(
6870
account_id,
6971
{
70-
host: 'weact-adapter.staging.campact.de',
72+
host: service_host,
73+
topt_authorization: {user: username, secret: secret}
74+
}
75+
)
76+
when '3'
77+
puts "I'll need a user account ID. In practice I won't need this here because it can be derived through the session token"
78+
account_id = gets.chomp
79+
prefill_forms = CampactUserService.prefill_forms(account_id, {
80+
host: service_host,
7181
topt_authorization: {user: username, secret: secret}
7282
}
7383
)

0 commit comments

Comments
 (0)