form_api 1.6.0 → 1.7.0

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +21 -10
  5. data/docs/{CreateSubmissionDataBatchV1.md → CombinePdfsData.md} +4 -4
  6. data/docs/CombinedSubmission.md +1 -0
  7. data/docs/CreateCustomFileData.md +8 -0
  8. data/docs/CreateCustomFileResponse.md +10 -0
  9. data/docs/CreateTemplateData.md +8 -0
  10. data/docs/CustomFile.md +9 -0
  11. data/docs/PDFApi.md +208 -12
  12. data/docs/SubmissionBatchData.md +1 -1
  13. data/docs/{CreateSubmissionData.md → SubmissionData.md} +1 -1
  14. data/docs/{CreateSubmissionDataBatchRequest.md → SubmissionDataBatchRequest.md} +5 -5
  15. data/docs/Templatesv2Template.md +19 -0
  16. data/docs/Templatesv2TemplateDocument.md +10 -0
  17. data/docs/Templatesv2TemplateDocumentMetadata.md +10 -0
  18. data/lib/form_api.rb +10 -3
  19. data/lib/form_api/api/client.rb +25 -9
  20. data/lib/form_api/api/pdf_api.rb +224 -20
  21. data/lib/form_api/models/{create_submission_data_batch_request.rb → combine_pdfs_data.rb} +31 -43
  22. data/lib/form_api/models/combined_submission.rb +12 -1
  23. data/lib/form_api/models/create_custom_file_data.rb +188 -0
  24. data/lib/form_api/models/create_custom_file_response.rb +237 -0
  25. data/lib/form_api/models/create_template_data.rb +188 -0
  26. data/lib/form_api/models/custom_file.rb +192 -0
  27. data/lib/form_api/models/submission_batch_data.rb +1 -1
  28. data/lib/form_api/models/{create_submission_data.rb → submission_data.rb} +1 -1
  29. data/lib/form_api/models/{create_submission_data_batch_v1.rb → submission_data_batch_request.rb} +32 -28
  30. data/lib/form_api/models/templatesv2_template.rb +316 -0
  31. data/lib/form_api/models/templatesv2_template_document.rb +235 -0
  32. data/lib/form_api/models/templatesv2_template_document_metadata.rb +235 -0
  33. data/lib/form_api/version.rb +1 -1
  34. data/spec/api/client_integration_spec.rb +41 -4
  35. data/spec/api/pdf_api_integration_spec.rb +7 -7
  36. data/spec/api/pdf_api_spec_original.skipped.rb +55 -9
  37. data/spec/models/{create_submission_data_batch_v1_spec.rb → combine_pdfs_data_spec.rb} +10 -10
  38. data/spec/models/combined_submission_spec.rb +6 -0
  39. data/spec/models/create_custom_file_data_spec.rb +41 -0
  40. data/spec/models/create_custom_file_response_spec.rb +57 -0
  41. data/spec/models/create_template_data_spec.rb +41 -0
  42. data/spec/models/custom_file_spec.rb +47 -0
  43. data/spec/models/{create_submission_data_batch_request_spec.rb → submission_data_batch_request_spec.rb} +12 -12
  44. data/spec/models/{create_submission_data_spec.rb → submission_data_spec.rb} +6 -6
  45. data/spec/models/templatesv2_template_document_metadata_spec.rb +57 -0
  46. data/spec/models/templatesv2_template_document_spec.rb +57 -0
  47. data/spec/models/templatesv2_template_spec.rb +111 -0
  48. data/spec/spec_helper.rb +3 -0
  49. metadata +42 -14
