artifacia 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +48 -0
- data/artifacia.gemspec +16 -0
- data/lib/artifacia.rb +68 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e593e72b1969b6b2813cfadde0a26564e0838df6
|
4
|
+
data.tar.gz: 2033b99eea0485cd06b55a2d5af1b9bd138f3c3e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6709d77515c3d26f4c5556977c8e8b68da6ee29e5beffc34382d11f41b756f717aafbb36a2fb13d24458fb9bea128e6fb7f874fa65692dc3066c2c4e0aa9b73
|
7
|
+
data.tar.gz: 6584752eaf3cfbd0486991858121a19109c66410cb63f287d8d99f07ddabd82b72cdbcf1decc2b3adb1a0035b2c7e1115f913f73154eb44eb0027fbb1a7b43a3
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Artifacia Ruby Client
|
2
|
+
|
3
|
+
This ruby client is a simple wrapper around our powerful Visual Discovery [API](http://docs.artifacia.com/).
|
4
|
+
|
5
|
+
The wrapper allows you to create your own indexes 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
|
+
|
7
|
+
* Visual Recommendation
|
8
|
+
* Cross Product Recommendation
|
9
|
+
* Smart Recommendation
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
To install the package you can follow the steps:-
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
rubygem install artifacia
|
17
|
+
```
|
18
|
+
|
19
|
+
## Getting Started
|
20
|
+
|
21
|
+
The API is really easy and simple to use. First you need to create an account [here]() and there you will get a username and a password. Using that credentials you can create your constructor and get stated.
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'artifacia'
|
25
|
+
user_name = <your_username>
|
26
|
+
password = <your_password>
|
27
|
+
client = Client.new(user_name, password)
|
28
|
+
```
|
29
|
+
|
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.
|
32
|
+
|
33
|
+
```python
|
34
|
+
import json
|
35
|
+
sample_data = json.load(open("sample_data.json","rb"))
|
36
|
+
data_indexing_response = client.upload_item_data(sample_data)
|
37
|
+
print data_indexing_response
|
38
|
+
```
|
39
|
+
|
40
|
+
### Performing Visual Recommendation
|
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.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
sample_prod_id = 2761
|
46
|
+
query_response = client.get_visual_recommendations(sample_prod_id)
|
47
|
+
puts query_response
|
48
|
+
```
|
data/artifacia.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'artifacia'
|
3
|
+
s.version = '0.1'
|
4
|
+
s.date = Date.today
|
5
|
+
s.summary = "Artifacia!"
|
6
|
+
s.description = "A ruby client to integrate visual recommendation feature from Artifacia API"
|
7
|
+
s.authors = ["Ashish Kumar"]
|
8
|
+
s.email = 'erashish122@gmail.com'
|
9
|
+
s.files = [
|
10
|
+
"lib/artifacia.rb",
|
11
|
+
"artifacia.gemspec",
|
12
|
+
"README.md"
|
13
|
+
]
|
14
|
+
s.homepage =
|
15
|
+
'https://github.com/artifacia/artifacia-client-ruby'
|
16
|
+
end
|
data/lib/artifacia.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
class Client
|
7
|
+
def initialize(username, password)
|
8
|
+
@user = username
|
9
|
+
@pass = password
|
10
|
+
@host = 'api.artifacia.com'
|
11
|
+
end
|
12
|
+
|
13
|
+
def upload_user_data(data)
|
14
|
+
@post_ws = "/v1/users"
|
15
|
+
@payload=data
|
16
|
+
|
17
|
+
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
18
|
+
req.basic_auth @user, @pass
|
19
|
+
req.body = @payload
|
20
|
+
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
21
|
+
return response.body
|
22
|
+
end
|
23
|
+
|
24
|
+
def upload_item_data(data)
|
25
|
+
@post_ws = "/v1/items"
|
26
|
+
@payload=data
|
27
|
+
|
28
|
+
req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
29
|
+
req.basic_auth @user, @pass
|
30
|
+
req.body = @payload
|
31
|
+
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
32
|
+
return response.body
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete_item_data(item_ids)
|
36
|
+
@post_ws = "/v1/items"
|
37
|
+
|
38
|
+
req = Net::HTTP::Delete.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
39
|
+
req.basic_auth @user, @pass
|
40
|
+
req.body = item_ids
|
41
|
+
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
42
|
+
return response.body
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_visual_recommendation(prod_id)
|
46
|
+
@post_ws = "/v1/recommendation/similar/#{prod_id}"
|
47
|
+
req = Net::HTTP::Get.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
48
|
+
req.basic_auth @user, @pass
|
49
|
+
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
50
|
+
return response.body
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_cpr_recommendation(prod_id)
|
54
|
+
@post_ws = "/v1/recommendation/collections/#{prod_id}"
|
55
|
+
req = Net::HTTP::Get.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
56
|
+
req.basic_auth @user, @pass
|
57
|
+
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
58
|
+
return response.body
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_smart_recommendation(prod_id)
|
62
|
+
@post_ws = "/v1/recommendation/user/#{prod_id}"
|
63
|
+
req = Net::HTTP::Get.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
|
64
|
+
req.basic_auth @user, @pass
|
65
|
+
response = Net::HTTP.new(@host).start {|http| http.request(req) }
|
66
|
+
return response.body
|
67
|
+
end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: artifacia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ashish Kumar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A ruby client to integrate visual recommendation feature from Artifacia
|
14
|
+
API
|
15
|
+
email: erashish122@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/artifacia.rb
|
21
|
+
- artifacia.gemspec
|
22
|
+
- README.md
|
23
|
+
homepage: https://github.com/artifacia/artifacia-client-ruby
|
24
|
+
licenses: []
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.0.14.1
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Artifacia!
|
46
|
+
test_files: []
|