kinetic_sdk 5.0.13 → 5.0.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bd5047435e78a51884c4b0b9a9766e273637fe9e31134fda839ebd4b5c9f939
4
- data.tar.gz: a22fb82511b3670bb86931fd0a57cea9ef91adc7ec4d0780f6f3c5f151a84eb6
3
+ metadata.gz: dfcd66e7c8773a12f2b7ddf6cf6cab0dd122c1e435ed0022a8061dc53e9a5391
4
+ data.tar.gz: 5cc5b32609b8ebb40129bc66cd0a28a4168b63820a61e76541d9382c899b30f3
5
5
  SHA512:
6
- metadata.gz: ea4237e58c4e40ee2b6c154efbec23d467a93d9ea83c0d0a798a53d987336c1fc9832ada3ea75527a74605ed36985f4e644876a345b4610cb74dd69d5574c971
7
- data.tar.gz: b0901ed2b02c428e70eebaa6a260b16ca7f2f47aca26d020bdb79ab87de0f7e73205279a01bf9caba85b8b3f65e64662745247ae461ab29f2abddf2a91043e3d
6
+ metadata.gz: 2a5dee48734bee20e4b7e28217d0e9ecb4ffb862e87cb5528957580845224326b4e3bef7d6479075c96c95a604acc325c0ef434ed1dfd11ed4d058a34a8e2885
7
+ data.tar.gz: bf57bcac5081d6dc31cf828564e58ec899d54fcbf3c8a118ab3a4064117440a5f0ac3b69d2cf9552624079e3bf732889fbe66dc00ea694e8dd2f5e2acc698e43
data/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Change Log
2
2
 
3
+ ## [5.0.18](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.18) (2021-03-25)
4
+
5
+ **Implemented enhancements:**
6
+
7
+ - Implemented method to enable searching for users against the system api (find_users_in_system)
8
+
9
+ ## [5.0.17](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.17) (2021-02-25)
10
+
11
+ **Implemented enhancements:**
12
+
13
+ - Bug fix related to removing user from a team
14
+
15
+
16
+ ## [5.0.16](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.16) (2021-02-25)
17
+
18
+ **Implemented enhancements:**
19
+
20
+ - Implmented ability to remove user from a team
21
+
22
+ ## [5.0.15](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.15) (2021-01-20)
23
+
24
+ **Implemented enhancements:**
25
+
26
+ - Bug Fixes
27
+
28
+ ## [5.0.14](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.14) (2021-01-15)
29
+
30
+ **Implemented enhancements:**
31
+
32
+ - Support for submitting attachments (datastore and form submissions)
33
+ - Bug Fixes
34
+
3
35
  ## [5.0.13](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.13) (2020-09-03)
4
36
 
5
37
  **Implemented enhancements:**
@@ -64,7 +64,6 @@ module KineticSdk
64
64
 
65
65
  # Add Bridge to Space
66
66
  #
67
- # @param space [String] slug of the space
68
67
  # @param body [Hash] properties associated to the Bridge
69
68
  # - +space+
70
69
  # - +adapterClass+
@@ -64,7 +64,6 @@ module KineticSdk
64
64
 
65
65
  # Add Filestore to Space
66
66
  #
67
- # @param space [String] slug of the space
68
67
  # @param body [Hash] properties associated to the Filestore
69
68
  # - +space+
70
69
  # - +adapterClass+
@@ -64,7 +64,6 @@ module KineticSdk
64
64
 
65
65
  # Add Handler to Space
66
66
  #
67
- # @param space [String] slug of the space
68
67
  # @param body [Hash] properties associated to the Handler
69
68
  # - +space+
70
69
  # - +definitionId+
@@ -8,15 +8,16 @@ module KineticSdk
8
8
  # - +origin+ - Origin ID of the submission to be added
9
9
  # - +parent+ - Parent ID of the submission to be added
10
10
  # - +values+ - hash of field values for the submission
11
+ # - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
11
12
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
12
13
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
13
14
  def add_datastore_submission(form_slug, payload={}, headers=default_headers)
14
- # initialize "values" if nil
15
- payload["values"] = {} if payload["values"].nil?
16
15
  # set origin hash if origin was passed as a string
17
16
  payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
18
17
  # set parent hash if parent was passed as a string
19
18
  payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
19
+ # prepare any attachment values
20
+ payload["values"] = prepare_new_datastore_submission_values(form_slug, payload["values"])
20
21
  # Create the submission