@@ -0,0 +1,235 @@
1
+ =begin
2
+ #API v1
3
+
4
+ #FormAPI is a service that helps you fill out and sign PDF templates.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 3.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module FormAPI
16
+ class Templatesv2TemplateDocumentMetadata
17
+ attr_accessor :filename
18
+
19
+ attr_accessor :size
20
+
21
+ attr_accessor :mime_type
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'filename' => :'filename',
49
+ :'size' => :'size',
50
+ :'mime_type' => :'mime_type'
51
+ }
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'filename' => :'String',
58
+ :'size' => :'Integer',
59
+ :'mime_type' => :'String'
60
+ }
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ return unless attributes.is_a?(Hash)
67
+
68
+ # convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
70
+
71
+ if attributes.has_key?(:'filename')
72
+ self.filename = attributes[:'filename']
73
+ end
74
+
75
+ if attributes.has_key?(:'size')
76
+ self.size = attributes[:'size']
77
+ end
78
+
79
+ if attributes.has_key?(:'mime_type')
80
+ self.mime_type = attributes[:'mime_type']
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ invalid_properties
89
+ end
90
+
91
+ # Check to see if the all the properties in the model are valid
92
+ # @return true if the model is valid
93
+ def valid?
94
+ mime_type_validator = EnumAttributeValidator.new('String', ['application/pdf'])
95
+ return false unless mime_type_validator.valid?(@mime_type)
96
+ true
97
+ end
98
+
99
+ # Custom attribute writer method checking allowed values (enum).
100
+ # @param [Object] mime_type Object to be assigned
101
+ def mime_type=(mime_type)
102
+ validator = EnumAttributeValidator.new('String', ['application/pdf'])
103
+ unless validator.valid?(mime_type)
104
+ fail ArgumentError, 'invalid value for "mime_type", must be one of #{validator.allowable_values}.'
105
+ end
106
+ @mime_type = mime_type
107
+ end
108
+
109
+ # Checks equality by comparing each attribute.
110
+ # @param [Object] Object to be compared
111
+ def ==(o)
112
+ return true if self.equal?(o)
113
+ self.class == o.class &&
114
+ filename == o.filename &&
115
+ size == o.size &&
116
+ mime_type == o.mime_type
117
+ end
118
+
119
+ # @see the `==` method
120
+ # @param [Object] Object to be compared
121
+ def eql?(o)
122
+ self == o
123
+ end
124
+
125
+ # Calculates hash code according to all attributes.
126
+ # @return [Fixnum] Hash code
127
+ def hash
128
+ [filename, size, mime_type].hash
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def build_from_hash(attributes)
135
+ return nil unless attributes.is_a?(Hash)
136
+ self.class.openapi_types.each_pair do |key, type|
137
+ if type =~ /\AArray<(.*)>/i
138
+ # check to ensure the input is an array given that the the attribute
139
+ # is documented as an array but the input is not
140
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
141
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
142
+ end
143
+ elsif !attributes[self.class.attribute_map[key]].nil?
144
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
145
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
146
+ end
147
+
148
+ self
149
+ end
150
+
151
+ # Deserializes the data based on type
152
+ # @param string type Data type
153
+ # @param string value Value to be deserialized
154
+ # @return [Object] Deserialized data
155
+ def _deserialize(type, value)
156
+ case type.to_sym
157
+ when :DateTime
158
+ DateTime.parse(value)
159
+ when :Date
160
+ Date.parse(value)
161
+ when :String
162
+ value.to_s
163
+ when :Integer
164
+ value.to_i
165
+ when :Float
166
+ value.to_f
167
+ when :BOOLEAN
168
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
169
+ true
170
+ else
171
+ false
172
+ end
173
+ when :Object
174
+ # generic object (usually a Hash), return directly
175
+ value
176
+ when /\AArray<(?<inner_type>.+)>\z/
177
+ inner_type = Regexp.last_match[:inner_type]
178
+ value.map { |v| _deserialize(inner_type, v) }
179
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
180
+ k_type = Regexp.last_match[:k_type]
181
+ v_type = Regexp.last_match[:v_type]
182
+ {}.tap do |hash|
183
+ value.each do |k, v|
184
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
185
+ end
186
+ end
187
+ else # model
188
+ temp_model = FormAPI.const_get(type).new
189
+ temp_model.build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ next if value.nil?
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+ end
235
+ end
@@ -11,5 +11,5 @@ OpenAPI Generator version: 3.3.0-SNAPSHOT
11
11
  =end
12
12
 
13
13
  module FormAPI
14
- VERSION = '1.6.0'
14
+ VERSION = '1.7.0'
15
15
  end
@@ -6,7 +6,7 @@ describe FormAPI::Client do
6
6
  FormAPI.configure do |c|
7
7
  c.api_token_id = 'api_token123'
8
8
  c.api_token_secret = 'testsecret123'
9
- c.host = 'http://localhost:31337'
9
+ c.host = 'http://api.formapi.local:31337'
10
10
  end
