bluekai 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/bluekai.gemspec +14 -14
- data/lib/bluekai/client.rb +8 -56
- data/lib/bluekai/request.rb +82 -0
- data/lib/bluekai/rule.rb +9 -0
- data/lib/bluekai/user_data.rb +2 -1
- data/lib/bluekai/version.rb +1 -1
- data/spec/fixtures/signatures/0e01a80ff1ca77f4fd32b58ff48310168539a9a26e4ef527042b7bab78d4648a +0 -0
- data/spec/fixtures/signatures/1952b4f61dbd2187b5589dfc390af2ee985ca6f43020081d420f5d9ca025532e +1 -1
- data/spec/fixtures/signatures/1a4aff70f9ce0f00680a85710f1bcf9d294239c7748dc1a23ce2bc7b3e1dca77 +1 -0
- data/spec/fixtures/signatures/2db01e685f73149994efc9824c10fa91e704fb7256d748c4305101513444f49f +1 -1
- data/spec/fixtures/signatures/3c33aa44e5fbea304ffda0390ac2e413a02d187d5425f67c3edab34684b2b18f +0 -0
- data/spec/fixtures/signatures/78f40f967bf9cb1ae030412e7c28267a8050926a538226c685fb2dec6f23b44a +1 -1
- data/spec/fixtures/signatures/7fe2b3662915bf82890e1fe870480885e0744b12832569c5d7017a0fc42d5527 +1 -1
- data/spec/fixtures/signatures/8cd7ba76199d2b34be042841a2dd69310619dcac0f3dd4f24bae6b5fb5f9e302 +2 -1
- data/spec/fixtures/signatures/95768bffa5416007061da13a2a0368e52a4bea3451ac2dfede43f6a6841ac402 +1 -1
- data/spec/fixtures/signatures/a49b4d9ac5b30c91f95a907b887f9b8eaf5c7856b844c49d2b937c00d88af63d +4 -1
- data/spec/fixtures/signatures/a6d578d433ca6f7c84ce9da14c415b3d302bf1da2b87f7666c637419fb784f57 +0 -0
- data/spec/fixtures/signatures/cc71fec906c7a94cba83ef4ea26c065cd10db7db3f128ea9a532a7c25b1e3d3a +1 -0
- data/spec/fixtures/signatures/ce8bca90097fba283912bd48ca710d85cc6c5e52f180624f402903620a16a179 +1 -0
- data/spec/fixtures/signatures/d3c90cbaf307901dff229713b703217d7460f3c50400aa981ac20088f58343ad +1 -1
- data/spec/fixtures/signatures/e41e0c9002d2de5b269a529804dbdf3b987e2ef2cfd801ef5cb09f4ef313882b +0 -0
- data/spec/fixtures/vcr_cassettes/Bluekai_Rule/it_creates_a_rule_and_deletes_it.yml +82 -0
- data/spec/fixtures/vcr_cassettes/Bluekai_UserData/reads_user_information_given_bkuuid.yml +16 -15
- data/spec/lib/bluekai/client_spec.rb +1 -8
- data/spec/lib/bluekai/request_spec.rb +14 -0
- data/spec/lib/bluekai/rule_integration_spec.rb +15 -0
- data/spec/lib/bluekai/user_data_integration_spec.rb +1 -1
- data/spec/support/signature_mock.rb +5 -3
- metadata +16 -13
- data/spec/fixtures/signatures/26d52d2e4c2d42ba54ec6b4de9e67d9b566aeb8224c28261d1d133b7fb3c3436 +0 -1
- data/spec/fixtures/signatures/391112d6698e9864c1d9b37f92ab7e6db690a7e84949378ee272b011f3b82fc0 +0 -1
- data/spec/fixtures/signatures/691325444d07bf08ce72b95283f8a8fd74e19f6963263e5367772b7633cbeab0 +0 -1
- data/spec/fixtures/signatures/847da153b01c0ea4e3beeeb00f5552c3dd773227ee5aeaf5c9ff9a620adae324 +0 -1
- data/spec/fixtures/signatures/d30077840edb2b580c1c9a4a6659989b8342cfdc439ceef0c984672849288243 +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e6f268e501ed2d86040a3e6267273dcf13c7a9a
|
|
4
|
+
data.tar.gz: cc98c3655b05748e9cb5f0e37372c72e3aa0ec7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45b3f3c233cdc04d4d932288e28fb6ceeb52b05ac6f722092310452413960469f7d3d5871093b531ce375ac52c6aee955e91adda6fbcc2e8ad082a2c3cd2eb72
|
|
7
|
+
data.tar.gz: 0241700e4064701a9c834969b087068490e76547abf60c45d50f023494440819e55c43156fe507005e5da4245e875718972ca2e9c1dfe792b66eb85dc25ffd3c
|
data/Gemfile
CHANGED
data/bluekai.gemspec
CHANGED
|
@@ -4,24 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
require 'bluekai/version'
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name
|
|
8
|
-
spec.version
|
|
9
|
-
spec.authors
|
|
10
|
-
spec.email
|
|
11
|
-
spec.summary
|
|
12
|
-
spec.description
|
|
13
|
-
spec.homepage
|
|
14
|
-
spec.license
|
|
7
|
+
spec.name = 'bluekai'
|
|
8
|
+
spec.version = Bluekai::VERSION
|
|
9
|
+
spec.authors = ['ad2games GmbH']
|
|
10
|
+
spec.email = ['developers@ad2games.com']
|
|
11
|
+
spec.summary = 'Simple client for the BlueKai API'
|
|
12
|
+
spec.description = 'Simple client for the BlueKai API (services.bluekai.com)'
|
|
13
|
+
spec.homepage = ''
|
|
14
|
+
spec.license = 'MIT'
|
|
15
15
|
|
|
16
|
-
spec.files
|
|
17
|
-
spec.executables
|
|
18
|
-
spec.test_files
|
|
19
|
-
spec.require_paths = [
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ['lib']
|
|
20
20
|
|
|
21
21
|
spec.add_dependency 'httparty'
|
|
22
22
|
|
|
23
|
-
spec.add_development_dependency
|
|
24
|
-
spec.add_development_dependency
|
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
|
24
|
+
spec.add_development_dependency 'rake'
|
|
25
25
|
spec.add_development_dependency 'vcr'
|
|
26
26
|
spec.add_development_dependency 'webmock'
|
|
27
27
|
spec.add_development_dependency 'rspec'
|
data/lib/bluekai/client.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
require 'openssl'
|
|
2
2
|
require 'base64'
|
|
3
|
-
require 'httparty'
|
|
4
|
-
require 'cgi'
|
|
5
3
|
|
|
6
4
|
module Bluekai
|
|
7
5
|
# A simple BlueKai client
|
|
@@ -10,16 +8,16 @@ module Bluekai
|
|
|
10
8
|
|
|
11
9
|
def initialize(opts = {})
|
|
12
10
|
@api_user_key = opts.fetch(:api_user_key, ENV['BLUEKAI_API_USER_KEY']) ||
|
|
13
|
-
fail(Error, 'BlueKai API user key missing')
|
|
11
|
+
fail(Bluekai::Error, 'BlueKai API user key missing')
|
|
14
12
|
@api_private_key = opts.fetch(:api_private_key, ENV['BLUEKAI_API_PRIVATE_KEY']) ||
|
|
15
|
-
fail(Error, 'BlueKai API private key missing')
|
|
13
|
+
fail(Bluekai::Error, 'BlueKai API private key missing')
|
|
16
14
|
@partner_id = opts.fetch(:partner_id, ENV['BLUEKAI_PARTNER_ID']) ||
|
|
17
|
-
fail(Error, 'BlueKai PartnerID missing')
|
|
15
|
+
fail(Bluekai::Error, 'BlueKai PartnerID missing')
|
|
18
16
|
@opts = opts
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
def ping
|
|
22
|
-
request('GET', '/Services/WS/Ping', {})
|
|
20
|
+
request('GET', '/Services/WS/Ping', {}) == :success rescue false
|
|
23
21
|
end
|
|
24
22
|
|
|
25
23
|
# Public: Lists categories in the BlueKai taxonomy. API definition
|
|
@@ -47,60 +45,14 @@ module Bluekai
|
|
|
47
45
|
private
|
|
48
46
|
|
|
49
47
|
def request(method, path, query, body = nil)
|
|
50
|
-
method
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
response =
|
|
56
|
-
case method
|
|
57
|
-
when 'GET'
|
|
58
|
-
HTTParty.get(url)
|
|
59
|
-
when 'POST'
|
|
60
|
-
HTTParty.post(url, body: body_sorted(body), headers: json_headers)
|
|
61
|
-
when 'PUT'
|
|
62
|
-
HTTParty.put(url, body: body_sorted(body), headers: json_headers)
|
|
63
|
-
else
|
|
64
|
-
fail ArgumentError, "request method '#{method}' not supported"
|
|
65
|
-
end.response
|
|
66
|
-
|
|
67
|
-
fail "HTTP Request Error: #{response.body}" if response.code != '200'
|
|
68
|
-
return response.code if response.body == '' || response.body.nil?
|
|
69
|
-
JSON.parse(response.body, symbolize_names: true)
|
|
48
|
+
r = Request.new(method, path, query, body, domain)
|
|
49
|
+
r.api_user_key = @api_user_key
|
|
50
|
+
r.api_private_key = @api_private_key
|
|
51
|
+
r.run
|
|
70
52
|
end
|
|
71
53
|
|
|
72
54
|
def domain
|
|
73
55
|
'https://services.bluekai.com'
|
|
74
56
|
end
|
|
75
|
-
|
|
76
|
-
def body_sorted(body)
|
|
77
|
-
# sort hash according to keys for correct signature computation
|
|
78
|
-
body.sort_by { |key, _value| key.to_s }.to_h.to_json if body
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def json_headers
|
|
82
|
-
{
|
|
83
|
-
'Accept' => 'application/json',
|
|
84
|
-
'Content-type' => 'application/json'
|
|
85
|
-
}
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def query_values(query)
|
|
89
|
-
return nil unless query
|
|
90
|
-
query.values.join
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def query_url_formatted(query)
|
|
94
|
-
return nil unless query
|
|
95
|
-
query.map { |k, v| "#{k}=#{v}" }.join('&') + '&'
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# HMAC-SHA256(Secret key, HTTP_METHOD + URI_PATH + QUERY_ARG_VALUES + POST_DATA)
|
|
99
|
-
def sign(method, path, query, body)
|
|
100
|
-
string_to_sign = method + path + query.to_s + body.to_s
|
|
101
|
-
digest = OpenSSL::Digest.new('sha256')
|
|
102
|
-
hmac = OpenSSL::HMAC.digest(digest, @api_private_key, string_to_sign)
|
|
103
|
-
CGI.escape(Base64.strict_encode64(hmac))
|
|
104
|
-
end
|
|
105
57
|
end
|
|
106
58
|
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
require 'cgi'
|
|
3
|
+
|
|
4
|
+
module Bluekai
|
|
5
|
+
class Request
|
|
6
|
+
attr_accessor :api_user_key, :api_private_key
|
|
7
|
+
|
|
8
|
+
def initialize(method, path, query, body, domain)
|
|
9
|
+
@method = method.upcase
|
|
10
|
+
@path = path
|
|
11
|
+
@query = query
|
|
12
|
+
@body = body
|
|
13
|
+
@domain = domain
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run
|
|
17
|
+
response = http_request
|
|
18
|
+
fail "HTTP Request Error: #{response.body}" unless response.code.start_with?('2')
|
|
19
|
+
return :success if response.body.nil? || response.body.strip.empty?
|
|
20
|
+
JSON.parse(response.body, symbolize_names: true)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
attr_reader :method, :path, :query, :body, :domain
|
|
26
|
+
|
|
27
|
+
def http_request
|
|
28
|
+
case method
|
|
29
|
+
when 'GET'
|
|
30
|
+
HTTParty.get(url)
|
|
31
|
+
when 'POST'
|
|
32
|
+
HTTParty.post(url, non_get_params)
|
|
33
|
+
when 'PUT'
|
|
34
|
+
HTTParty.put(url, non_get_params)
|
|
35
|
+
when 'DELETE'
|
|
36
|
+
HTTParty.delete(url, non_get_params)
|
|
37
|
+
end.response
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def non_get_params
|
|
41
|
+
{ body: body_sorted, headers: json_headers }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def url
|
|
45
|
+
"#{domain}#{path}?#{query_url_formatted}"\
|
|
46
|
+
"bkuid=#{api_user_key}&bksig=#{signature}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def query_values
|
|
50
|
+
return nil unless query
|
|
51
|
+
query.values.join
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def body_sorted
|
|
55
|
+
# sort hash according to keys for correct signature computation
|
|
56
|
+
body.sort_by { |key, _value| key.to_s }.to_h.to_json if body
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def json_headers
|
|
60
|
+
{
|
|
61
|
+
'Accept' => 'application/json',
|
|
62
|
+
'Content-type' => 'application/json'
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def query_url_formatted
|
|
67
|
+
return nil unless query
|
|
68
|
+
query.map { |k, v| "#{k}=#{v}" }.join('&') + '&'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def string_to_sign
|
|
72
|
+
method + path + query_values.to_s + body_sorted.to_s
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# HMAC-SHA256(Secret key, HTTP_METHOD + URI_PATH + QUERY_ARG_VALUES + POST_DATA)
|
|
76
|
+
def signature
|
|
77
|
+
digest = OpenSSL::Digest.new('sha256')
|
|
78
|
+
hmac = OpenSSL::HMAC.digest(digest, api_private_key, string_to_sign)
|
|
79
|
+
CGI.escape(Base64.strict_encode64(hmac))
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
data/lib/bluekai/rule.rb
CHANGED
|
@@ -161,5 +161,14 @@ module Bluekai
|
|
|
161
161
|
body = { partner_id: @partner_id }.merge(body)
|
|
162
162
|
request('PUT', "/Services/WS/classificationRules/#{rule_id}", {}, body)
|
|
163
163
|
end
|
|
164
|
+
|
|
165
|
+
# Public: Deletes a self-classification rule
|
|
166
|
+
#
|
|
167
|
+
# rule_id:integer (MANDATORY) - id of classification rule to be deleted
|
|
168
|
+
#
|
|
169
|
+
# Returns: '200' if rule could be deleted
|
|
170
|
+
def rule_delete(rule_id)
|
|
171
|
+
request('DELETE', "/Services/WS/classificationRules/#{rule_id}", {})
|
|
172
|
+
end
|
|
164
173
|
end
|
|
165
174
|
end
|
data/lib/bluekai/user_data.rb
CHANGED
|
@@ -71,7 +71,8 @@ module Bluekai
|
|
|
71
71
|
# to filter the categories returned by the
|
|
72
72
|
# User Data API based on the campaigns that won the user.
|
|
73
73
|
#
|
|
74
|
-
# Syntax for passing multiple campaign IDs:
|
|
74
|
+
# Syntax for passing multiple campaign IDs:
|
|
75
|
+
# campaignId1=value&filterbycampids=campaignId2=value
|
|
75
76
|
# Example: 44966&filterbycampids=41674
|
|
76
77
|
#
|
|
77
78
|
# target:integer - By default, this flag is set to 1, which means that the User Data
|
data/lib/bluekai/version.rb
CHANGED
data/spec/fixtures/signatures/0e01a80ff1ca77f4fd32b58ff48310168539a9a26e4ef527042b7bab78d4648a
CHANGED
|
Binary file
|
data/spec/fixtures/signatures/1952b4f61dbd2187b5589dfc390af2ee985ca6f43020081d420f5d9ca025532e
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
x���g�:R-S��?��3�&�u�]5~?@��
|
data/spec/fixtures/signatures/1a4aff70f9ce0f00680a85710f1bcf9d294239c7748dc1a23ce2bc7b3e1dca77
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
�e�����M���M�G.O���+D�0{#����
|
data/spec/fixtures/signatures/2db01e685f73149994efc9824c10fa91e704fb7256d748c4305101513444f49f
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
%��A!G^&��d�EK����.���L�3c#
|
data/spec/fixtures/signatures/3c33aa44e5fbea304ffda0390ac2e413a02d187d5425f67c3edab34684b2b18f
CHANGED
|
Binary file
|
data/spec/fixtures/signatures/78f40f967bf9cb1ae030412e7c28267a8050926a538226c685fb2dec6f23b44a
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
ۛ/GA 4d�Xt?ű��t���C_�
|
data/spec/fixtures/signatures/7fe2b3662915bf82890e1fe870480885e0744b12832569c5d7017a0fc42d5527
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
�,�zJ�ׁ��Xx����q��0�ϔ����\
|
data/spec/fixtures/signatures/8cd7ba76199d2b34be042841a2dd69310619dcac0f3dd4f24bae6b5fb5f9e302
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
��&:�lo�
|
|
2
|
+
�x�� �v��8�3O
|
data/spec/fixtures/signatures/95768bffa5416007061da13a2a0368e52a4bea3451ac2dfede43f6a6841ac402
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
=�f�(
|
data/spec/fixtures/signatures/a6d578d433ca6f7c84ce9da14c415b3d302bf1da2b87f7666c637419fb784f57
CHANGED
|
Binary file
|
data/spec/fixtures/signatures/cc71fec906c7a94cba83ef4ea26c065cd10db7db3f128ea9a532a7c25b1e3d3a
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
�I����A�t4�bo p��}�UE�?�������
|
data/spec/fixtures/signatures/ce8bca90097fba283912bd48ca710d85cc6c5e52f180624f402903620a16a179
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
���4~���|XX�8�&e*�c�����2�
|
data/spec/fixtures/signatures/d3c90cbaf307901dff229713b703217d7460f3c50400aa981ac20088f58343ad
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
5��������(X��S�4�75.���y%'��%�
|
data/spec/fixtures/signatures/e41e0c9002d2de5b269a529804dbdf3b987e2ef2cfd801ef5cb09f4ef313882b
ADDED
|
Binary file
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://services.bluekai.com/Services/WS/classificationRules?bksig=imWQoLjT903W3/8YTddHFi5Pq%2B3HK0SPMHsj%2Bhe89OY=&bkuid=bluekai-api-user-key
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"name":"TEST_123","partner_id":"bluekai-partner-id","phints":[{"key":"offer_id","value":321,"operator":"is"}],"type":"phint"}'
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/json
|
|
12
|
+
Content-Type:
|
|
13
|
+
- application/json
|
|
14
|
+
response:
|
|
15
|
+
status:
|
|
16
|
+
code: 200
|
|
17
|
+
message: OK
|
|
18
|
+
headers:
|
|
19
|
+
Date:
|
|
20
|
+
- Mon, 20 Apr 2015 08:48:01 GMT
|
|
21
|
+
Set-Cookie:
|
|
22
|
+
- JSESSIONID=15F0087CF43C8116B7BC5D5D352018C0; Path=/Services; HttpOnly
|
|
23
|
+
Content-Type:
|
|
24
|
+
- application/json
|
|
25
|
+
Cneonction:
|
|
26
|
+
- close
|
|
27
|
+
Transfer-Encoding:
|
|
28
|
+
- chunked
|
|
29
|
+
body:
|
|
30
|
+
encoding: UTF-8
|
|
31
|
+
string: |-
|
|
32
|
+
{
|
|
33
|
+
"name" : "TEST_123",
|
|
34
|
+
"id" : 15418,
|
|
35
|
+
"type" : "phint",
|
|
36
|
+
"status" : "active",
|
|
37
|
+
"phints" : [ {
|
|
38
|
+
"id" : 24216,
|
|
39
|
+
"key" : "offer_id",
|
|
40
|
+
"value" : "321",
|
|
41
|
+
"operator" : "is"
|
|
42
|
+
} ],
|
|
43
|
+
"categories" : [ ],
|
|
44
|
+
"partner_id" : bluekai-partner-id,
|
|
45
|
+
"created_at" : "Mon Apr 20 03:48:01 CDT 2015",
|
|
46
|
+
"updated_at" : "Mon Apr 20 03:48:01 CDT 2015",
|
|
47
|
+
"sites" : [ ]
|
|
48
|
+
}
|
|
49
|
+
http_version:
|
|
50
|
+
recorded_at: Mon, 20 Apr 2015 08:48:09 GMT
|
|
51
|
+
- request:
|
|
52
|
+
method: delete
|
|
53
|
+
uri: https://services.bluekai.com/Services/WS/classificationRules/15418?bksig=pknB/8CUQfd0NL1ibyBwp9B9nQFVRf8/zxby/tnx3t0=&bkuid=bluekai-api-user-key
|
|
54
|
+
body:
|
|
55
|
+
encoding: US-ASCII
|
|
56
|
+
string: ''
|
|
57
|
+
headers:
|
|
58
|
+
Accept:
|
|
59
|
+
- application/json
|
|
60
|
+
Content-Type:
|
|
61
|
+
- application/json
|
|
62
|
+
response:
|
|
63
|
+
status:
|
|
64
|
+
code: 200
|
|
65
|
+
message: OK
|
|
66
|
+
headers:
|
|
67
|
+
Date:
|
|
68
|
+
- Mon, 20 Apr 2015 08:48:11 GMT
|
|
69
|
+
Set-Cookie:
|
|
70
|
+
- JSESSIONID=4E64A6F826FE91EE28242494CC09B848; Path=/Services; HttpOnly
|
|
71
|
+
Content-Type:
|
|
72
|
+
- application/json
|
|
73
|
+
Content-Length:
|
|
74
|
+
- '1'
|
|
75
|
+
Nncoection:
|
|
76
|
+
- close
|
|
77
|
+
body:
|
|
78
|
+
encoding: UTF-8
|
|
79
|
+
string: " "
|
|
80
|
+
http_version:
|
|
81
|
+
recorded_at: Mon, 20 Apr 2015 08:48:10 GMT
|
|
82
|
+
recorded_with: VCR 2.9.3
|
|
@@ -2,32 +2,32 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: get
|
|
5
|
-
uri: http://api.tags.bluekai.com/getdata/
|
|
5
|
+
uri: http://api.tags.bluekai.com/getdata/23705/v1.2?bksig=H7vQ2wKPkbH4LZAbw/vivSbHb0qUnhhNIACh/pcOO94=&bkuid=bluekai-api-user-key&puserid=916466479881
|
|
6
6
|
body:
|
|
7
7
|
encoding: US-ASCII
|
|
8
8
|
string: ''
|
|
9
|
-
headers:
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
10
16
|
response:
|
|
11
17
|
status:
|
|
12
18
|
code: 200
|
|
13
19
|
message: OK
|
|
14
20
|
headers:
|
|
15
21
|
Date:
|
|
16
|
-
-
|
|
22
|
+
- Wed, 29 Apr 2015 07:16:49 GMT
|
|
17
23
|
Server:
|
|
18
24
|
- Apache/2.2.24 (Unix)
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
Pragma:
|
|
22
|
-
- no-cache
|
|
23
|
-
Expires:
|
|
24
|
-
- Thu, 01 Dec 1994 16:00:00 GMT
|
|
25
|
-
Cache-Control:
|
|
26
|
-
- max-age=0, no-cache, no-store
|
|
25
|
+
Bk-Time-Debug:
|
|
26
|
+
- '1430291809: 0.126987 400000000000000'
|
|
27
27
|
Bk-Server:
|
|
28
|
-
-
|
|
28
|
+
- '4486'
|
|
29
29
|
Content-Length:
|
|
30
|
-
- '
|
|
30
|
+
- '111'
|
|
31
31
|
Content-Type:
|
|
32
32
|
- application/json
|
|
33
33
|
body:
|
|
@@ -36,9 +36,10 @@ http_interactions:
|
|
|
36
36
|
{
|
|
37
37
|
"status": 200,
|
|
38
38
|
"msg": "ok",
|
|
39
|
-
"
|
|
39
|
+
"puserid": "916466479881",
|
|
40
|
+
"userid": "5w2KR8x999e4Xp5P",
|
|
40
41
|
"categories": []
|
|
41
42
|
}
|
|
42
43
|
http_version:
|
|
43
|
-
recorded_at:
|
|
44
|
+
recorded_at: Wed, 29 Apr 2015 07:16:53 GMT
|
|
44
45
|
recorded_with: VCR 2.9.3
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
RSpec.describe Bluekai::Client do
|
|
2
2
|
subject { described_class.new(api_private_key: '1234') }
|
|
3
3
|
|
|
4
|
-
describe '#sign' do
|
|
5
|
-
it 'computes a correct signature' do
|
|
6
|
-
signature = subject.send(:sign, 'GET', '/Services/WS/classificationCategories/', 'blabli', key1: 'value1', key2: 'value2')
|
|
7
|
-
expect(signature).to eq('msNdVnof8pNLImtDYxh0KDiMHWqrvjExAEh7UcSLJw8%3D')
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
4
|
describe '#request' do
|
|
12
5
|
it 'raises ArgumentError if unknown HTTP method is passed' do
|
|
13
|
-
expect { subject.send(:request, 'FOO', '123', {}, nil) }.to raise_error(
|
|
6
|
+
expect { subject.send(:request, 'FOO', '123', {}, nil) }.to raise_error(NoMethodError)
|
|
14
7
|
end
|
|
15
8
|
end
|
|
16
9
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
RSpec.describe Bluekai::Request do
|
|
2
|
+
describe '#sign' do
|
|
3
|
+
it 'computes a correct signature' do
|
|
4
|
+
rq = described_class.new(
|
|
5
|
+
'GET',
|
|
6
|
+
'/Services/WS/classificationCategories/',
|
|
7
|
+
{ ho: 'blabli' },
|
|
8
|
+
{ key1: 'value1', key2: 'value2' },
|
|
9
|
+
'https://services.bluekai.com')
|
|
10
|
+
rq.api_private_key = '1234'
|
|
11
|
+
expect(rq.send(:signature)).to eq('t%2BE36Yup7ORbC3WRux5xY7ohUxqFo5AGsKrGjJYDCKs%3D')
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -70,4 +70,19 @@ RSpec.describe Bluekai::Rule, :vcr do
|
|
|
70
70
|
type: 'phint'
|
|
71
71
|
))
|
|
72
72
|
end
|
|
73
|
+
|
|
74
|
+
it 'it creates a rule and deletes it' do
|
|
75
|
+
rule_body = {
|
|
76
|
+
name: 'TEST_123',
|
|
77
|
+
type: 'phint',
|
|
78
|
+
phints: [{
|
|
79
|
+
key: 'offer_id',
|
|
80
|
+
value: 321,
|
|
81
|
+
operator: 'is'
|
|
82
|
+
}]
|
|
83
|
+
}
|
|
84
|
+
create_response = subject.rule_create(rule_body)
|
|
85
|
+
rule_id = create_response[:id]
|
|
86
|
+
expect(subject.rule_delete(rule_id)).to eq(:success)
|
|
87
|
+
end
|
|
73
88
|
end
|
|
@@ -2,7 +2,7 @@ RSpec.describe Bluekai::UserData, :vcr do
|
|
|
2
2
|
include_context 'signature_mock'
|
|
3
3
|
|
|
4
4
|
it 'reads user information given bkuuid' do
|
|
5
|
-
user_read_response = subject.user_data(
|
|
5
|
+
user_read_response = subject.user_data(23705, puserid: '916466479881')
|
|
6
6
|
expect(user_read_response).to include(
|
|
7
7
|
status: 200,
|
|
8
8
|
msg: 'ok',
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
require 'bluekai/request'
|
|
1
2
|
RSpec.shared_context 'signature_mock' do
|
|
2
3
|
before :each do
|
|
3
|
-
allow(
|
|
4
|
-
|
|
4
|
+
allow(OpenSSL::HMAC)
|
|
5
|
+
.to receive(:digest)
|
|
6
|
+
.and_wrap_original do |method, digest, api_private_key, string_to_sign|
|
|
5
7
|
hash = Digest::SHA256.hexdigest(string_to_sign)
|
|
6
8
|
file = "spec/fixtures/signatures/#{hash}"
|
|
7
9
|
next File.read(file) if File.exist?(file)
|
|
8
|
-
result = method.call(
|
|
10
|
+
result = method.call(digest, api_private_key, string_to_sign)
|
|
9
11
|
File.open(file, 'w+') { |f| f.write(result) }
|
|
10
12
|
result
|
|
11
13
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bluekai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ad2games GmbH
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-04-
|
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|
|
@@ -114,25 +114,25 @@ files:
|
|
|
114
114
|
- lib/bluekai/category.rb
|
|
115
115
|
- lib/bluekai/client.rb
|
|
116
116
|
- lib/bluekai/error.rb
|
|
117
|
+
- lib/bluekai/request.rb
|
|
117
118
|
- lib/bluekai/rule.rb
|
|
118
119
|
- lib/bluekai/user_data.rb
|
|
119
120
|
- lib/bluekai/version.rb
|
|
120
121
|
- spec/fixtures/signatures/0e01a80ff1ca77f4fd32b58ff48310168539a9a26e4ef527042b7bab78d4648a
|
|
121
122
|
- spec/fixtures/signatures/1952b4f61dbd2187b5589dfc390af2ee985ca6f43020081d420f5d9ca025532e
|
|
122
|
-
- spec/fixtures/signatures/
|
|
123
|
+
- spec/fixtures/signatures/1a4aff70f9ce0f00680a85710f1bcf9d294239c7748dc1a23ce2bc7b3e1dca77
|
|
123
124
|
- spec/fixtures/signatures/2db01e685f73149994efc9824c10fa91e704fb7256d748c4305101513444f49f
|
|
124
|
-
- spec/fixtures/signatures/391112d6698e9864c1d9b37f92ab7e6db690a7e84949378ee272b011f3b82fc0
|
|
125
125
|
- spec/fixtures/signatures/3c33aa44e5fbea304ffda0390ac2e413a02d187d5425f67c3edab34684b2b18f
|
|
126
|
-
- spec/fixtures/signatures/691325444d07bf08ce72b95283f8a8fd74e19f6963263e5367772b7633cbeab0
|
|
127
126
|
- spec/fixtures/signatures/78f40f967bf9cb1ae030412e7c28267a8050926a538226c685fb2dec6f23b44a
|
|
128
127
|
- spec/fixtures/signatures/7fe2b3662915bf82890e1fe870480885e0744b12832569c5d7017a0fc42d5527
|
|
129
|
-
- spec/fixtures/signatures/847da153b01c0ea4e3beeeb00f5552c3dd773227ee5aeaf5c9ff9a620adae324
|
|
130
128
|
- spec/fixtures/signatures/8cd7ba76199d2b34be042841a2dd69310619dcac0f3dd4f24bae6b5fb5f9e302
|
|
131
129
|
- spec/fixtures/signatures/95768bffa5416007061da13a2a0368e52a4bea3451ac2dfede43f6a6841ac402
|
|
132
130
|
- spec/fixtures/signatures/a49b4d9ac5b30c91f95a907b887f9b8eaf5c7856b844c49d2b937c00d88af63d
|
|
133
131
|
- spec/fixtures/signatures/a6d578d433ca6f7c84ce9da14c415b3d302bf1da2b87f7666c637419fb784f57
|
|
134
|
-
- spec/fixtures/signatures/
|
|
132
|
+
- spec/fixtures/signatures/cc71fec906c7a94cba83ef4ea26c065cd10db7db3f128ea9a532a7c25b1e3d3a
|
|
133
|
+
- spec/fixtures/signatures/ce8bca90097fba283912bd48ca710d85cc6c5e52f180624f402903620a16a179
|
|
135
134
|
- spec/fixtures/signatures/d3c90cbaf307901dff229713b703217d7460f3c50400aa981ac20088f58343ad
|
|
135
|
+
- spec/fixtures/signatures/e41e0c9002d2de5b269a529804dbdf3b987e2ef2cfd801ef5cb09f4ef313882b
|
|
136
136
|
- spec/fixtures/vcr_cassettes/Bluekai_Category/creates_a_category.yml
|
|
137
137
|
- spec/fixtures/vcr_cassettes/Bluekai_Category/lists_4_categories.yml
|
|
138
138
|
- spec/fixtures/vcr_cassettes/Bluekai_Category/reads_a_category_and_its_reach.yml
|
|
@@ -141,6 +141,7 @@ files:
|
|
|
141
141
|
- spec/fixtures/vcr_cassettes/Bluekai_Client/lists_Bluekai_taxonomy_nodes.yml
|
|
142
142
|
- spec/fixtures/vcr_cassettes/Bluekai_Client/performs_a_ping.yml
|
|
143
143
|
- spec/fixtures/vcr_cassettes/Bluekai_Rule/creates_a_rule.yml
|
|
144
|
+
- spec/fixtures/vcr_cassettes/Bluekai_Rule/it_creates_a_rule_and_deletes_it.yml
|
|
144
145
|
- spec/fixtures/vcr_cassettes/Bluekai_Rule/lists_10_phint_rules.yml
|
|
145
146
|
- spec/fixtures/vcr_cassettes/Bluekai_Rule/reads_a_rule.yml
|
|
146
147
|
- spec/fixtures/vcr_cassettes/Bluekai_Rule/updates_a_rule.yml
|
|
@@ -148,6 +149,7 @@ files:
|
|
|
148
149
|
- spec/lib/bluekai/category_integration_spec.rb
|
|
149
150
|
- spec/lib/bluekai/client_integration_spec.rb
|
|
150
151
|
- spec/lib/bluekai/client_spec.rb
|
|
152
|
+
- spec/lib/bluekai/request_spec.rb
|
|
151
153
|
- spec/lib/bluekai/rule_integration_spec.rb
|
|
152
154
|
- spec/lib/bluekai/user_data_integration_spec.rb
|
|
153
155
|
- spec/spec_helper.rb
|
|
@@ -172,27 +174,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
172
174
|
version: '0'
|
|
173
175
|
requirements: []
|
|
174
176
|
rubyforge_project:
|
|
175
|
-
rubygems_version: 2.4.
|
|
177
|
+
rubygems_version: 2.4.5
|
|
176
178
|
signing_key:
|
|
177
179
|
specification_version: 4
|
|
178
180
|
summary: Simple client for the BlueKai API
|
|
179
181
|
test_files:
|
|
180
182
|
- spec/fixtures/signatures/0e01a80ff1ca77f4fd32b58ff48310168539a9a26e4ef527042b7bab78d4648a
|
|
181
183
|
- spec/fixtures/signatures/1952b4f61dbd2187b5589dfc390af2ee985ca6f43020081d420f5d9ca025532e
|
|
182
|
-
- spec/fixtures/signatures/
|
|
184
|
+
- spec/fixtures/signatures/1a4aff70f9ce0f00680a85710f1bcf9d294239c7748dc1a23ce2bc7b3e1dca77
|
|
183
185
|
- spec/fixtures/signatures/2db01e685f73149994efc9824c10fa91e704fb7256d748c4305101513444f49f
|
|
184
|
-
- spec/fixtures/signatures/391112d6698e9864c1d9b37f92ab7e6db690a7e84949378ee272b011f3b82fc0
|
|
185
186
|
- spec/fixtures/signatures/3c33aa44e5fbea304ffda0390ac2e413a02d187d5425f67c3edab34684b2b18f
|
|
186
|
-
- spec/fixtures/signatures/691325444d07bf08ce72b95283f8a8fd74e19f6963263e5367772b7633cbeab0
|
|
187
187
|
- spec/fixtures/signatures/78f40f967bf9cb1ae030412e7c28267a8050926a538226c685fb2dec6f23b44a
|
|
188
188
|
- spec/fixtures/signatures/7fe2b3662915bf82890e1fe870480885e0744b12832569c5d7017a0fc42d5527
|
|
189
|
-
- spec/fixtures/signatures/847da153b01c0ea4e3beeeb00f5552c3dd773227ee5aeaf5c9ff9a620adae324
|
|
190
189
|
- spec/fixtures/signatures/8cd7ba76199d2b34be042841a2dd69310619dcac0f3dd4f24bae6b5fb5f9e302
|
|
191
190
|
- spec/fixtures/signatures/95768bffa5416007061da13a2a0368e52a4bea3451ac2dfede43f6a6841ac402
|
|
192
191
|
- spec/fixtures/signatures/a49b4d9ac5b30c91f95a907b887f9b8eaf5c7856b844c49d2b937c00d88af63d
|
|
193
192
|
- spec/fixtures/signatures/a6d578d433ca6f7c84ce9da14c415b3d302bf1da2b87f7666c637419fb784f57
|
|
194
|
-
- spec/fixtures/signatures/
|
|
193
|
+
- spec/fixtures/signatures/cc71fec906c7a94cba83ef4ea26c065cd10db7db3f128ea9a532a7c25b1e3d3a
|
|
194
|
+
- spec/fixtures/signatures/ce8bca90097fba283912bd48ca710d85cc6c5e52f180624f402903620a16a179
|
|
195
195
|
- spec/fixtures/signatures/d3c90cbaf307901dff229713b703217d7460f3c50400aa981ac20088f58343ad
|
|
196
|
+
- spec/fixtures/signatures/e41e0c9002d2de5b269a529804dbdf3b987e2ef2cfd801ef5cb09f4ef313882b
|
|
196
197
|
- spec/fixtures/vcr_cassettes/Bluekai_Category/creates_a_category.yml
|
|
197
198
|
- spec/fixtures/vcr_cassettes/Bluekai_Category/lists_4_categories.yml
|
|
198
199
|
- spec/fixtures/vcr_cassettes/Bluekai_Category/reads_a_category_and_its_reach.yml
|
|
@@ -201,6 +202,7 @@ test_files:
|
|
|
201
202
|
- spec/fixtures/vcr_cassettes/Bluekai_Client/lists_Bluekai_taxonomy_nodes.yml
|
|
202
203
|
- spec/fixtures/vcr_cassettes/Bluekai_Client/performs_a_ping.yml
|
|
203
204
|
- spec/fixtures/vcr_cassettes/Bluekai_Rule/creates_a_rule.yml
|
|
205
|
+
- spec/fixtures/vcr_cassettes/Bluekai_Rule/it_creates_a_rule_and_deletes_it.yml
|
|
204
206
|
- spec/fixtures/vcr_cassettes/Bluekai_Rule/lists_10_phint_rules.yml
|
|
205
207
|
- spec/fixtures/vcr_cassettes/Bluekai_Rule/reads_a_rule.yml
|
|
206
208
|
- spec/fixtures/vcr_cassettes/Bluekai_Rule/updates_a_rule.yml
|
|
@@ -208,6 +210,7 @@ test_files:
|
|
|
208
210
|
- spec/lib/bluekai/category_integration_spec.rb
|
|
209
211
|
- spec/lib/bluekai/client_integration_spec.rb
|
|
210
212
|
- spec/lib/bluekai/client_spec.rb
|
|
213
|
+
- spec/lib/bluekai/request_spec.rb
|
|
211
214
|
- spec/lib/bluekai/rule_integration_spec.rb
|
|
212
215
|
- spec/lib/bluekai/user_data_integration_spec.rb
|
|
213
216
|
- spec/spec_helper.rb
|
data/spec/fixtures/signatures/26d52d2e4c2d42ba54ec6b4de9e67d9b566aeb8224c28261d1d133b7fb3c3436
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
oiIT%2F%2BY9Y%2FIHdSlOu80lscu9p76Ez78X8AGi5tTXKYc%3D
|
data/spec/fixtures/signatures/391112d6698e9864c1d9b37f92ab7e6db690a7e84949378ee272b011f3b82fc0
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
IyFa4WJbqPYfaLQ%2FswUpjJg8ECxrrtOkfZ7pQ9Q14co%3D
|
data/spec/fixtures/signatures/691325444d07bf08ce72b95283f8a8fd74e19f6963263e5367772b7633cbeab0
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4EP5gTMcv7xfptkcK%2FfQpEEH9Qtxtta879BfAGEvxfM%3D
|
data/spec/fixtures/signatures/847da153b01c0ea4e3beeeb00f5552c3dd773227ee5aeaf5c9ff9a620adae324
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
6nWdj4cOVG4Cnjm%2F9qfmjG5MKJ8h446WQKBzT2AP30w%3D
|
data/spec/fixtures/signatures/d30077840edb2b580c1c9a4a6659989b8342cfdc439ceef0c984672849288243
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
N1bXH7bmiXZcdIEEPqd2oOO7tZeT9ctNeslruNARLX8%3D
|