21
22
  @logger.info("Adding a submission in the \"#{form_slug}\" Datastore Form.")
22
23
  post("#{@api_url}/datastore/forms/#{form_slug}/submissions", payload, headers)
@@ -30,15 +31,16 @@ module KineticSdk
30
31
  # - +origin+ - Origin ID of the submission to be added
31
32
  # - +parent+ - Parent ID of the submission to be added
32
33
  # - +values+ - hash of field values for the submission
34
+ # - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
33
35
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
34
36
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
35
37
  def add_datastore_submission_page(form_slug, page_name, payload={}, headers=default_headers)
36
- # initialize "values" if nil
37
- payload["values"] = {} if payload["values"].nil?
38
38
  # set origin hash if origin was passed as a string
39
39
  payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
40
40
  # set parent hash if parent was passed as a string
41
41
  payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
42
+ # prepare any attachment values
43
+ payload["values"] = prepare_new_datastore_submission_values(form_slug, payload["values"])
42
44
  # Create the submission
43
45
  @logger.info("Adding a submission page in the \"#{form_slug}\" Datastore Form.")
44
46
  post("#{@api_url}/datastore/forms/#{form_slug}/submissions?page=#{encode(page_name)}", payload, headers)
@@ -51,22 +53,47 @@ module KineticSdk
51
53
  # - +origin+ - Origin ID of the submission to be patched
52
54
  # - +parent+ - Parent ID of the submission to be patched
53
55
  # - +values+ - hash of field values for the submission
56
+ # - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
54
57
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
55
58
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
56
59
  def patch_datastore_submission(form_slug, payload={}, headers=default_headers)
57
60
  # set the currentPage hash if currentPage was passed as a string
58
61
  payload["currentPage"] = { "name" => payload["currentPage"] } if payload["currentPage"].is_a? String
59
- # initialize "values" if nil
60
- payload["values"] = {} if payload["values"].nil?
61
62
  # set origin hash if origin was passed as a string
62
63
  payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
63
64
  # set parent hash if parent was passed as a string
64
65
  payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
66
+ # prepare any attachment values
67
+ payload["values"] = prepare_new_datastore_submission_values(form_slug, payload["values"])
65
68
  # Create the submission
66
69
  @logger.info("Patching a submission in the \"#{form_slug}\" Form.")
67
70
  patch("#{@api_url}/datastore/forms/#{form_slug}/submissions", payload, headers)
68
71
  end
69
72
 
73
+ # Patch an existing Datastore Submission
74
+ #
75
+ # @param submission_id [String] id of the Submission
76
+ # @param payload [Hash] payload of the submission
77
+ # - +origin+ - Origin ID of the submission to be patched
78
+ # - +parent+ - Parent ID of the submission to be patched
79
+ # - +values+ - hash of field values for the submission
80
+ # - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
81
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
82
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
83
+ def patch_existing_datastore_submission(submission_id, payload={}, headers=default_headers)
84
+ # set the currentPage hash if currentPage was passed as a string
85
+ payload["currentPage"] = { "name" => payload["currentPage"] } if payload["currentPage"].is_a? String
86
+ # set origin hash if origin was passed as a string
87
+ payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
88
+ # set parent hash if parent was passed as a string
89
+ payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
90
+ # prepare any attachment values
91
+ payload["values"] = prepare_updated_datastore_submission_values(submission_id, payload["values"])
92
+ # Update the submission
93
+ @logger.info("Patching a submission with id \"#{submission_id}\"")
94
+ patch("#{@api_url}/datastore/submissions/#{submission_id}", payload, headers)
95
+ end
96
+
70
97
  # Find all Submissions for a Datastore Form.
71
98
  #
72
99
  # This method will process pages of form submissions and internally
@@ -164,5 +191,27 @@ module KineticSdk
164
191
  delete("#{@api_url}/datastore/submissions/#{encode(submission_id)}", headers)
165
192
  end
166
193
 