11
11
  end
12
12
 
@@ -84,7 +84,7 @@ describe FormAPI::Client do
84
84
 
85
85
  expect(response.status).to eq 'success'
86
86
  batch = response.submission_batch
87
- expect(batch.id).to start_with 'sba_'
87
+ expect(batch.id).to start_with 'sbb_'
88
88
  expect(batch.state).to eq 'processed'
89
89
  expect(batch.total_count).to eq 2
90
90
  expect(batch.pending_count).to eq 0
@@ -137,7 +137,7 @@ describe FormAPI::Client do
137
137
 
138
138
  expect(response.status).to eq 'error'
139
139
  batch = response.submission_batch
140
- expect(batch.id).to start_with 'sba_'
140
+ expect(batch.id).to start_with 'sbb_'
141
141
  expect(batch.state).to eq 'error'
142
142
  expect(batch.total_count).to eq 2
143
143
  expect(batch.pending_count).to eq 0
@@ -158,7 +158,7 @@ describe FormAPI::Client do
158
158
  end
159
159
  end
160
160
 
161
- describe '#combine_submissions' do
161
+ describe '#combine_submissions with submission_ids' do
162
162
  it 'should merge multiple PDFs and wait for the job to be processed' do
163
163
  client = FormAPI::Client.new
164
164
  expect(client).to receive(:sleep).with(1).once
@@ -171,6 +171,13 @@ describe FormAPI::Client do
171
171
  expect(combined_submission.id).to start_with 'com_'
172
172
  expect(combined_submission.expired).to eq false
173
173
  expect(combined_submission.state).to eq 'processed'
174
+ expect(combined_submission.source_pdfs).to eq(
175
+ [
176
+ { type: 'submission', id: 'sub_000000000000000001' },
177
+ { type: 'submission', id: 'sub_000000000000000002' }
178
+ ]
179
+ )
180
+ # Backwards compatibility - We still set submission_ids
174
181
  expect(combined_submission.submission_ids).to eq(
175
182
  %w[sub_000000000000000001 sub_000000000000000002])
176
183
  expect(combined_submission.download_url).to include(
@@ -178,6 +185,36 @@ describe FormAPI::Client do
178
185
  end
179
186
  end
180
187
 
188
+ describe '#combine_pdfs with source_pdfs' do
189
+ it 'should merge multiple PDFs and wait for the job to be processed' do
190
+ client = FormAPI::Client.new
191
+ expect(client).to receive(:sleep).with(1).once
192
+
193
+ response = client.combine_pdfs(
194
+ source_pdfs: [
195
+ { type: 'submission', id: 'sub_000000000000000001' },
196
+ { type: 'template', id: 'tpl_000000000000000001' },
197
+ { type: 'submission', id: 'sub_000000000000000002' }
198
+ ]
199
+ )
200
+
201
+ expect(response.status).to eq 'success'
202
+ combined_submission = response.combined_submission
203
+ expect(combined_submission.id).to start_with 'com_'
204
+ expect(combined_submission.expired).to eq false
205
+ expect(combined_submission.state).to eq 'processed'
206
+ expect(combined_submission.source_pdfs).to eq(
207
+ [
208
+ { type: 'submission', id: 'sub_000000000000000001' },
209
+ { type: 'template', id: 'tpl_000000000000000001' },
210
+ { type: 'submission', id: 'sub_000000000000000002' }
211
+ ]
212
+ )
213
+ expect(combined_submission.download_url).to include(
214
+ 'combined_submissions/combined_submission.pdf')
215
+ end
216
+ end
217
+
181
218
  describe '#batch_generate_and_combine_pdfs' do
182
219
  it 'should submit a batch job and combine the PDFs into a single PDF' do
183
220
  client = FormAPI::Client.new
@@ -21,7 +21,7 @@ describe 'PDFApi' do
21
21
  FormAPI.configure do |c|
22
22
  c.api_token_id = 'api_token123'
23
23
  c.api_token_secret = 'testsecret123'
24
- c.host = 'http://localhost:31337'
24
+ c.host = 'http://api.formapi.local:31337'
25
25
  end
26
26
  end
27
27
 
@@ -89,7 +89,7 @@ describe 'PDFApi' do
89
89
  )
90
90
  expect(response.status).to eq 'success'
