artifacia 0.1.2.1 → 0.1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/artifacia.gemspec +3 -3
- data/lib/artifacia.rb +14 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebbd4111b539a634d45c6e8a170d4845c9dd0b6f
|
4
|
+
data.tar.gz: 091102688677fe99e07fe232a9bacd7668cd6a7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6696f3d63cacd4c786cf5ea60c5dbb182c8cf9e40907fe8f0aa578cd4131a22c4eddb55aca591abc2cc6117b6cfca5c69a8686ce80156d28f3f1e228d3ce564e
|
7
|
+
data.tar.gz: ba6e4212bd4ad519738860df5f693e45702ce984fb049e70022987da4a679cfbe6766348d61d31b487bf4156a7bd68cdccf36f1c09133dad754dc9251f86ed69
|
data/README.md
CHANGED
@@ -22,9 +22,8 @@ The API is really easy and simple to use. First you need to visit [this](http://
|
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
require 'artifacia'
|
25
|
-
|
26
|
-
|
27
|
-
client = Client.new(user_name, password)
|
25
|
+
api_key = <api_key>
|
26
|
+
client = Client.new(api_key)
|
28
27
|
```
|
29
28
|
|
30
29
|
### Creating your index
|
@@ -39,12 +38,13 @@ puts data_indexing_response
|
|
39
38
|
### Performing Visual Recommendation
|
40
39
|
|
41
40
|
Once you receive a notification form us about the status of the indexed data, you are ready to search.
|
42
|
-
You can search for a product ID indexed in the sample data you inserted/uploaded. And also you can specify the number to results to be returned.
|
41
|
+
You can search for a product ID indexed in the sample data you inserted/uploaded. And also you can specify the number to results to be returned as well as you can set attribute if you want to prioritize the result on the basis of tags like color, material, pattern etc as given below.
|
43
42
|
|
44
43
|
|
45
44
|
```ruby
|
46
45
|
sample_prod_id = 2761
|
47
46
|
num = 4
|
48
|
-
|
47
|
+
filters = {"color" => 1, "pattern" => 1}
|
48
|
+
query_response = client.get_visual_recommendation(sample_prod_id, num, filters)
|
49
49
|
puts query_response
|
50
50
|
```
|
data/artifacia.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'artifacia'
|
3
|
-
s.version = '0.1.2.
|
3
|
+
s.version = '0.1.2.2'
|
4
4
|
s.date = Date.today
|
5
5
|
s.summary = "Artifacia!"
|
6
6
|
s.description = "A ruby client to integrate visual recommendation feature from Artifacia API"
|
7
7
|
s.authors = ["Ashish Kumar"]
|
8
8
|
s.email = 'erashish122@gmail.com'
|
9
9
|
s.files = [
|
10
|
-
"lib/artifacia.rb",
|
11
|
-
"artifacia.gemspec",
|
10
|
+
"lib/artifacia.rb",
|
11
|
+
"artifacia.gemspec",
|
12
12
|
"README.md"
|
13
13
|
]
|
14
14
|
s.homepage =
|
data/lib/artifacia.rb
CHANGED
@@ -3,9 +3,8 @@ require 'rubygems'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
class Client
|
6
|
-
def initialize(
|
7
|
-
@
|
8
|
-
@pass = password
|
6
|
+
def initialize(api_key)
|
7
|
+
@api_key = api_key
|
9
8
|
@host = 'api.artifacia.com'
|
10
9
|
@port = 443
|
11
10
|
@http = Net::HTTP.new(@host, @port)
|
@@ -15,16 +14,14 @@ class Client
|
|
15
14
|
|
16
15
|
def upload_user_purchased_items(user_id, data)
|
17
16
|
@post_ws = "/v1/users/#{user_id}/purchased_items"
|
18
|
-
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
19
|
-
req.basic_auth @user, @pass
|
17
|
+
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json', 'api_key' => @api_key})
|
20
18
|
response = @http.request(req)
|
21
19
|
return response.body
|
22
20
|
end
|
23
21
|
|
24
22
|
def upload_user_viewed_items(user_id, data)
|
25
23
|
@post_ws = "/v1/users/#{user_id}/viewed_items"
|
26
|
-
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
27
|
-
req.basic_auth @user, @pass
|
24
|
+
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json', 'api_key' => @api_key})
|
28
25
|
req.body = data
|
29
26
|
response = @http.request(req)
|
30
27
|
return response.body
|
@@ -32,8 +29,7 @@ class Client
|
|
32
29
|
|
33
30
|
def upload_item_data(data)
|
34
31
|
@post_ws = "/v1/items"
|
35
|
-
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
36
|
-
req.basic_auth @user, @pass
|
32
|
+
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json', 'api_key' => @api_key})
|
37
33
|
req.body = data
|
38
34
|
response = @http.request(req)
|
39
35
|
return response.body
|
@@ -41,33 +37,32 @@ class Client
|
|
41
37
|
|
42
38
|
def delete_item_data(item_ids)
|
43
39
|
@post_ws = "/v1/items"
|
44
|
-
req = Net::HTTP::Delete.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
45
|
-
req.basic_auth @user, @pass
|
40
|
+
req = Net::HTTP::Delete.new(@post_ws, initheader = {'Content-Type' =>'application/json', 'api_key' => @api_key})
|
46
41
|
req.body = item_ids
|
47
42
|
response = @http.request(req)
|
48
43
|
return response.body
|
49
44
|
end
|
50
45
|
|
51
|
-
def get_visual_recommendation(prod_id, num)
|
52
|
-
@post_ws = "/v1/recommendation/similar/#{prod_id}/#{num}"
|
53
|
-
|
54
|
-
|
46
|
+
def get_visual_recommendation(prod_id, num, filters)
|
47
|
+
@post_ws = "/v1/recommendation/similar/#{prod_id}/#{num}?"
|
48
|
+
filters.each do |key, value|
|
49
|
+
@post_ws = @post_ws+"#{key}=#{value}&"
|
50
|
+
|
51
|
+
req = Net::HTTP::Get.new(@post_ws, initheader = {'api_key' => @api_key})
|
55
52
|
response = @http.request(req)
|
56
53
|
return response.body
|
57
54
|
end
|
58
55
|
|
59
56
|
def get_cpr_recommendation(prod_id, num)
|
60
57
|
@post_ws = "/v1/recommendation/collections/#{prod_id}/#{num}"
|
61
|
-
req = Net::HTTP::Get.new(@post_ws)
|
62
|
-
req.basic_auth @user, @pass
|
58
|
+
req = Net::HTTP::Get.new(@post_ws, initheader = {'api_key' => @api_key})
|
63
59
|
response = @http.request(req)
|
64
60
|
return response.body
|
65
61
|
end
|
66
62
|
|
67
63
|
def get_personalized_recommendation(user_id, num)
|
68
64
|
@post_ws = "/v1/recommendation/user/#{user_id}/#{num}"
|
69
|
-
req = Net::HTTP::Get.new(@post_ws)
|
70
|
-
req.basic_auth @user, @pass
|
65
|
+
req = Net::HTTP::Get.new(@post_ws, initheader = {'api_key' => @api_key})
|
71
66
|
response = @http.request(req)
|
72
67
|
return response.body
|
73
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artifacia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.2.
|
4
|
+
version: 0.1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashish Kumar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A ruby client to integrate visual recommendation feature from Artifacia
|
14
14
|
API
|