docusign_webforms 1.0.0 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,29 @@
1
+ =begin
2
+ #Web Forms API version 1.1
3
+
4
+ #The Web Forms API facilitates generating semantic HTML forms around everyday contracts.
5
+
6
+ OpenAPI spec version: 1.1.0
7
+ Contact: devcenter@docusign.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module DocuSign_WebForms
15
+ class WebFormType
16
+
17
+ STANDALONE = 'standalone'.freeze
18
+ HAS_ESIGN_TEMPLATE = 'hasEsignTemplate'.freeze
19
+
20
+ # Builds the enum from string
21
+ # @param [String] The enum value in the form of the string
22
+ # @return [String] The enum value
23
+ def build_from_hash(value)
24
+ constantValues = WebFormType.constants.select { |c| WebFormType::const_get(c) == value }
25
+ raise "Invalid ENUM value #{value} for class #WebFormType" if constantValues.empty?
26
+ value
27
+ end
28
+ end
29
+ end
@@ -10,5 +10,5 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git
10
10
  =end
11
11
 
12
12
  module DocuSign_WebForms
13
- VERSION = '1.0.0'
13
+ VERSION = '2.0.0.rc1'
14
14
  end
@@ -39,6 +39,7 @@ require 'docusign_webforms/models/web_form_source'
39
39
  require 'docusign_webforms/models/web_form_state'
40
40
  require 'docusign_webforms/models/web_form_summary'
41
41
  require 'docusign_webforms/models/web_form_summary_list'
42
+ require 'docusign_webforms/models/web_form_type'
42
43
  require 'docusign_webforms/models/web_form_user_info'
43
44
  require 'docusign_webforms/models/web_form_values'
44
45
 
data/tests/Gemfile CHANGED
@@ -2,4 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rspec'
4
4
 
5
+ gem 'ffi', '1.16.3'
5
6
  gem 'docusign_webforms', path: '../'
@@ -0,0 +1 @@
1
+
@@ -1,38 +1,563 @@
1
- require 'docusign_webforms'
2
- require 'base64'
3
- require 'uri'
4
- RSpec.describe DocuSign_WebForms::FormManagementApi do
5
- def login
6
- begin
7
- if $api_client.nil?
8
- configuration = DocuSign_WebForms::Configuration.new
9
- configuration.host = "https://demo.services.docusign.net/webforms/v1.1"
10
-
11
- $api_client = DocuSign_WebForms::ApiClient.new(configuration)
12
- end
1
+ require "docusign_webforms"
2
+ require "base64"
3
+ require "uri"
4
+ require "date"
5
+
6
+
7
+ describe "DocuSign Ruby Client Tests" do
8
+ def login
9
+ begin
10
+ if $api_client.nil?
11
+ configuration = DocuSign_WebForms::Configuration.new
12
+ configuration.host = $host
13
+
14
+ $api_client = DocuSign_WebForms::ApiClient.new(configuration)
15
+ $api_client.set_oauth_base_path(DocuSign_WebForms::OAuth::DEMO_OAUTH_BASE_PATH)
16
+ end
17
+
18
+ decode_base64_content = Base64.decode64(ENV["PRIVATE_KEY"])
19
+
20
+ File.open($private_key_filename, "wb") do |f|
21
+ f.write(decode_base64_content)
22
+ end
23
+ scopes = [DocuSign_WebForms::OAuth::SCOPE_IMPERSONATION, DocuSign_WebForms::OAuth::SCOPE_SIGNATURE, "webforms_read", "webforms_write", "webforms_instance_read", "webforms_instance_write"]
24
+ token_obj = $api_client.request_jwt_user_token(ENV["INTEGRATOR_KEY_JWT"], ENV["USER_ID"], File.read($private_key_filename), $expires_in_seconds, scopes)
25
+ user_info = $api_client.get_user_info(token_obj.access_token)
13
26
 
14
- $api_client.set_default_header("Authorization", "Bearer" + " " + "")
15
- return nil
27
+ if !user_info.nil?
28
+ user_info.accounts.each do |account|
29
+ if account.is_default == "true"
30
+ account_id = account.account_id
31
+ $api_client.set_base_path("https://apps-d.docusign.com/api/webforms")
32
+ return account
33
+ end
16
34
  end