194
+ private
195
+
196
+ # Prepares new datastore submission values for attachment fields
197
+ #
198
+ # @param form_slug [String] datastore form slug
199
+ # @param values [Hash] hash of values being submitted
200
+ # @return [Hash] hash of values with attachment paths replaced with uploaded file information
201
+ def prepare_new_datastore_submission_values(form_slug, values)
202
+ file_upload_url = "#{@api_url.gsub('/api/v1','')}/datastore/forms/#{form_slug}/files"
203
+ prepare_submission_values(values, file_upload_url)
204
+ end
205
+
206
+ # Prepares updated datastore submission values for attachment fields
207
+ #
208
+ # @param submission_id [String] id of the Submission
209
+ # @param values [Hash] hash of values being submitted
210
+ # @return [Hash] hash of values with attachment paths replaced with uploaded file information
211
+ def prepare_updated_datastore_submission_values(submission_id, values)
212
+ file_upload_url = "#{@api_url.gsub('/api/v1','')}/datastore/submissions/#{submission_id}/files"
213
+ prepare_submission_values(values, file_upload_url)
214
+ end
215
+
167
216
  end
168
217
  end
@@ -79,7 +79,6 @@ module KineticSdk
79
79
  # Delete Agent Component
80
80
  #
81
81
  # @param agent_slug [String] the slug of the agent to retrieve
82
- # @param params [Hash] Query parameters that are added to the URL, such as +include+
83
82
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
84
83
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
85
84
  def delete_agent_component(agent_slug, headers = default_headers)
@@ -9,18 +9,19 @@ module KineticSdk
9
9
  # - +origin+ - Origin ID of the submission to be added
10
10
  # - +parent+ - Parent ID of the submission to be added
11
11
  # - +values+ - hash of field values for the submission
12
+ # - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
12
13
  # @param parameters [Hash] hash of query parameters to append to the URL
13
14
  # - +include+ - comma-separated list of properties to include in the response
14
15
  # - +completed+ - signals that the submission should be completed, default is false
15
16
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
16
17
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
17
18
  def add_submission(kapp_slug, form_slug, payload={}, parameters={}, headers=default_headers)
18
- # initialize "values" if nil
19
- payload["values"] = {} if payload["values"].nil?
20
19
  # set origin hash if origin was passed as a string
21
20
  payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
22
21
  # set parent hash if parent was passed as a string
23
22
  payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
23
+ # prepare any attachment values
24
+ payload["values"] = prepare_new_submission_values(kapp_slug, form_slug, payload["values"])
24
25
  # build the uri with the encoded parameters
25
26
  uri = URI.parse("#{@api_url}/kapps/#{kapp_slug}/forms/#{form_slug}/submissions")
26
27
  uri.query = URI.encode_www_form(parameters) unless parameters.empty?
@@ -38,6 +39,7 @@ module KineticSdk
38
39
  # - +origin+ - Origin ID of the submission to be added
39
40
  # - +parent+ - Parent ID of the submission to be added
40
41
  # - +values+ - hash of field values for the submission
42
+ # - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
41
43
  # @param parameters [Hash] hash of query parameters to append to the URL
42
44
  # - +include+ - comma-separated list of properties to include in the response
43
45
  # - +staged+ - Indicates whether field validations and page advancement should occur, default is false
@@ -45,12 +47,12 @@ module KineticSdk
45
47
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
46
48
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
47
49
  def add_submission_page(kapp_slug, form_slug, page_name, payload={}, parameters={}, headers=default_headers)
48
- # initialize "values" if nil
49
- payload["values"] = {} if payload["values"].nil?
50
50
  # set origin hash if origin was passed as a string
51
51
  payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
52
52
  # set parent hash if parent was passed as a string
53
53
  payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
54
+ # prepare any attachment values
55
+ payload["values"] = prepare_new_submission_values(kapp_slug, form_slug, payload["values"])
54
56
  # add the page name to the parameters
55
57
  parameters["page"] = page_name
56
58
  # build the uri with the encoded parameters
@@ -69,17 +71,18 @@ module KineticSdk
69
71
  # - +origin+ - Origin ID of the submission to be patched
70
72
  # - +parent+ - Parent ID of the submission to be patched
71
73
  # - +values+ - hash of field values for the submission
74
+ # - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
72
75
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
73
76
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
74
77
  def patch_new_submission(kapp_slug, form_slug, payload={}, headers=default_headers)
75
78
  # set the currentPage hash if currentPage was passed as a string
76
79
  payload["currentPage"] = { "name" => payload["currentPage"] } if payload["currentPage"].is_a? String
77
- # initialize "values" if nil
78
- payload["values"] = {} if payload["values"].nil?
79
80
  # set origin hash if origin was passed as a string
80
81
  payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
81
82
  # set parent hash if parent was passed as a string
