kooaba 0.0.1 → 0.0.2
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.
- data/README.md +8 -8
- data/examples/query.rb +2 -2
- data/examples/upload.rb +3 -3
- data/lib/kooaba/base.rb +4 -4
- data/lib/kooaba/upload_request.rb +1 -1
- data/lib/kooaba/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -17,24 +17,24 @@ This is a lightweight gem (no other dependencies) for accessing the [kooaba APIs
|
|
17
17
|
|
18
18
|
## Uploading an item
|
19
19
|
|
20
|
-
In order to upload items into your account, you need
|
20
|
+
In order to upload items into your account, you need a `data-key` and a `bucket-id`. The `data-key` you can find on your account on the [kooaba platform](https://platform.kooaba.com), under API Access -> Data API Keys. You need to use the `secret-token` string. The bucket id you find under the Reference Items section.
|
21
21
|
|
22
22
|
require 'rubygems'
|
23
23
|
require 'kooaba'
|
24
24
|
|
25
|
-
# set the
|
26
|
-
Kooaba.
|
25
|
+
# set the data key
|
26
|
+
Kooaba.data_key = <data-key-secret-token>
|
27
27
|
|
28
28
|
# initialize the item
|
29
29
|
item = Kooaba::Item.new(
|
30
30
|
:title => "A lake",
|
31
31
|
:metadata => nil,
|
32
|
-
:image_files => <
|
32
|
+
:image_files => <path-to-image-on-local-filesystem>,
|
33
33
|
:referenceId => "lake"
|
34
34
|
)
|
35
35
|
|
36
36
|
# select the bucket you want to put the item into
|
37
|
-
bucket_id = <
|
37
|
+
bucket_id = <bucket-id>
|
38
38
|
|
39
39
|
# upload the item
|
40
40
|
response = Kooaba.upload(item, bucket_id)
|
@@ -52,16 +52,16 @@ The reponse will look like:
|
|
52
52
|
|
53
53
|
## Making a query
|
54
54
|
|
55
|
-
To make a query you need a
|
55
|
+
To make a query you need a `query-key` which you can find under the API Access -> Query API Keys section in your [kooaba account](https://platform.kooaba.com). You need to use the `secret-token` string.
|
56
56
|
|
57
57
|
require 'rubygems'
|
58
58
|
require 'kooaba'
|
59
59
|
|
60
60
|
# set the query key
|
61
|
-
Kooaba.query_key = <
|
61
|
+
Kooaba.query_key = <query-key-secret-token>
|
62
62
|
|
63
63
|
# send the query to the kooaba servers
|
64
|
-
query = Kooaba::Query.new(:image_path => <
|
64
|
+
query = Kooaba::Query.new(:image_path => <path-to-query-image-on-local-filesystem>)
|
65
65
|
response = Kooaba.query(query)
|
66
66
|
|
67
67
|
# inspect the result
|
data/examples/query.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "..", "lib", "kooaba.rb")
|
2
2
|
|
3
3
|
# set the query key
|
4
|
-
Kooaba.query_key = <
|
4
|
+
Kooaba.query_key = <query-key-secret-token>
|
5
5
|
|
6
6
|
# send the query to the kooaba servers
|
7
|
-
query = Kooaba::Query.new(:image_path => <
|
7
|
+
query = Kooaba::Query.new(:image_path => <path-to-image>)
|
8
8
|
response = Kooaba.query(query)
|
9
9
|
|
10
10
|
# inspect the result
|
data/examples/upload.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "..", "lib", "kooaba.rb")
|
2
2
|
|
3
|
-
# set the
|
4
|
-
Kooaba.
|
3
|
+
# set the data key
|
4
|
+
Kooaba.data_key = <data-key-secret-token>
|
5
5
|
|
6
6
|
# initialize the item
|
7
7
|
item = Kooaba::Item.new(
|
8
8
|
:title => "A lake",
|
9
9
|
:metadata => nil,
|
10
|
-
:image_files => <
|
10
|
+
:image_files => <path-to-image-on-local-filesystem>,
|
11
11
|
:referenceId => "lake"
|
12
12
|
)
|
13
13
|
|
data/lib/kooaba/base.rb
CHANGED
@@ -2,16 +2,16 @@ module Kooaba
|
|
2
2
|
QUERY_URL = "https://query-api.kooaba.com/v4/"
|
3
3
|
UPLOAD_URL = "https://upload-api.kooaba.com/api/v4/"
|
4
4
|
|
5
|
-
def self.
|
6
|
-
@@
|
5
|
+
def self.data_key=(data_key)
|
6
|
+
@@data_key = data_key
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.query_key=(query_key)
|
10
10
|
@@query_key = query_key
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.
|
14
|
-
@@
|
13
|
+
def self.data_key
|
14
|
+
@@data_key
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.query_key
|
@@ -39,7 +39,7 @@ module Kooaba
|
|
39
39
|
req.body = @message.body
|
40
40
|
req['date'] = Time.new.httpdate
|
41
41
|
req['content-type'] = @message.content_type
|
42
|
-
req['authorization'] = "Token #{Kooaba.
|
42
|
+
req['authorization'] = "Token #{Kooaba.data_key}"
|
43
43
|
|
44
44
|
http.start { |h| h.request(req) }
|
45
45
|
end
|
data/lib/kooaba/version.rb
CHANGED
metadata
CHANGED