35
+ end
36
+ rescue => e
37
+ puts "Error during processing: #{$!}"
17
38
  end
18
-
19
- def create_api_client
39
+
40
+ return nil
41
+ end
42
+
43
+ def create_api_client
20
44
  if $api_client.nil?
21
- self.login()
45
+ self.login()
22
46
  end
23
47
 
24
48
  return $api_client
49
+ end
50
+
51
+ before(:all) do
52
+ # run before each test
53
+ $host = "apps-d.docusign.com"
54
+
55
+ $expires_in_seconds = 3600 #1 hour
56
+ $auth_server = "account-d.docusign.com"
57
+ $private_key_filename = "../docs/private.pem"
58
+
59
+ $recipient_name = "Ruby SDK"
60
+
61
+ # Required for embedded signing url
62
+ $client_user_id = ENV["USER_ID"]
63
+ $integrator_key = ENV["INTEGRATOR_KEY_JWT"]
64
+ $secret = ENV["SECRET"]
65
+ $return_url = "https://developers.docusign.com/"
66
+ $authentication_method = "email"
67
+
68
+ $template_id = ""
69
+
70
+ $base_uri = nil
71
+ $account_id = nil
72
+ $api_client = nil
73
+ $form_id = nil
74
+ $client_user_id = nil
75
+ $instance_id = nil
76
+ login()
77
+ end
78
+
79
+ after do
80
+ # run after each test
81
+ end
82
+
83
+ describe DocuSign_WebForms::OAuth do
84
+ describe ".login" do
85
+ context "given correct credentials" do
86
+ it "return Account" do
87
+ account = login()
88
+
89
+ if !account.nil?
90
+ $base_uri = "https://apps-d.docusign.com/api/webforms"
91
+ $account_id = account.account_id
92
+ end
93
+
94
+ expect($account_id).to be_truthy
95
+ end
96
+ end
25
97
  end
98
+ end
99
+
100
+ describe DocuSign_WebForms::FormManagementApi do
101
+
102
+ describe ".ListForms" do
103
+ context "given account id" do
104
+ it "return forms" do
105
+ api_client = create_api_client()
106
+ form_management = DocuSign_WebForms::FormManagementApi.new(api_client)
107
+ list_forms = form_management.list_forms($account_id)
26
108
 
27
- describe '#listForms' do
28
- it 'list forms' do
29
- begin
30
- api_client = create_api_client()
31
- form_management_api = DocuSign_WebForms::FormManagementApi.new(api_client)
32
- puts form_management_api.list_forms("3c9c0391-01ac-4a98-8fab-adb9d0e548d2")
33
- rescue => e
34
- puts "An error occurred: #{e}"
109
+ # Ensure that the response from list_forms is correctly structured
110
+ if list_forms.is_a?(DocuSign_WebForms::WebFormSummaryList)
111
+ web_form_summary_list = list_forms
112
+
113
+ # Check if there are items in the list
114
+ if web_form_summary_list.items.any?
115
+ web_form_summary_list.items.each do |web_form_summary|
116
+ expect(web_form_summary.id).to be_truthy
117
+ expect(web_form_summary.account_id).to be_truthy
118
+ expect(web_form_summary.is_published).not_to be_nil
119
+ expect(web_form_summary.is_enabled).not_to be_nil
120
+ if web_form_summary.is_enabled == true
121
+ $form_id = web_form_summary.id
122
+ break # Exit loop once the first enabled form is found
123
+ end
124
+ end
125
+ else
126
+ puts "No web form summaries found."
35
127
  end
