Skip to content

Commit 598faef

Browse files
committed
refactor(VisualRecognitionV4): convert collection ids and features to comma separated string
1 parent abe6d29 commit 598faef

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

lib/ibm_watson/visual_recognition_v4.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ def analyze(collection_ids:, features:, images_file: nil, image_url: nil, thresh
115115

116116
form_data = {}
117117

118+
collection_ids *= "," unless collection_ids.nil?
119+
features *= "," unless features.nil?
120+
118121
form_data[:collection_ids] = HTTP::FormData::Part.new(collection_ids.to_s, content_type: "text/plain")
119122

120123
form_data[:features] = HTTP::FormData::Part.new(features.to_s, content_type: "text/plain")

test/integration/test_visual_recognition_v4.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def test_analyze
4343
"content_type": "image/jpeg"
4444
}
4545
],
46-
collection_ids: @collection_id,
47-
features: "objects"
46+
collection_ids: [@collection_id],
47+
features: ["objects"]
4848
).result
4949
assert_equal(2, result["images"].length)
5050
refute(result.nil?)

test/unit/test_visual_recognition_v4.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def test_analyze
3131
"content_type": "image/jpeg"
3232
}
3333
],
34-
collection_ids: "collid",
35-
features: "animal"
34+
collection_ids: ["collid"],
35+
features: ["animal"]
3636
)
3737
end
3838

@@ -53,8 +53,8 @@ def test_analyze_url
5353
image_url: [
5454
"www.somethingfunny.com"
5555
],
56-
collection_ids: "collid",
57-
features: "animal"
56+
collection_ids: ["collid"],
57+
features: ["animal"]
5858
)
5959
end
6060

0 commit comments

Comments
 (0)