Class: Dropbox::Sign::TemplateApi

Inherits:
Object
  • Object
show all
Defined in:
lib/dropbox-sign/api/template_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TemplateApi

Returns a new instance of TemplateApi.



22
23
24
# File 'lib/dropbox-sign/api/template_api.rb', line 22

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



20
21
22
# File 'lib/dropbox-sign/api/template_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

#template_add_user(template_id, template_add_user_request, opts = {}) ⇒ TemplateGetResponse

Add User to Template Gives the specified Account access to the specified Template. The specified Account must be a part of your Team.

Parameters:

  • template_id (String)

    The id of the Template to give the Account access to.

  • template_add_user_request (TemplateAddUserRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



31
32
33
34
# File 'lib/dropbox-sign/api/template_api.rb', line 31

def template_add_user(template_id, template_add_user_request, opts = {})
  data, _status_code, _headers = template_add_user_with_http_info(template_id, template_add_user_request, opts)
  data
end

#template_add_user_with_http_info(template_id, template_add_user_request, opts = {}) ⇒ Array<(TemplateGetResponse, Integer, Hash)>

Add User to Template Gives the specified Account access to the specified Template. The specified Account must be a part of your Team.

Parameters:

  • template_id (String)

    The id of the Template to give the Account access to.

  • template_add_user_request (TemplateAddUserRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateGetResponse, Integer, Hash)>)

    TemplateGetResponse data, response status code and response headers



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/dropbox-sign/api/template_api.rb', line 42