36
- end
128
+ else
129
+ puts "Error: Unexpected response format from list_forms."
130
+ end
131
+ expect(list_forms).to be_truthy
132
+ end
133
+ end
134
+ end
135
+ describe ".GetForm" do
136
+ context "given account id and form id" do
137
+ it "return form" do
138
+ api_client = create_api_client()
139
+ form_management = DocuSign_WebForms::FormManagementApi.new(api_client)
140
+ form_options = DocuSign_WebForms::GetFormOptions.new
141
+ form_options.state = "active"
142
+ get_form = form_management.get_form($account_id, $form_id, form_options)
143
+ # Ensure that the response from list_forms is correctly structured
144
+ if get_form.is_a?(DocuSign_WebForms::WebForm)
145
+ web_form = get_form
146
+
147
+ expect(web_form.id).to be_truthy
148
+ expect(web_form.id).to eq ($form_id)
149
+ expect(web_form.account_id).to be_truthy
150
+ expect(web_form.account_id).to eq($account_id)
151
+ expect(web_form.is_published).not_to be_nil
152
+ expect(web_form.is_enabled).not_to be_nil
153
+ expect(web_form.form_state).not_to be_nil
154
+ expect(web_form.form_metadata).not_to be_nil
155
+ else
156
+ puts "Error: Unexpected response format from get_form."
157
+ pending "There is error in the API data"
158
+ end
159
+ expect(get_form).to be_truthy
160
+ end
161
+ end
162
+ end
163
+
164
+ # Negative testing
165
+ describe ".ListForms" do
166
+ context "given wrong account id" do
167
+ it "should throw API Error" do
168
+ api_client = create_api_client()
169
+ form_management = DocuSign_WebForms::FormManagementApi.new(api_client)
170
+ wrong_account_id = "abc123"
171
+ expect {
172
+ list_forms = form_management.list_forms(wrong_account_id)
173
+ }.to raise_error(DocuSign_WebForms::ApiError)
174
+ end
175
+ end
176
+ end
177
+
178
+ describe ".GetForm" do
179
+ context "given wrong account id and wrong form id" do
180
+ it "should throw API Error" do
181
+ api_client = create_api_client()
182
+ form_management = DocuSign_WebForms::FormManagementApi.new(api_client)
183
+ wrong_account_id = "abc123"
184
+ wrong_form_id = "xyz123"
185
+ expect {
186
+ get_form = form_management.get_form(wrong_account_id, wrong_form_id)
187
+ }.to raise_error(DocuSign_WebForms::ApiError)
188
+ end
189
+ end
190
+ context "given correct account id and wrong form id" do
191
+ it "should throw API Error" do
192
+ api_client = create_api_client()
193
+ form_management = DocuSign_WebForms::FormManagementApi.new(api_client)
194
+ wrong_form_id = "xyz123"
195
+ expect {
196
+ get_form = form_management.get_form($account_id, wrong_form_id)
197
+ }.to raise_error(DocuSign_WebForms::ApiError)
198
+ end
199
+ end
200
+ context "given wrong account id and correct form id" do
201
+ it "should throw API Error" do
202
+ api_client = create_api_client()
203
+ form_management = DocuSign_WebForms::FormManagementApi.new(api_client)
204
+ wrong_account_id = "abc123"
205
+ expect {
206
+ get_form = form_management.get_form(wrong_account_id, $form_id)
207
+ }.to raise_error(DocuSign_WebForms::ApiError)
208
+ end
209
+ end
210
+ end
211
+
212
+ end
213
+
214
+ describe DocuSign_WebForms::FormInstanceManagementApi do
215
+
216
+ describe ".CreateInstance" do
217
+ context "given account id, form id, and instance body" do
218
+ it "creates instance" do
219
+ api_client = create_api_client()
220
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
221
+ instance_body = DocuSign_WebForms::CreateInstanceRequestBody.new
222
+ now = DateTime.now
223
+ client_id = "asif.sajjad-#{now}"
224
+ $client_user_id = client_id
225
+ instance_body.client_user_id = client_id
226
+ instance_body.tags = ["general_details"]
227
+ form_instance = form_instance_management.create_instance($account_id, $form_id, instance_body)
228
+
229
+ # Ensure that the response from list_forms is correctly structured
230
+ if form_instance.is_a?(DocuSign_WebForms::WebFormInstance)
231
+ web_form_instance = form_instance
232
+ $instance_id = web_form_instance.id
233
+ expect(web_form_instance.id).to be_truthy
234
+ expect(web_form_instance.form_id).to eq ($form_id)
235
+ expect(web_form_instance.account_id).to be_truthy
236
+ expect(web_form_instance.account_id).to eq($account_id)
237
+ expect(web_form_instance.form_url).not_to be_nil
238
+ expect(web_form_instance.instance_token).not_to be_nil
239
+ expect(web_form_instance.token_expiration_date_time).not_to be_nil
240
+ else
241
+ puts "Error: Unexpected response format from form_instance."
242
+ pending "Unexpected response in create form_instance other than WebformInstance"
243
+ end
244
+ expect(form_instance).to be_truthy
245
+ end
246
+ end
247
+ end
248
+
249
+ describe ".GetInstance" do
250
+ context "given account id, form id, and instance id" do
251
+ it "get instance" do
252
+ api_client = create_api_client()
253
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
254
+ form_instance = form_instance_management.get_instance($account_id, $form_id, $instance_id)
255
+
256
+ # Ensure that the response from list_forms is correctly structured
257
+ if form_instance.is_a?(DocuSign_WebForms::WebFormInstance)
258
+ web_form_instance = form_instance
259
+ expect(web_form_instance.id).to be_truthy
260
+ expect(web_form_instance.form_id).to eq ($form_id)
261
+ expect(web_form_instance.account_id).to be_truthy
262
+ expect(web_form_instance.status).to be_truthy
263
+ expect(web_form_instance.account_id).to eq($account_id)
264
+ expect(web_form_instance.client_user_id).to eq($client_user_id)
265
+ expect(web_form_instance.instance_metadata).not_to be_nil
266
+ else
267
+ puts "Error: Unexpected response format from get_instance."
268
+ pending "Unexpected response in get_instance other than WebformInstance"
269
+ end
270
+ expect(form_instance).to be_truthy
271
+ end
272
+ end
273
+ end
274
+
275
+ describe ".ListInstances" do
276
+ context "given account id and form id" do
277
+ it "fetch instances" do
278
+ api_client = create_api_client()
279
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
280
+ form_instances_object = form_instance_management.list_instances($account_id, $form_id)
281
+ if form_instances_object.is_a?(DocuSign_WebForms::WebFormInstanceList)
282
+ form_instances = form_instances_object.items
283
+ # Ensure that the response from list_forms is correctly structured
284
+ if form_instances.is_a?(Array) && form_instances.all? { |item| item.is_a?(DocuSign_WebForms::WebFormInstance) }
285
+ web_form_instances = form_instances
286
+ web_form_instance = web_form_instances.first
287
+ expect(web_form_instance.id).to be_truthy
288
+ expect(web_form_instance.form_id).to eq ($form_id)
289
+ expect(web_form_instance.account_id).to be_truthy
290
+ expect(web_form_instance.status).to be_truthy
291
+ expect(web_form_instance.account_id).to eq($account_id)
292
+ expect(web_form_instance.instance_metadata).not_to be_nil
293
+ else
294
+ puts "Error: Unexpected response format from list_instances."
295
+ pending "Unexpected item in list form_instances other than WebformInstance"
296
+ end
297
+ else
298
+ puts "Error: Unexpected response format from list_instances_object."
299
+ pending "Unexpected response in form_instances_object other than WebformInstanceList"
300
+ end
301
+ expect(form_instances_object).to be_truthy
302
+ end
303
+ end
304
+ end
305
+
306
+ describe ".RefreshToken" do
307
+ context "given account id, form id, and instance id" do
308
+ it "refresh the token" do
309
+ api_client = create_api_client()
310
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
311
+ refresh_token = form_instance_management.refresh_token($account_id, $form_id, $instance_id)
312
+
313
+ # Ensure that the response from list_forms is correctly structured
314
+ if refresh_token.is_a?(DocuSign_WebForms::WebFormInstance)
315
+ web_form_instance = refresh_token
316
+ expect(web_form_instance.id).to be_truthy
317
+ expect(web_form_instance.id).to eq ($instance_id)
318
+ expect(web_form_instance.instance_token).to be_truthy
319
+ expect(web_form_instance.form_url).to be_truthy
320
+ expect(web_form_instance.token_expiration_date_time).to be_truthy
321
+ else
322
+ puts "Error: Unexpected response format from refresh_token."
323
+ end
324
+ expect(refresh_token).to be_truthy
325
+ end
326
+ end
37
327
  end
