artifacia 0.1.2 → 0.1.2.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/artifacia.gemspec +1 -1
  3. data/lib/artifacia.rb +15 -13
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0a9d771635e85cd06644d9d778058cdd1a67eab
4
- data.tar.gz: 28c4e3d47e5e5b7b8f57627381a2732d028e2d9d
3
+ metadata.gz: 430377b9bb0f81cfab96ba1574415096a5feddb6
4
+ data.tar.gz: 4b7c021939eeef44a38313833d9cff9fc7e98f43
5
5
  SHA512:
6
- metadata.gz: 5a9a5b651247e60d6c128002fb2ba612ede9ede834ab098307900ede364f0d4990a6a403345c7474608ee51b2b6cf2d63b5bdc469a0e95f34f8e7aab9fafc3e4
7
- data.tar.gz: c0e6c4f1941cb54c2e330039299fdb2c9ad0470c19d2505ecabd1ebc7931ed8623c5da577255ac9f397351791275188c5d59d9c384e913abd8a885883031792f
6
+ metadata.gz: e43e9a23b117fe526a272b366c84053dd3f33a2ad3b21a6998733ca8182a32189adec073043a124e3774358c8b0ad146724d5426839e95351814c0d36aa9e5e3
7
+ data.tar.gz: 79cd2a883bfbaf2d7b728cc6d339ccbac4917efaba270cef8bc5a5e2513658f581969a46ec30c6480d56188e03a0d6cea98c2d1c24b8d5f72fa473d1b393cba5
data/artifacia.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'artifacia'
3
- s.version = '0.1.2'
3
+ s.version = '0.1.2.1'
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"
data/lib/artifacia.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'net/http'
2
-
1
+ require 'net/https'
3
2
  require 'rubygems'
4
3
  require 'json'
5
4
 
@@ -8,14 +7,17 @@ class Client
8
7
  @user = username
9
8
  @pass = password
10
9
  @host = 'api.artifacia.com'
10
+ @port = 443
11
+ @http = Net::HTTP.new(@host, @port)
12
+ @http.use_ssl = true
13
+ @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
11
14
  end
12
15
 
13
16
  def upload_user_purchased_items(user_id, data)
14
17
  @post_ws = "/v1/users/#{user_id}/purchased_items"
15
18
  req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
16
19
  req.basic_auth @user, @pass
17
- req.body = data
18
- response = Net::HTTP.new(@host).start {|http| http.request(req) }
20
+ response = @http.request(req)
19
21
  return response.body
20
22
  end
21
23
 
@@ -24,7 +26,7 @@ class Client
24
26
  req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
25
27
  req.basic_auth @user, @pass
26
28
  req.body = data
27
- response = Net::HTTP.new(@host).start {|http| http.request(req) }
29
+ response = @http.request(req)
28
30
  return response.body
29
31
  end
30
32
 
@@ -33,7 +35,7 @@ class Client
33
35
  req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
34
36
  req.basic_auth @user, @pass
35
37
  req.body = data
36
- response = Net::HTTP.new(@host).start {|http| http.request(req) }
38
+ response = @http.request(req)
37
39
  return response.body
38
40
  end
39
41
 
@@ -42,31 +44,31 @@ class Client
42
44
  req = Net::HTTP::Delete.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
43
45
  req.basic_auth @user, @pass
44
46
  req.body = item_ids
45
- response = Net::HTTP.new(@host).start {|http| http.request(req) }
47
+ response = @http.request(req)
46
48
  return response.body
47
49
  end
48
50
 
49
51
  def get_visual_recommendation(prod_id, num)
50
52
  @post_ws = "/v1/recommendation/similar/#{prod_id}/#{num}"
51
- req = Net::HTTP::Get.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
53
+ req = Net::HTTP::Get.new(@post_ws)
52
54
  req.basic_auth @user, @pass
53
- response = Net::HTTP.new(@host).start {|http| http.request(req) }
55
+ response = @http.request(req)
54
56
  return response.body
55
57
  end
56
58
 
57
59
  def get_cpr_recommendation(prod_id, num)
58
60
  @post_ws = "/v1/recommendation/collections/#{prod_id}/#{num}"
59
- req = Net::HTTP::Get.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
61
+ req = Net::HTTP::Get.new(@post_ws)
60
62
  req.basic_auth @user, @pass
61
- response = Net::HTTP.new(@host).start {|http| http.request(req) }
63
+ response = @http.request(req)
62
64
  return response.body
63
65
  end
64
66
 
65
67
  def get_personalized_recommendation(user_id, num)
66
68
  @post_ws = "/v1/recommendation/user/#{user_id}/#{num}"
67
- req = Net::HTTP::Get.new(@post_ws, initheader = {'Content-Type' =>'application/json'})
69
+ req = Net::HTTP::Get.new(@post_ws)
68
70
  req.basic_auth @user, @pass
69
- response = Net::HTTP.new(@host).start {|http| http.request(req) }
71
+ response = @http.request(req)
70
72
  return response.body
71
73
  end
72
74
  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.1
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-08-03 00:00:00.000000000 Z
11
+ date: 2016-08-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A ruby client to integrate visual recommendation feature from Artifacia
14
14
  API