artifacia 0.1 → 0.1.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 +13 -11
- data/artifacia.gemspec +1 -1
- data/lib/artifacia.rb +18 -14
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0a9d771635e85cd06644d9d778058cdd1a67eab
|
4
|
+
data.tar.gz: 28c4e3d47e5e5b7b8f57627381a2732d028e2d9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a9a5b651247e60d6c128002fb2ba612ede9ede834ab098307900ede364f0d4990a6a403345c7474608ee51b2b6cf2d63b5bdc469a0e95f34f8e7aab9fafc3e4
|
7
|
+
data.tar.gz: c0e6c4f1941cb54c2e330039299fdb2c9ad0470c19d2505ecabd1ebc7931ed8623c5da577255ac9f397351791275188c5d59d9c384e913abd8a885883031792f
|
data/README.md
CHANGED
@@ -2,23 +2,23 @@
|
|
2
2
|
|
3
3
|
This ruby client is a simple wrapper around our powerful Visual Discovery [API](http://docs.artifacia.com/).
|
4
4
|
|
5
|
-
The wrapper allows you to create your own
|
5
|
+
The wrapper allows you to create your own index of images on which you would like to enhance the product discovery experiences. It also allows you to get various types of recommendations which are listed below.
|
6
6
|
|
7
7
|
* Visual Recommendation
|
8
8
|
* Cross Product Recommendation
|
9
|
-
*
|
9
|
+
* Personalized Recommendation
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
13
|
To install the package you can follow the steps:-
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
|
16
|
+
[sudo] gem install artifacia
|
17
17
|
```
|
18
18
|
|
19
19
|
## Getting Started
|
20
20
|
|
21
|
-
The API is really easy and simple to use. First you need to
|
21
|
+
The API is really easy and simple to use. First you need to visit [this](http://www.artifacia.com/requestaccess/) page and request for username and password. Using that credentials you can create your constructor and get stated.
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
require 'artifacia'
|
@@ -28,21 +28,23 @@ client = Client.new(user_name, password)
|
|
28
28
|
```
|
29
29
|
|
30
30
|
### Creating your index
|
31
|
-
The first step is to create a index of the items that you would like to store in our databases to perform search against. If you don't have data ready right now you can quickly get started with our [sample data](). Once the data is stored and indexed we will inform you shortly.
|
31
|
+
The first step is to create a index of the items that you would like to store in our databases to perform search against. If you don't have data ready right now you can quickly get started with our [sample data](https://github.com/artifacia/artifacia-client-ruby/blob/master/sample_data.json). Once the data is stored and indexed we will inform you shortly.
|
32
32
|
|
33
|
-
```
|
34
|
-
|
35
|
-
sample_data = json.load(open("sample_data.json","rb"))
|
33
|
+
```ruby
|
34
|
+
sample_data = File.read("sample_data.json")
|
36
35
|
data_indexing_response = client.upload_item_data(sample_data)
|
37
|
-
|
36
|
+
puts data_indexing_response
|
38
37
|
```
|
39
38
|
|
40
39
|
### Performing Visual Recommendation
|
40
|
+
|
41
41
|
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.
|
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.
|
43
|
+
|
43
44
|
|
44
45
|
```ruby
|
45
46
|
sample_prod_id = 2761
|
46
|
-
|
47
|
+
num = 4
|
48
|
+
query_response = client.get_visual_recommendation(sample_prod_id, num)
|
47
49
|
puts query_response
|
48
50
|
```
|
data/artifacia.gemspec
CHANGED
data/lib/artifacia.rb
CHANGED
@@ -10,31 +10,35 @@ class Client
|
|
10
10
|
@host = 'api.artifacia.com'
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
@post_ws = "/v1/users"
|
15
|
-
@
|
13
|
+
def upload_user_purchased_items(user_id, data)
|
14
|
+
@post_ws = "/v1/users/#{user_id}/purchased_items"
|
15
|
+
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
16
|
+
req.basic_auth @user, @pass
|
17
|
+
req.body = data
|
18
|
+
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
19
|
+
return response.body
|
20
|
+
end
|
16
21
|
|
22
|
+
def upload_user_viewed_items(user_id, data)
|
23
|
+
@post_ws = "/v1/users/#{user_id}/viewed_items"
|
17
24
|
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
18
25
|
req.basic_auth @user, @pass
|
19
|
-
req.body =
|
26
|
+
req.body = data
|
20
27
|
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
21
28
|
return response.body
|
22
29
|
end
|
23
30
|
|
24
31
|
def upload_item_data(data)
|
25
32
|
@post_ws = "/v1/items"
|
26
|
-
@payload=data
|
27
|
-
|
28
33
|
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
29
34
|
req.basic_auth @user, @pass
|
30
|
-
req.body =
|
35
|
+
req.body = data
|
31
36
|
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
32
37
|
return response.body
|
33
38
|
end
|
34
39
|
|
35
40
|
def delete_item_data(item_ids)
|
36
41
|
@post_ws = "/v1/items"
|
37
|
-
|
38
42
|
req = Net::HTTP::Delete.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
39
43
|
req.basic_auth @user, @pass
|
40
44
|
req.body = item_ids
|
@@ -42,24 +46,24 @@ class Client
|
|
42
46
|
return response.body
|
43
47
|
end
|
44
48
|
|
45
|
-
def get_visual_recommendation(prod_id)
|
46
|
-
@post_ws = "/v1/recommendation/similar/#{prod_id}"
|
49
|
+
def get_visual_recommendation(prod_id, num)
|
50
|
+
@post_ws = "/v1/recommendation/similar/#{prod_id}/#{num}"
|
47
51
|
req = Net::HTTP::Get.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
48
52
|
req.basic_auth @user, @pass
|
49
53
|
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
50
54
|
return response.body
|
51
55
|
end
|
52
56
|
|
53
|
-
def get_cpr_recommendation(prod_id)
|
54
|
-
@post_ws = "/v1/recommendation/collections/#{prod_id}"
|
57
|
+
def get_cpr_recommendation(prod_id, num)
|
58
|
+
@post_ws = "/v1/recommendation/collections/#{prod_id}/#{num}"
|
55
59
|
req = Net::HTTP::Get.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
56
60
|
req.basic_auth @user, @pass
|
57
61
|
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
58
62
|
return response.body
|
59
63
|
end
|
60
64
|
|
61
|
-
def
|
62
|
-
@post_ws = "/v1/recommendation/user/#{
|
65
|
+
def get_personalized_recommendation(user_id, num)
|
66
|
+
@post_ws = "/v1/recommendation/user/#{user_id}/#{num}"
|
63
67
|
req = Net::HTTP::Get.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
64
68
|
req.basic_auth @user, @pass
|
65
69
|
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
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:
|
4
|
+
version: 0.1.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-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A ruby client to integrate visual recommendation feature from Artifacia
|
14
14
|
API
|
@@ -17,9 +17,9 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- lib/artifacia.rb
|
21
|
-
- artifacia.gemspec
|
22
20
|
- README.md
|
21
|
+
- artifacia.gemspec
|
22
|
+
- lib/artifacia.rb
|
23
23
|
homepage: https://github.com/artifacia/artifacia-client-ruby
|
24
24
|
licenses: []
|
25
25
|
metadata: {}
|
@@ -29,17 +29,17 @@ require_paths:
|
|
29
29
|
- lib
|
30
30
|
required_ruby_version: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
41
|
rubyforge_project:
|
42
|
-
rubygems_version: 2.
|
42
|
+
rubygems_version: 2.5.1
|
43
43
|
signing_key:
|
44
44
|
specification_version: 4
|
45
45
|
summary: Artifacia!
|