328
+
329
+ # Negative testing
330
+ describe ".CreateInstance" do
331
+ context "given wrong account id with correct form id, and instance body" do
332
+ it "should throw API Error" do
333
+ api_client = create_api_client()
334
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
335
+ instance_body = DocuSign_WebForms::CreateInstanceRequestBody.new
336
+ now = DateTime.now
337
+ client_id = "asif.sajjad-#{now}"
338
+ instance_body.client_user_id = client_id
339
+ instance_body.tags = ["general_details"]
340
+ wrong_account_id = "abc123"
341
+
342
+ expect{
343
+ form_instance = form_instance_management.create_instance(wrong_account_id, $form_id, instance_body)
344
+ }.to raise_error(DocuSign_WebForms::ApiError)
345
+ end
346
+ end
347
+ context "given right account id and instance body with wrong form id" do
348
+ it "should throw API Error" do
349
+ api_client = create_api_client()
350
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
351
+ instance_body = DocuSign_WebForms::CreateInstanceRequestBody.new
352
+ now = DateTime.now
353
+ client_id = "asif.sajjad-#{now}"
354
+ instance_body.client_user_id = client_id
355
+ instance_body.tags = ["general_details"]
356
+ wrong_form_id = "xyz123"
357
+
358
+ expect{
359
+ form_instance = form_instance_management.create_instance($account_id, wrong_form_id, instance_body)
360
+ }.to raise_error(DocuSign_WebForms::ApiError)
361
+ end
362
+ end
363
+ context "given right account id and form id with nil instance body" do
364
+ it "should throw API Error" do
365
+ api_client = create_api_client()
366
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
367
+ instance_body = nil
368
+
369
+ expect{
370
+ form_instance = form_instance_management.create_instance($account_id, $form_id, instance_body)
371
+ }.to raise_error(ArgumentError)
372
+ end
373
+ end
374
+ context "given nil account id with correct form id and instance body" do
375
+ it "should throw API Error" do
376
+ api_client = create_api_client()
377
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
378
+ instance_body = DocuSign_WebForms::CreateInstanceRequestBody.new
379
+ now = DateTime.now
380
+ client_id = "asif.sajjad-#{now}"
381
+ instance_body.client_user_id = client_id
382
+ instance_body.tags = ["general_details"]
383
+
384
+ expect{
385
+ form_instance = form_instance_management.create_instance(nil, $form_id, instance_body)
386
+ }.to raise_error(ArgumentError)
387
+ end
388
+ end
389
+ context "given nil form id with correct account id and instance body" do
390
+ it "should throw API Error" do
391
+ api_client = create_api_client()
392
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
393
+ instance_body = DocuSign_WebForms::CreateInstanceRequestBody.new
394
+ now = DateTime.now
395
+ client_id = "asif.sajjad-#{now}"
396
+ instance_body.client_user_id = client_id
397
+ instance_body.tags = ["general_details"]
398
+
399
+ expect{
400
+ form_instance = form_instance_management.create_instance($account_id, nil, instance_body)
401
+ }.to raise_error(ArgumentError)
402
+ end
403
+ end
404
+ end
405
+
406
+
407
+ describe ".GetInstance" do
408
+ context "given wrong account id with correct form id, and instance id" do
409
+ it "should throw API Error" do
410
+ api_client = create_api_client()
411
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
412
+ wrong_account_id = "abc123"
413
+ expect{
414
+ form_instance = form_instance_management.get_instance(wrong_account_id, $form_id, $instance_id)
415
+ }.to raise_error(DocuSign_WebForms::ApiError)
416
+ end
417
+ end
418
+ context "given wrong form id with correct account id, and instance id" do
419
+ it "should throw API Error" do
420
+ api_client = create_api_client()
421
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
422
+ wrong_form_id = "xyz123"
423
+ expect{
424
+ form_instance = form_instance_management.get_instance($account_id, wrong_form_id, $instance_id)
425
+ }.to raise_error(DocuSign_WebForms::ApiError)
426
+ end
427
+ end
428
+ context "given wrong instance id with correct account id, and form id" do
429
+ it "should throw API Error" do
430
+ api_client = create_api_client()
431
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
432
+ wrong_instance_id = "lmn123"
433
+ expect{
434
+ form_instance = form_instance_management.get_instance($account_id, $form_id, wrong_instance_id)
435
+ }.to raise_error(DocuSign_WebForms::ApiError)
436
+ end
437
+ end
438
+ context "given nil instance id with correct account id, and form id" do
439
+ it "should throw API Error" do
440
+ api_client = create_api_client()
441
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
442
+ expect{
443
+ form_instance = form_instance_management.get_instance($account_id, $form_id, nil)
444
+ }.to raise_error(ArgumentError)
445
+ end
446
+ end
447
+ context "given nil account id with correct form id, and instance id" do
448
+ it "should throw API Error" do
449
+ api_client = create_api_client()
450
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
451
+ expect{
452
+ form_instance = form_instance_management.get_instance(nil, $form_id, $instance_id)
453
+ }.to raise_error(ArgumentError)
454
+ end
455
+ end
456
+ context "given nil form id with correct account id, and instance id" do
457
+ it "should throw API Error" do
458
+ api_client = create_api_client()
459
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
460
+ expect{
461
+ form_instance = form_instance_management.get_instance($account_id, nil, $instance_id)
462
+ }.to raise_error(ArgumentError)
463
+ end
464
+ end
465
+
466
+ end
467
+
468
+
469
+ describe ".ListInstances" do
470
+ context "given wrong account id and correct form id" do
471
+ it "should throw API Error" do
472
+ api_client = create_api_client()
473
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
474
+ wrong_account_id = "abc123"
475
+ expect{
476
+ form_instances = form_instance_management.list_instances(wrong_account_id, $form_id)
477
+ }.to raise_error(DocuSign_WebForms::ApiError)
478
+ end
479
+ end
480
+ context "given wrong form id and correct account id" do
481
+ it "should throw API Error" do
482
+ api_client = create_api_client()
483
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
484
+ wrong_form_id = "xyz123"
485
+ expect{
486
+ form_instances = form_instance_management.list_instances($account_id, wrong_form_id)
487
+ }.to raise_error(DocuSign_WebForms::ApiError)
488
+ end
489
+ end
490
+ context "given nil form id and correct account id" do
491
+ it "should throw API Error" do
492
+ api_client = create_api_client()
493
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
494
+ expect{
495
+ form_instances = form_instance_management.list_instances($account_id, nil)
496
+ }.to raise_error(ArgumentError)
497
+ end
498
+ end
499
+ context "given nil account id and correct form id" do
500
+ it "should throw API Error" do
501
+ api_client = create_api_client()
502
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
503
+ expect{
504
+ form_instances = form_instance_management.list_instances(nil, $form_id)
505
+ }.to raise_error(ArgumentError)
506
+ end
507
+ end
508
+ end
509
+
510
+
511
+ describe ".RefreshToken" do
512
+ context "given wrong account id with correct form id, and instance id" do
513
+ it "should throw API Error" do
514
+ api_client = create_api_client()
515
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
516
+ wrong_account_id = "abc123"
517
+ expect{
518
+ refresh_token = form_instance_management.refresh_token(wrong_account_id, $form_id, $instance_id)
519
+ }.to raise_error(DocuSign_WebForms::ApiError)
520
+ end
521
+ end
522
+ context "given wrong form id with correct account id, and instance id" do
523
+ it "should throw API Error" do
524
+ api_client = create_api_client()
525
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
526
+ wrong_form_id = "xyz123"
527
+ expect{
528
+ refresh_token = form_instance_management.refresh_token($account_id, wrong_form_id, $instance_id)
529
+ }.to raise_error(DocuSign_WebForms::ApiError)
530
+ end
531
+ end
532
+ context "given nil account id with correct form id, and instance id" do
533
+ it "should throw API Error" do
534
+ api_client = create_api_client()
535
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
536
+ expect{
537
+ refresh_token = form_instance_management.refresh_token(nil, $form_id, $instance_id)
538
+ }.to raise_error(ArgumentError)
539
+ end
540
+ end
541
+ context "given nil form id with correct account id, and instance id" do
542
+ it "should throw API Error" do
543
+ api_client = create_api_client()
544
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
545
+ expect{
546
+ refresh_token = form_instance_management.refresh_token($account_id, nil, $instance_id)
547
+ }.to raise_error(ArgumentError)
548
+ end
549
+ end
550
+ context "given nil instance id with correct account id, and form id" do
551
+ it "should throw API Error" do
552
+ api_client = create_api_client()
553
+ form_instance_management = DocuSign_WebForms::FormInstanceManagementApi.new(api_client)
554
+ expect{
555
+ refresh_token = form_instance_management.refresh_token($account_id, $form_id, nil)
556
+ }.to raise_error(ArgumentError)
557
+ end
558
+ end
559
+ end
560
+
561
+ end
562
+
38
563
  end