91
91
  batch = response.submission_batch
92
- expect(batch.id).to start_with 'sba_'
92
+ expect(batch.id).to start_with 'sbb_'
93
93
  expect(batch.state).to eq 'pending'
94
94
  expect(batch.total_count).to eq 2
95
95
  expect(batch.pending_count).to eq 2
@@ -108,9 +108,9 @@ describe 'PDFApi' do
108
108
 
109
109
  describe 'get_submission_batch test' do
110
110
  it 'should get the batch including submissions' do
111
- submission_batch_id = 'sba_000000000000000001'
111
+ submission_batch_id = 'sbb_000000000000000001'
112
112
  batch = api_instance.get_submission_batch(submission_batch_id, include_submissions: true)
113
- expect(batch.id).to eq 'sba_000000000000000001'
113
+ expect(batch.id).to eq 'sbb_000000000000000001'
114
114
  expect(batch.total_count).to eq 2
115
115
  expect(batch.pending_count).to eq 0
116
116
  expect(batch.completion_percentage).to eq 100
@@ -119,9 +119,9 @@ describe 'PDFApi' do
119
119
  end
120
120
 
121
121
  it 'should get the batch without submissions' do
122
- submission_batch_id = 'sba_000000000000000001'
122
+ submission_batch_id = 'sbb_000000000000000001'
123
123
  batch = api_instance.get_submission_batch(submission_batch_id)
124
- expect(batch.id).to eq 'sba_000000000000000001'
124
+ expect(batch.id).to eq 'sbb_000000000000000001'
125
125
  expect(batch.submissions).to be_nil
126
126
  end
127
127
  end
@@ -153,7 +153,7 @@ describe 'PDFApi' do
153
153
  expect(response.token.id).to_not be_nil
154
154
  expect(response.token.secret).to_not be_nil
155
155
  expect(response.token.data_request_url).to start_with \
156
- 'http://localhost/data_requests/drq_000000000000000001?token_id='
156
+ 'http://app.formapi.local/data_requests/drq_000000000000000001?token_id='
157
157
  expect(response.token.data_request_url).to include \
158
158
  "?token_id=#{response.token.id}" \
159
159
  "&token_secret=#{response.token.secret}"
@@ -21,7 +21,7 @@ describe 'PDFApi' do
21
21
  FormAPI.configure do |c|
22
22
  c.username = 'api_token123'
23
23
  c.password = 'testsecret123'
24
- c.host = 'localhost:31337'
24
+ c.host = 'api.formapi.local:31337'
25
25
  c.scheme = 'http'
26
26
  end
27
27
  end
@@ -41,14 +41,14 @@ describe 'PDFApi' do
41
41
  # integration tests for batch_generate_pdf_v1
42
42
  # Generates multiple PDFs
43
43
  # @param template_id
44
- # @param create_submission_data_batch_v1
44
+ # @param request_body
45
45
  # @param [Hash] opts the optional parameters
46
46
  # @return [Array<CreateSubmissionResponse>]
47
47
  describe 'batch_generate_pdf_v1 test' do
48
48
  it 'should work' do
49
49
  template_id = 'tpl_000000000000000001' # String |
50
- create_submission_data_batch_v1 = nil # Array<CreateSubmissionDataBatchV1> |
51
- result = api_instance.batch_generate_pdf_v1(template_id, create_submission_data_batch_v1)
50
+ request_body = nil # Array<Object> |
51
+ result = api_instance.batch_generate_pdf_v1(template_id, request_body)
52
52
  expect(result).to_not be_nil
53
53
  end
54
54
  end
@@ -64,6 +64,18 @@ describe 'PDFApi' do
64
64
  expect(result).to_not be_nil
65
65
  end
66
66
  end
67
+ # integration tests for combine_pdfs
68
+ # Merge submission PDFs, template PDFs, or custom files
69
+ # @param combine_pdfs_data
70
+ # @param [Hash] opts the optional parameters
71
+ # @return [CreateCombinedSubmissionResponse]
72
+ describe 'combine_pdfs test' do
73
+ it 'should work' do
74
+ combine_pdfs_data = FormAPI::CombinePdfsData.new # CombinePdfsData |
75
+ result = api_instance.combine_pdfs(combine_pdfs_data)
76
+ expect(result).to_not be_nil
77
+ end
78
+ end
67
79
  # integration tests for combine_submissions