82
83
  payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
84
+ # prepare any attachment values
85
+ payload["values"] = prepare_new_submission_values(kapp_slug, form_slug, payload["values"])
83
86
  # Create the submission
84
87
  @logger.info("Patching a submission in the \"#{form_slug}\" Form.")
85
88
  patch("#{@api_url}/kapps/#{kapp_slug}/forms/#{form_slug}/submissions", payload, headers)
@@ -92,17 +95,18 @@ module KineticSdk
92
95
  # - +origin+ - Origin ID of the submission to be patched
93
96
  # - +parent+ - Parent ID of the submission to be patched
94
97
  # - +values+ - hash of field values for the submission
98
+ # - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
95
99
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
96
100
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
97
101
  def patch_existing_submission(submission_id, payload={}, headers=default_headers)
98
102
  # set the currentPage hash if currentPage was passed as a string
99
103
  payload["currentPage"] = { "name" => payload["currentPage"] } if payload["currentPage"].is_a? String
100
- # initialize "values" if nil
101
- payload["values"] = {} if payload["values"].nil?
102
104
  # set origin hash if origin was passed as a string
103
105
  payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
104
106
  # set parent hash if parent was passed as a string
105
107
  payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
108
+ # prepare any attachment values
109
+ payload["values"] = prepare_updated_submission_values(submission_id, payload["values"])
106
110
  # Create the submission
107
111
  @logger.info("Patching a submission with id \"#{submission_id}\"")
108
112
  patch("#{@api_url}/submissions/#{submission_id}", payload, headers)
@@ -211,5 +215,59 @@ module KineticSdk
211
215
  put("#{@api_url}/submissions/#{encode(submission_id)}", body, headers)
212
216
  end
213
217
 
218
+ private
219
+
220
+ # Prepares new submission values for attachment fields
221
+ #
222
+ # @param kapp_slug [String] kapp slug
223
+ # @param form_slug [String] form slug
224
+ # @param values [Hash] hash of values being submitted
225
+ # @return [Hash] hash of values with attachment paths replaced with uploaded file information
226
+ def prepare_new_submission_values(kapp_slug, form_slug, values)
227
+ file_upload_url = "#{@api_url.gsub('/app/api/v1','')}/#{kapp_slug}/#{form_slug}/files"
228
+ prepare_submission_values(values, file_upload_url)
229
+ end
230
+
231
+ # Prepares updated submission values for attachment fields
232
+ #
233
+ # @param submission_id [String] id of the Submission
234
+ # @param values [Hash] hash of values being submitted
235
+ # @return [Hash] hash of values with attachment paths replaced with uploaded file information
236
+ def prepare_updated_submission_values(submission_id, values)
237
+ file_upload_url = "#{@api_url.gsub('/app/api/v1','')}/submissions/#{submission_id}/files"
238
+ prepare_submission_values(values, file_upload_url)
239
+ end
240
+
241
+ # Prepares submission values for attachment fields
242
+ #
243
+ # @param values [Hash] hash of values being submitted
244
+ # @param file_upload_url [String] url to post attachments
245
+ # @return [Hash] hash of values with attachment paths replaced with uploaded file information
246
+ def prepare_submission_values(values, file_upload_url)
247
+ # initialize the values
248
+ values = {} if values.nil?
249
+ # handle attachment values
250
+ values.each do |field, value|
251
+ # if the value contains an array of files
252
+ if value.is_a?(Array) && !value.empty? && value.first.is_a?(Hash) && value.first.has_key?('path')
253
+ value.each_with_index do |file, index|
254
+ # upload the file to the server
255
+ file_upload_response = post_multipart(
256
+ file_upload_url,
257
+ { "package" => File.new(file['path']) },
258
+ default_headers)
259
+ # update the value with the file upload response
260
+ if file_upload_response.status == 200
261
+ values[field][index] = file_upload_response.content.first
262
+ else
263
+ raise "Attachment file upload failed: (#{file_upload_response.status}) #{file_upload_response.content_string}"
264
+ end
265
+ end
266
+ end
267
+ end
268
+ # return the values
269
+ values
270
+ end
271
+
214
272
  end
215
273
  end
@@ -73,6 +73,18 @@ module KineticSdk
73
73
  post("#{@api_url}/memberships/", body, headers)
74
74
  end
75
75
 