def template_add_user_with_http_info(template_id, template_add_user_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_add_user ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_add_user"
  end
  # verify the required parameter 'template_add_user_request' is set
  if @api_client.config.client_side_validation && template_add_user_request.nil?
    fail ArgumentError, "Missing the required parameter 'template_add_user_request' when calling TemplateApi.template_add_user"
  end
  # resource path
  local_var_path = '/template/add_user/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  post_body = {}
  form_params = opts[:form_params] || {}
  result = @api_client.generate_form_data(
    template_add_user_request,
    Dropbox::Sign::TemplateAddUserRequest.openapi_types
  )

  # form parameters
  if result[:has_file]
    form_params = opts[:form_params] || result[:params]
    header_params['Content-Type'] = 'multipart/form-data'
  else
    # http body (model)
    post_body = opts[:debug_body] || result[:params]
  end

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateGetResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_add_user",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
    if e.code === 200
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::TemplateGetResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

    range_code = "4XX".split('').first
    range_code_left = "#{range_code}00".to_i
    range_code_right = "#{range_code}99".to_i
    if e.code >= range_code_left && e.code <= range_code_right
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::ErrorResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_add_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#template_create(template_create_request, opts = {}) ⇒ TemplateCreateResponse

Create Template Creates a template that can then be used.

Parameters:

  • template_create_request (TemplateCreateRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



145
146
147
148
# File 'lib/dropbox-sign/api/template_api.rb', line 145

def template_create(template_create_request, opts = {})
  data, _status_code, _headers = template_create_with_http_info(template_create_request, opts)
  data
end

#template_create_embedded_draft(template_create_embedded_draft_request, opts = {}) ⇒ TemplateCreateEmbeddedDraftResponse

Create Embedded Template Draft The first step in an embedded template workflow. Creates a draft template that can then be further set up in the template ‘edit’ stage.

Parameters:

Returns:



254
255
256
257
# File 'lib/dropbox-sign/api/template_api.rb', line 254

def template_create_embedded_draft(template_create_embedded_draft_request, opts = {})
  data, _status_code, _headers = template_create_embedded_draft_with_http_info(template_create_embedded_draft_request, opts)
  data
end

#template_create_embedded_draft_with_http_info(template_create_embedded_draft_request, opts = {}) ⇒ Array<(TemplateCreateEmbeddedDraftResponse, Integer, Hash)>

Create Embedded Template Draft The first step in an embedded template workflow. Creates a draft template that can then be further set up in the template &#39;edit&#39; stage.

Parameters:

Returns:



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/dropbox-sign/api/template_api.rb', line 264

def template_create_embedded_draft_with_http_info(template_create_embedded_draft_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_create_embedded_draft ...'
  end
  # verify the required parameter 'template_create_embedded_draft_request' is set
  if @api_client.config.client_side_validation && template_create_embedded_draft_request.nil?
    fail ArgumentError, "Missing the required parameter 'template_create_embedded_draft_request' when calling TemplateApi.template_create_embedded_draft"
  end
  # resource path
  local_var_path = '/template/create_embedded_draft'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json', 'multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  post_body = {}
  form_params = opts[:form_params] || {}
  result = @api_client.generate_form_data(
    template_create_embedded_draft_request,
    Dropbox::Sign::TemplateCreateEmbeddedDraftRequest.openapi_types
  )

  # form parameters
  if result[:has_file]
    form_params = opts[:form_params] || result[:params]
    header_params['Content-Type'] = 'multipart/form-data'
  else
    # http body (model)
    post_body = opts[:debug_body] || result[:params]
  end

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateCreateEmbeddedDraftResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_create_embedded_draft",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
    if e.code === 200
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::TemplateCreateEmbeddedDraftResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

    range_code = "4XX".split('').first
    range_code_left = "#{range_code}00".to_i
    range_code_right = "#{range_code}99".to_i
    if e.code >= range_code_left && e.code <= range_code_right
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::ErrorResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_create_embedded_draft\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#template_create_with_http_info(template_create_request, opts = {}) ⇒ Array<(TemplateCreateResponse, Integer, Hash)>

Create Template Creates a template that can then be used.

Parameters:

  • template_create_request (TemplateCreateRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateCreateResponse, Integer, Hash)>)

    TemplateCreateResponse data, response status code and response headers



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/dropbox-sign/api/template_api.rb', line 155

def template_create_with_http_info(template_create_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_create ...'
  end
  # verify the required parameter 'template_create_request' is set
  if @api_client.config.client_side_validation && template_create_request.nil?
    fail ArgumentError, "Missing the required parameter 'template_create_request' when calling TemplateApi.template_create"
  end
  # resource path
  local_var_path = '/template/create'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json', 'multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  post_body = {}
  form_params = opts[:form_params] || {}
  result = @api_client.generate_form_data(
    template_create_request,
    Dropbox::Sign::TemplateCreateRequest.openapi_types
  )

  # form parameters
  if result[:has_file]
    form_params = opts[:form_params] || result[:params]
    header_params['Content-Type'] = 'multipart/form-data'
  else
    # http body (model)
    post_body = opts[:debug_body] || result[:params]
  end

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateCreateResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_create",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
    if e.code === 200
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::TemplateCreateResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

    range_code = "4XX".split('').first
    range_code_left = "#{range_code}00".to_i
    range_code_right = "#{range_code}99".to_i
    if e.code >= range_code_left && e.code <= range_code_right
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::ErrorResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#template_delete(template_id, opts = {}) ⇒ nil

Delete Template Completely deletes the template specified from the account.

Parameters:

  • template_id (String)

    The id of the Template to delete.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


363
364
365
366
# File 'lib/dropbox-sign/api/template_api.rb', line 363

def template_delete(template_id, opts = {})
  template_delete_with_http_info(template_id, opts)
  nil
end

#template_delete_with_http_info(template_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete Template Completely deletes the template specified from the account.

Parameters:

  • template_id (String)

    The id of the Template to delete.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/dropbox-sign/api/template_api.rb', line 373

def template_delete_with_http_info(template_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_delete ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_delete"
  end
  # resource path
  local_var_path = '/template/delete/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  post_body = {}
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_delete",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#template_files(template_id, opts = {}) ⇒ File

Get Template Files Obtain a copy of the current documents specified by the ‘template_id` parameter. Returns a PDF or ZIP file. If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event.

Parameters:

  • template_id (String)

    The id of the template files to retrieve.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :file_type (String)

    Set to &#x60;pdf&#x60; for a single merged document or &#x60;zip&#x60; for a collection of individual documents.

Returns:

  • (File)


431
432
433
434
# File 'lib/dropbox-sign/api/template_api.rb', line 431

def template_files(template_id, opts = {})
  data, _status_code, _headers = template_files_with_http_info(template_id, opts)
  data
end

#template_files_as_data_uri(template_id, opts = {}) ⇒ FileResponseDataUri

Get Template Files as Data Uri Obtain a copy of the current documents specified by the ‘template_id` parameter. Returns a JSON object with a `data_uri` representing the base64 encoded file (PDFs only). If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event.

Parameters:

  • template_id (String)

    The id of the template files to retrieve.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



531
532
533
534
# File 'lib/dropbox-sign/api/template_api.rb', line 531

def template_files_as_data_uri(template_id, opts = {})
  data, _status_code, _headers = template_files_as_data_uri_with_http_info(template_id, opts)
  data
end

#template_files_as_data_uri_with_http_info(template_id, opts = {}) ⇒ Array<(FileResponseDataUri, Integer, Hash)>

Get Template Files as Data Uri Obtain a copy of the current documents specified by the &#x60;template_id&#x60; parameter. Returns a JSON object with a &#x60;data_uri&#x60; representing the base64 encoded file (PDFs only). If the files are currently being prepared, a status code of &#x60;409&#x60; will be returned instead. In this case please wait for the &#x60;template_created&#x60; callback event.

Parameters:

  • template_id (String)

    The id of the template files to retrieve.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(FileResponseDataUri, Integer, Hash)>)

    FileResponseDataUri data, response status code and response headers



541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
# File 'lib/dropbox-sign/api/template_api.rb', line 541

def template_files_as_data_uri_with_http_info(template_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_files_as_data_uri ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_files_as_data_uri"
  end
  # resource path
  local_var_path = '/template/files_as_data_uri/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  post_body = {}
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'FileResponseDataUri'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_files_as_data_uri",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
    if e.code === 200
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::FileResponseDataUri"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

    range_code = "4XX".split('').first
    range_code_left = "#{range_code}00".to_i
    range_code_right = "#{range_code}99".to_i
    if e.code >= range_code_left && e.code <= range_code_right
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::ErrorResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_files_as_data_uri\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#template_files_as_file_url(template_id, opts = {}) ⇒ FileResponse

Get Template Files as File Url Obtain a copy of the current documents specified by the ‘template_id` parameter. Returns a JSON object with a url to the file (PDFs only). If the files are currently being prepared, a status code of `409` will be returned instead. In this case please wait for the `template_created` callback event.

Parameters:

  • template_id (String)

    The id of the template files to retrieve.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :force_download (Integer)

    By default when opening the &#x60;file_url&#x60; a browser will download the PDF and save it locally. When set to &#x60;0&#x60; the PDF file will be displayed in the browser. (default to 1)

Returns:



626
627
628
629
# File 'lib/dropbox-sign/api/template_api.rb', line 626

def template_files_as_file_url(template_id, opts = {})
  data, _status_code, _headers = template_files_as_file_url_with_http_info(template_id, opts)
  data
end

#template_files_as_file_url_with_http_info(template_id, opts = {}) ⇒ Array<(FileResponse, Integer, Hash)>

Get Template Files as File Url Obtain a copy of the current documents specified by the &#x60;template_id&#x60; parameter. Returns a JSON object with a url to the file (PDFs only). If the files are currently being prepared, a status code of &#x60;409&#x60; will be returned instead. In this case please wait for the &#x60;template_created&#x60; callback event.

Parameters:

  • template_id (String)

    The id of the template files to retrieve.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :force_download (Integer)

    By default when opening the &#x60;file_url&#x60; a browser will download the PDF and save it locally. When set to &#x60;0&#x60; the PDF file will be displayed in the browser. (default to 1)

Returns:

  • (Array<(FileResponse, Integer, Hash)>)

    FileResponse data, response status code and response headers



637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
# File 'lib/dropbox-sign/api/template_api.rb', line 637

def template_files_as_file_url_with_http_info(template_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_files_as_file_url ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_files_as_file_url"
  end
  # resource path
  local_var_path = '/template/files_as_file_url/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'force_download'] = opts[:'force_download'] if !opts[:'force_download'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  post_body = {}
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'FileResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_files_as_file_url",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
    if e.code === 200
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::FileResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

    range_code = "4XX".split('').first
    range_code_left = "#{range_code}00".to_i
    range_code_right = "#{range_code}99".to_i
    if e.code >= range_code_left && e.code <= range_code_right
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::ErrorResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_files_as_file_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#template_files_with_http_info(template_id, opts = {}) ⇒ Array<(File, Integer, Hash)>

Get Template Files Obtain a copy of the current documents specified by the &#x60;template_id&#x60; parameter. Returns a PDF or ZIP file. If the files are currently being prepared, a status code of &#x60;409&#x60; will be returned instead. In this case please wait for the &#x60;template_created&#x60; callback event.

Parameters:

  • template_id (String)

    The id of the template files to retrieve.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :file_type (String)

    Set to &#x60;pdf&#x60; for a single merged document or &#x60;zip&#x60; for a collection of individual documents.

Returns:

  • (Array<(File, Integer, Hash)>)

    File data, response status code and response headers



442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'lib/dropbox-sign/api/template_api.rb', line 442

def template_files_with_http_info(template_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_files ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_files"
  end
  allowable_values = ["pdf", "zip"]
  if @api_client.config.client_side_validation && opts[:'file_type'] && !allowable_values.include?(opts[:'file_type'])
    fail ArgumentError, "invalid value for \"file_type\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/template/files/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'file_type'] = opts[:'file_type'] if !opts[:'file_type'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/pdf', 'application/zip', 'application/json']) unless header_params['Accept']

  post_body = {}
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'File'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_files",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
    if e.code === 200
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::File"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

    range_code = "4XX".split('').first
    range_code_left = "#{range_code}00".to_i
    range_code_right = "#{range_code}99".to_i
    if e.code >= range_code_left && e.code <= range_code_right
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::ErrorResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_files\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#template_get(template_id, opts = {}) ⇒ TemplateGetResponse

Get Template Returns the Template specified by the ‘template_id` parameter.

Parameters:

  • template_id (String)

    The id of the Template to retrieve.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



722
723
724
725
# File 'lib/dropbox-sign/api/template_api.rb', line 722

def template_get(template_id, opts = {})
  data, _status_code, _headers = template_get_with_http_info(template_id, opts)
  data
end

#template_get_with_http_info(template_id, opts = {}) ⇒ Array<(TemplateGetResponse, Integer, Hash)>

Get Template Returns the Template specified by the &#x60;template_id&#x60; parameter.

Parameters:

  • template_id (String)

    The id of the Template to retrieve.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateGetResponse, Integer, Hash)>)

    TemplateGetResponse data, response status code and response headers



732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
# File 'lib/dropbox-sign/api/template_api.rb', line 732

def template_get_with_http_info(template_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_get ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_get"
  end
  # resource path
  local_var_path = '/template/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  post_body = {}
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateGetResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_get",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
    if e.code === 200
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::TemplateGetResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

    range_code = "4XX".split('').first
    range_code_left = "#{range_code}00".to_i
    range_code_right = "#{range_code}99".to_i
    if e.code >= range_code_left && e.code <= range_code_right
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::ErrorResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#template_list(opts = {}) ⇒ TemplateListResponse

List Templates Returns a list of the Templates that are accessible by you. Take a look at our [search guide](/api/reference/search/) to learn more about querying templates.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :account_id (String)

    Which account to return Templates for. Must be a team member. Use &#x60;all&#x60; to indicate all team members. Defaults to your account.

  • :page (Integer)

    Which page number of the Template List to return. Defaults to &#x60;1&#x60;. (default to 1)

  • :page_size (Integer)

    Number of objects to be returned per page. Must be between &#x60;1&#x60; and &#x60;100&#x60;. Default is &#x60;20&#x60;. (default to 20)

  • :query (String)

    String that includes search terms and/or fields to be used to filter the Template objects.

Returns:



819
820
821
822
# File 'lib/dropbox-sign/api/template_api.rb', line 819

def template_list(opts = {})
  data, _status_code, _headers = template_list_with_http_info(opts)
  data
end

#template_list_with_http_info(opts = {}) ⇒ Array<(TemplateListResponse, Integer, Hash)>

List Templates Returns a list of the Templates that are accessible by you. Take a look at our [search guide](/api/reference/search/) to learn more about querying templates.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :account_id (String)

    Which account to return Templates for. Must be a team member. Use &#x60;all&#x60; to indicate all team members. Defaults to your account.

  • :page (Integer)

    Which page number of the Template List to return. Defaults to &#x60;1&#x60;. (default to 1)

  • :page_size (Integer)

    Number of objects to be returned per page. Must be between &#x60;1&#x60; and &#x60;100&#x60;. Default is &#x60;20&#x60;. (default to 20)

  • :query (String)

    String that includes search terms and/or fields to be used to filter the Template objects.

Returns:

  • (Array<(TemplateListResponse, Integer, Hash)>)

    TemplateListResponse data, response status code and response headers



832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
# File 'lib/dropbox-sign/api/template_api.rb', line 832

def template_list_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_list ...'
  end
  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling TemplateApi.template_list, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling TemplateApi.template_list, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/template/list'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'account_id'] = opts[:'account_id'] if !opts[:'account_id'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'query'] = opts[:'query'] if !opts[:'query'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  post_body = {}
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_list",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
    if e.code === 200
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::TemplateListResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

    range_code = "4XX".split('').first
    range_code_left = "#{range_code}00".to_i
    range_code_right = "#{range_code}99".to_i
    if e.code >= range_code_left && e.code <= range_code_right
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::ErrorResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#template_remove_user(template_id, template_remove_user_request, opts = {}) ⇒ TemplateGetResponse

Remove User from Template Removes the specified Account’s access to the specified Template.

Parameters:

  • template_id (String)

    The id of the Template to remove the Account&#39;s access to.

  • template_remove_user_request (TemplateRemoveUserRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



925
926
927
928
# File 'lib/dropbox-sign/api/template_api.rb', line 925

def template_remove_user(template_id, template_remove_user_request, opts = {})
  data, _status_code, _headers = template_remove_user_with_http_info(template_id, template_remove_user_request, opts)
  data
end

#template_remove_user_with_http_info(template_id, template_remove_user_request, opts = {}) ⇒ Array<(TemplateGetResponse, Integer, Hash)>

Remove User from Template Removes the specified Account&#39;s access to the specified Template.

Parameters:

  • template_id (String)

    The id of the Template to remove the Account&#39;s access to.

  • template_remove_user_request (TemplateRemoveUserRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateGetResponse, Integer, Hash)>)

    TemplateGetResponse data, response status code and response headers



936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
# File 'lib/dropbox-sign/api/template_api.rb', line 936

def template_remove_user_with_http_info(template_id, template_remove_user_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_remove_user ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_remove_user"
  end
  # verify the required parameter 'template_remove_user_request' is set
  if @api_client.config.client_side_validation && template_remove_user_request.nil?
    fail ArgumentError, "Missing the required parameter 'template_remove_user_request' when calling TemplateApi.template_remove_user"
  end
  # resource path
  local_var_path = '/template/remove_user/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  post_body = {}
  form_params = opts[:form_params] || {}
  result = @api_client.generate_form_data(
    template_remove_user_request,
    Dropbox::Sign::TemplateRemoveUserRequest.openapi_types
  )

  # form parameters
  if result[:has_file]
    form_params = opts[:form_params] || result[:params]
    header_params['Content-Type'] = 'multipart/form-data'
  else
    # http body (model)
    post_body = opts[:debug_body] || result[:params]
  end

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateGetResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_remove_user",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
    if e.code === 200
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::TemplateGetResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

    range_code = "4XX".split('').first
    range_code_left = "#{range_code}00".to_i
    range_code_right = "#{range_code}99".to_i
    if e.code >= range_code_left && e.code <= range_code_right
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::ErrorResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_remove_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#template_update_files(template_id, template_update_files_request, opts = {}) ⇒ TemplateUpdateFilesResponse

Update Template Files Overlays a new file with the overlay of an existing template. The new file(s) must: 1. have the same or higher page count 2. the same orientation as the file(s) being replaced. This will not overwrite or in any way affect the existing template. Both the existing template and new template will be available for use after executing this endpoint. Also note that this will decrement your template quota. Overlaying new files is asynchronous and a successful call to this endpoint will return 200 OK response if the request passes initial validation checks. It is recommended that a callback be implemented to listen for the callback event. A ‘template_created` event will be sent when the files are updated or a `template_error` event will be sent if there was a problem while updating the files. If a callback handler has been configured and the event has not been received within 60 minutes of making the call, check the status of the request in the API dashboard and retry the request if necessary. If the page orientation or page count is different from the original template document, we will notify you with a `template_error` [callback event](app.hellosign.com/api/eventsAndCallbacksWalkthrough).

Parameters:

  • template_id (String)

    The ID of the template whose files to update.

  • template_update_files_request (TemplateUpdateFilesRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



1040
1041
1042
1043
# File 'lib/dropbox-sign/api/template_api.rb', line 1040

def template_update_files(template_id, template_update_files_request, opts = {})
  data, _status_code, _headers = template_update_files_with_http_info(template_id, template_update_files_request, opts)
  data
end

#template_update_files_with_http_info(template_id, template_update_files_request, opts = {}) ⇒ Array<(TemplateUpdateFilesResponse, Integer, Hash)>

Update Template Files Overlays a new file with the overlay of an existing template. The new file(s) must: 1. have the same or higher page count 2. the same orientation as the file(s) being replaced. This will not overwrite or in any way affect the existing template. Both the existing template and new template will be available for use after executing this endpoint. Also note that this will decrement your template quota. Overlaying new files is asynchronous and a successful call to this endpoint will return 200 OK response if the request passes initial validation checks. It is recommended that a callback be implemented to listen for the callback event. A &#x60;template_created&#x60; event will be sent when the files are updated or a &#x60;template_error&#x60; event will be sent if there was a problem while updating the files. If a callback handler has been configured and the event has not been received within 60 minutes of making the call, check the status of the request in the API dashboard and retry the request if necessary. If the page orientation or page count is different from the original template document, we will notify you with a &#x60;template_error&#x60; [callback event](app.hellosign.com/api/eventsAndCallbacksWalkthrough).

Parameters:

  • template_id (String)

    The ID of the template whose files to update.

  • template_update_files_request (TemplateUpdateFilesRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateUpdateFilesResponse, Integer, Hash)>)

    TemplateUpdateFilesResponse data, response status code and response headers



1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
# File 'lib/dropbox-sign/api/template_api.rb', line 1051

def template_update_files_with_http_info(template_id, template_update_files_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.template_update_files ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateApi.template_update_files"
  end
  # verify the required parameter 'template_update_files_request' is set
  if @api_client.config.client_side_validation && template_update_files_request.nil?
    fail ArgumentError, "Missing the required parameter 'template_update_files_request' when calling TemplateApi.template_update_files"
  end
  # resource path
  local_var_path = '/template/update_files/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json', 'multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  post_body = {}
  form_params = opts[:form_params] || {}
  result = @api_client.generate_form_data(
    template_update_files_request,
    Dropbox::Sign::TemplateUpdateFilesRequest.openapi_types
  )

  # form parameters
  if result[:has_file]
    form_params = opts[:form_params] || result[:params]
    header_params['Content-Type'] = 'multipart/form-data'
  else
    # http body (model)
    post_body = opts[:debug_body] || result[:params]
  end

  # return_type
  return_type = opts[:debug_return_type] || 'TemplateUpdateFilesResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'oauth2']

  new_options = opts.merge(
    :operation => :"TemplateApi.template_update_files",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  begin
    data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  rescue Dropbox::Sign::ApiError => e
    if e.code === 200
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::TemplateUpdateFilesResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

    range_code = "4XX".split('').first
    range_code_left = "#{range_code}00".to_i
    range_code_right = "#{range_code}99".to_i
    if e.code >= range_code_left && e.code <= range_code_right
      body = @api_client.convert_to_type(
        JSON.parse("[#{e.response_body}]", :symbolize_names => true)[0],
        "Dropbox::Sign::ErrorResponse"
      )

      fail ApiError.new(:code => e.code,
                        :response_headers => e.response_headers,
                        :response_body => body),
           e.message
    end

  end

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#template_update_files\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end