68
80
  # Merge generated PDFs together
69
81
  # @param combined_submission_data
@@ -76,6 +88,18 @@ describe 'PDFApi' do
76
88
  expect(result).to_not be_nil
77
89
  end
78
90
  end
91
+ # integration tests for create_custom_file_from_upload
92
+ # Create a new custom file from a cached presign upload
93
+ # @param create_custom_file_data
94
+ # @param [Hash] opts the optional parameters
95
+ # @return [CreateCustomFileResponse]
96
+ describe 'create_custom_file_from_upload test' do
97
+ it 'should work' do
98
+ create_custom_file_data = FormAPI::CreateCustomFileData.new # CreateCustomFileData |
99
+ result = api_instance.create_custom_file_from_upload(create_custom_file_data)
100
+ expect(result).to_not be_nil
101
+ end
102
+ end
79
103
  # integration tests for create_data_request_token
80
104
  # Creates a new data request token for form authentication
81
105
  # @param data_request_id
@@ -89,7 +113,7 @@ describe 'PDFApi' do
89
113
  end
90
114
  end
91
115
  # integration tests for create_template
92
- # Upload a new PDF template
116
+ # Upload a new PDF template with a file upload
93
117
  # @param template_document
94
118
  # @param template_name
95
119
  # @param [Hash] opts the optional parameters
@@ -102,6 +126,18 @@ describe 'PDFApi' do
102
126
  expect(result).to_not be_nil
103
127
  end
104
128
  end
129
+ # integration tests for create_template_from_upload
130
+ # Create a new PDF template from a cached presign upload
131
+ # @param create_template_data
132
+ # @param [Hash] opts the optional parameters
133
+ # @return [PendingTemplate]
134
+ describe 'create_template_from_upload test' do
135
+ it 'should work' do
136
+ create_template_data = FormAPI::CreateTemplateData.new # CreateTemplateData |
137
+ result = api_instance.create_template_from_upload(create_template_data)
138
+ expect(result).to_not be_nil
139
+ end
140
+ end
105
141
  # integration tests for expire_combined_submission
106
142
  # Expire a combined submission
107
143
  # @param combined_submission_id
@@ -129,14 +165,14 @@ describe 'PDFApi' do
129
165
  # integration tests for generate_pdf
130
166
  # Generates a new PDF
131
167
  # @param template_id
132
- # @param create_submission_data
168
+ # @param submission_data
133
169
  # @param [Hash] opts the optional parameters
134
170
  # @return [CreateSubmissionResponse]
135
171
  describe 'generate_pdf test' do
136
172
  it 'should work' do
137
173
  template_id = 'tpl_000000000000000001' # String |
138
- create_submission_data = FormAPI::CreateSubmissionData.new # CreateSubmissionData |
139
- result = api_instance.generate_pdf(template_id, create_submission_data)
174
+ submission_data = FormAPI::SubmissionData.new # SubmissionData |
175
+ result = api_instance.generate_pdf(template_id, submission_data)
140
176
  expect(result).to_not be_nil
141
177
  end
142
178
  end
@@ -164,6 +200,16 @@ describe 'PDFApi' do
164
200
  expect(result).to_not be_nil
165
201
  end
166
202
  end
203
+ # integration tests for get_presign_url
204
+ # Get a presigned URL so that you can upload a file to our AWS S3 bucket
205
+ # @param [Hash] opts the optional parameters
206
+ # @return [Hash<String, Object>]
207
+ describe 'get_presign_url test' do
208
+ it 'should work' do
209
+ result = api_instance.get_presign_url
210
+ expect(result).to_not be_nil
211
+ end
212
+ end
167
213
  # integration tests for get_submission
168
214
  # Check the status of a PDF
169
215
  # @param submission_id
@@ -184,7 +230,7 @@ describe 'PDFApi' do
184
230
  # @return [SubmissionBatch]
185
231
  describe 'get_submission_batch test' do
186
232
  it 'should work' do
187
- submission_batch_id = 'sba_000000000000000001' # String |
233
+ submission_batch_id = 'sbb_000000000000000001' # String |
188
234
  opts = {
189
235
  include_submissions: true # BOOLEAN |
190
236
  }