76
+ # remove a team membership
77
+ #
78
+ # @param team_name [String] the team name
79
+ # @param username [String] the username to remove to the team
80
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
81
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
82
+ def remove_team_membership(team_name, username, headers=default_headers)
83
+ team_slug = Digest::MD5.hexdigest(team_name)
84
+ @logger.info("Removing user: \"#{username}\" from \"#{team_name}\" team")
85
+ delete("#{@api_url}/memberships/#{team_slug}_#{username}", headers)
86
+ end
87
+
76
88
  # Find teams
77
89
  #
78
90
  # @param params [Hash] Query parameters that are added to the URL, such as +include+
@@ -166,10 +166,21 @@ module KineticSdk
166
166
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
167
167
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
168
168
  def find_users(params={}, headers=default_headers)
169
- @logger.info("Finding Users \"#{username}\"")
169
+ @logger.info("Finding Users")
170
170
  get("#{@api_url}/users", params, headers)
171
171
  end
172
172
 
173
+ # Find all users with the system api
174
+ #
175
+ # @param space_slug [String] slug of the space to find users in when using the system api
176
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
177
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
178
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
179
+ def find_users_in_system(space_slug, params={}, headers=default_headers)
180
+ @logger.info("Finding Users")
181
+ get("#{@api_url}/spaces/#{space_slug}/users", params, headers)
182
+ end
183
+
173
184
  # Find the user
174
185
  #
175
186
  # @param username [String] username of the user
@@ -49,7 +49,7 @@ module KineticSdk
49
49
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
50
50
  def delete_sources(headers=header_basic_auth)
51
51
  @logger.info("Deleting all sources")
52
- (find_sources(headers).content['sources'] || []).each do |source|
52
+ (find_sources(headers).content["sourceRoots"] || []).each do |source|
53
53
  delete("#{@api_url}/sources/#{encode(source['name'])}", headers)
54
54
  end
55
55
  end
@@ -424,13 +424,11 @@ module KineticSdk
424
424
  # prepare the payload
425
425
  payload = data.inject({}) do |h,(k,v)|
426
426
  if v.class == File
427
- h[k] = UploadIO.new(v, mimetype(v), File.basename(v))
427
+ h[k] = UploadIO.new(v, mimetype(v).first, File.basename(v))
428
428
  elsif v.class == Array
429
- # f = v.first
430
- # h[k] = UploadIO.new(f, mimetype(f), File.basename(f)) unless f.nil?
431
429
  h[k] = v.inject([]) do |files, part|
432
430
  if part.class == File
433
- files << UploadIO.new(part, mimetype(part), File.basename(part))
431
+ files << UploadIO.new(part, mimetype(part).first, File.basename(part))
434
432
  end
435
433
  end
436
434
  else
@@ -634,9 +632,9 @@ module KineticSdk
634
632
  # @option http_options [Fixnum] :max_redirects optional - max number of times to redirect
635
633
  # @option http_options [Fixnum] :gateway_retry_limit optional - max number of times to retry a bad gateway
636
634
  # @option http_options [Float] :gateway_retry_delay optional - number of seconds to delay before retrying a bad gateway
637
- def stream_download_to_file(file_path, url, params={}, headers={}, http_options=@http_options)
635
+ def stream_download_to_file(file_path, url, params={}, headers={}, http_options=@options)
638
636
  # Determine if redirection is involved
639
- url = redirect_url(url, params, headers, max_redirects)
637
+ url = redirect_url(url, params, headers, http_options)
640
638
  # parse the URL
641
639
  uri = URI.parse(url)
642
640
 
@@ -645,15 +643,17 @@ module KineticSdk
645
643
  # build the http object
646
644
  http = build_http(uri)
647
645
 
648
- # stream the attachment
649
- file = File.open(file_path, "wb")
646
+ # prepare the download
647
+ file = nil
650
648
  file_name = File.basename(file_path)
651
649
  response_code = nil
652
650
  message = nil
653
651
  begin
652
+ # stream the attachment
654
653
  http.request_get(uri.request_uri, headers) do |response|
655
654
  response_code = response.code
656
655
  if response_code == "200"
656
+ file = File.open(file_path, "wb")
657
657
  response.read_body { |chunk| file.write(chunk) }
658
658
  else
659
659
  message = response.body
@@ -668,8 +668,9 @@ module KineticSdk
668
668
  rescue StandardError => e
669
669
  @logger.error("Failed to export file attachment \"#{file_name}\": (#{e})")
670
670
  ensure
671
- file.close()
671
+ file.close() unless file.nil?
672
672
  end
673
+ message
673
674
  end
674
675
 
675
676
 
@@ -3,5 +3,5 @@ module KineticSdk
3
3
  # Version of Kinetic SDK
4
4
  #
5
5
  # @return [String] Version of the SDK
6
- VERSION = "5.0.13"
6
+ VERSION = "5.0.18"
7
7
  end
metadata CHANGED
@@ -1,142 +1,142 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kinetic_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.13
4
+ version: 5.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kinetic Data
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-03 00:00:00.000000000 Z
11
+ date: 2021-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: slugify
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - '='
17
18
  - !ruby/object:Gem::Version
18
19
  version: 1.0.7
19
- name: slugify
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.0.7
27
27
  - !ruby/object:Gem::Dependency
28
+ name: multipart-post
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - '='
31
32
  - !ruby/object:Gem::Version
32
33
  version: 2.0.0
33
- name: multipart-post
34
- prerelease: false
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
+ name: mime-types
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - '='
45
46
  - !ruby/object:Gem::Version
46
47
  version: '3.1'
47
- name: mime-types
48
- prerelease: false
49
48
  type: :runtime
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.1'
55
55
  - !ruby/object:Gem::Dependency
56
+ name: parallel
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - '='
59
60
  - !ruby/object:Gem::Version
60
61
  version: 1.12.1
61
- name: parallel
62
- prerelease: false
63
62
  type: :runtime
63
+ prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.12.1
69
69
  - !ruby/object:Gem::Dependency
70
+ name: ruby-progressbar
70
71
  requirement: !ruby/object:Gem::Requirement
71
72
  requirements:
72
73
  - - '='
73
74
  - !ruby/object:Gem::Version
74
75
  version: 1.9.0
75
- name: ruby-progressbar
76
- prerelease: false
77
76
  type: :runtime
77
+ prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.9.0
83
83
  - !ruby/object:Gem::Dependency
84
+ name: kontena-websocket-client
84
85
  requirement: !ruby/object:Gem::Requirement
85
86
  requirements:
86
87
  - - '='
87
88
  - !ruby/object:Gem::Version
88
89
  version: 0.1.1
89
- name: kontena-websocket-client
90
- prerelease: false
91
90
  type: :development
91
+ prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.1.1
97
97
  - !ruby/object:Gem::Dependency
98
+ name: bundler
98
99
  requirement: !ruby/object:Gem::Requirement
99
100
  requirements:
100
101
  - - "~>"
101
102
  - !ruby/object:Gem::Version
102
103
  version: '1.17'
103
- name: bundler
104
- prerelease: false
105
104
  type: :development
105
+ prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.17'
111
111
  - !ruby/object:Gem::Dependency
112
+ name: rake
112
113
  requirement: !ruby/object:Gem::Requirement
113
114
  requirements:
114
115
  - - "~>"
115
116
  - !ruby/object:Gem::Version
116
117
  version: 13.0.1
117
- name: rake
118
- prerelease: false
119
118
  type: :development
119
+ prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 13.0.1
125
125
  - !ruby/object:Gem::Dependency
126
+ name: yard
126
127
  requirement: !ruby/object:Gem::Requirement
127
128
  requirements:
128
129
  - - "~>"
129
130
  - !ruby/object:Gem::Version
130
131
  version: 0.9.25
131
- name: yard
132
- prerelease: false
133
132
  type: :development
133
+ prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.9.25
139
- description:
139
+ description:
140
140
  email:
141
141
  - support@kineticdata.com
142
142
  executables:
@@ -408,7 +408,7 @@ homepage: https://github.com/kineticdata/kinetic-sdk-rb
408
408
  licenses: []
409
409
  metadata:
410
410
  yard.run: yri
411
- post_install_message:
411
+ post_install_message:
412
412
  rdoc_options: []
413
413
  require_paths:
414
414
  - lib
@@ -423,9 +423,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
423
423
  - !ruby/object:Gem::Version
424
424
  version: '0'
425
425
  requirements: []
426
- rubyforge_project:
427
- rubygems_version: 2.6.11
428
- signing_key:
426
+ rubygems_version: 3.0.3
427
+ signing_key:
429
428
  specification_version: 4
430
429
  summary: Ruby SDK for Kinetic Data application APIs
431
430
  test_files: []