bluekai 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/lib/bluekai/category.rb +145 -0
  4. data/lib/bluekai/client.rb +20 -321
  5. data/lib/bluekai/rule.rb +165 -0
  6. data/lib/bluekai/user_data.rb +90 -0
  7. data/lib/bluekai/version.rb +1 -1
  8. data/lib/bluekai.rb +3 -0
  9. data/spec/fixtures/signatures/0e01a80ff1ca77f4fd32b58ff48310168539a9a26e4ef527042b7bab78d4648a +1 -0
  10. data/spec/fixtures/signatures/7fe2b3662915bf82890e1fe870480885e0744b12832569c5d7017a0fc42d5527 +1 -0
  11. data/spec/fixtures/signatures/8cd7ba76199d2b34be042841a2dd69310619dcac0f3dd4f24bae6b5fb5f9e302 +1 -0
  12. data/spec/fixtures/signatures/95768bffa5416007061da13a2a0368e52a4bea3451ac2dfede43f6a6841ac402 +1 -0
  13. data/spec/fixtures/vcr_cassettes/{Bluekai_Client → Bluekai_Category}/creates_a_category.yml +10 -10
  14. data/spec/fixtures/vcr_cassettes/Bluekai_Category/lists_4_categories.yml +104 -0
  15. data/spec/fixtures/vcr_cassettes/{Bluekai_Client → Bluekai_Category}/reads_a_category_and_its_reach.yml +1616 -1610
  16. data/spec/fixtures/vcr_cassettes/{Bluekai_Client → Bluekai_Category}/updates_a_category.yml +9 -9
  17. data/spec/fixtures/vcr_cassettes/Bluekai_Client/lists_Bluekai_taxonomy_nodes.yml +28225 -27370
  18. data/spec/fixtures/vcr_cassettes/Bluekai_Client/performs_a_ping.yml +4 -4
  19. data/spec/fixtures/vcr_cassettes/{Bluekai_Client → Bluekai_Rule}/creates_a_rule.yml +11 -11
  20. data/spec/fixtures/vcr_cassettes/Bluekai_Rule/lists_10_phint_rules.yml +234 -0
  21. data/spec/fixtures/vcr_cassettes/{Bluekai_Client → Bluekai_Rule}/reads_a_rule.yml +12 -10
  22. data/spec/fixtures/vcr_cassettes/{Bluekai_Client → Bluekai_Rule}/updates_a_rule.yml +7 -7
  23. data/spec/fixtures/vcr_cassettes/Bluekai_UserData/reads_user_information_given_bkuuid.yml +44 -0
  24. data/spec/lib/bluekai/category_integration_spec.rb +56 -0
  25. data/spec/lib/bluekai/client_integration_spec.rb +1 -141
  26. data/spec/lib/bluekai/client_spec.rb +0 -3
  27. data/spec/lib/bluekai/rule_integration_spec.rb +73 -0
  28. data/spec/lib/bluekai/user_data_integration_spec.rb +12 -0
  29. data/spec/spec_helper.rb +3 -2
  30. data/spec/support/signature_mock.rb +13 -0
  31. metadata +40 -19
  32. data/spec/fixtures/vcr_cassettes/Bluekai_Client/lists_10_phint_rules.yml +0 -194
  33. data/spec/fixtures/vcr_cassettes/Bluekai_Client/lists_4_categories.yml +0 -3569
@@ -0,0 +1,165 @@
1
+ module Bluekai
2
+ class Rule < Client
3
+ ####
4
+ #### Classification Rules
5
+ #### API definition can be found here
6
+ #### https://kb.bluekai.com/display/PD/Self-Classification+Rule+API
7
+ ####
8
+
9
+ # Public: List the self-classification rules in your private
10
+ # taxonomy
11
+ #
12
+ # sort_by:string - Enter 'status', 'id', 'created_at', 'updated_at',
13
+ # or 'type' to sort the returned self-classification
14
+ # rules by the specified option.
15
+ #
16
+ # sorting_order:string - Enter 'asc' or 'desc' to list the returned
17
+ # self-classification rules in ascending or descending
18
+ # order based on the specified sort option.
19
+ #
20
+ # ids:integer - Returns the self-classification rule matching the specified
21
+ # rule ID, or returns all the self-classification rules matching
22
+ # the specified list of rule IDs. Syntax for passing multiple rule IDs:
23
+ # ruleId1&id=ruleId2 Example: 123&id=125
24
+ #
25
+ # type:enum - Enter 'phint' or 'url' to return only the phint or
26
+ # URL-based self-classification rules.
27
+ #
28
+ # site_ids:string - Returns all the self-classification rules under the
29
+ # specified site ID or list of site IDs. Syntax for
30
+ # passing multiple site IDs: site_id_1&site_ids=site_id_2
31
+ # Example: 1234&site_ids=1235
32
+ #
33
+ # category_ids:string - Returns all the self-classification rules used
34
+ # to map the specified catgeory ID or list of category IDs.
35
+ # Syntax for passing multiple category
36
+ # IDs: category_id_1&category_ids=category_id_2
37
+ # Example: 1234&category_ids=1235
38
+ #
39
+ # offset:integer - Specify the starting index from which to return the
40
+ # self-classification rules.
41
+ #
42
+ # size:integer - Specify the maximum number of rules to be included in
43
+ # the response. This filter requires the offset filter
44
+ # to be specified.
45
+ #
46
+ # created_date_range:string - Returns all the self-classification rules
47
+ # created within the specified list of dates.
48
+ # Syntax: YYYY-MM-DD&created_date_range=YYYY-MM-DD
49
+ # Example: 2014-01-01&created_date_range=2014-31-01
50
+ #
51
+ # updated_date_range:string - Returns all the self-classification rules updated
52
+ # within the specified list of dates.
53
+ # Syntax: YYYY-MM-DD&updated_date_range=YYYY-MM-DD
54
+ # Example: 2014-01-01&updated_date_range=2014-31-01
55
+ #
56
+ # status:string - Enter 'Active' or 'Creating' to return the
57
+ # self-classification rules based on the specified status referrer
58
+ # boolean Returns all URL-based self-classification rules that
59
+ # classify the site URL (False) or the referrer URL (True) in
60
+ # the collected URL.
61
+ #
62
+ # exact:boolean - Returns all URL-based self-classification rules that classify
63
+ # an exact URL (True) or a top-level URL (False) in the collected URL.
64
+ # Returns: hash of Bluekai rules
65
+ def rule_list(query)
66
+ request('GET', '/Services/WS/classificationRules', query)[:rules]
67
+ end
68
+
69
+ # Public: Reads a self-classification rule
70
+ #
71
+ # rule_id:integer - The unique ID assigned to the
72
+ # self-classification rule to be retrieved
73
+ #
74
+ # Returns: hash of Blukkai rule parameters
75
+ def rule_read(rule_id)
76
+ request('GET', "/Services/WS/classificationRules/#{rule_id}", {})
77
+ end
78
+
79
+ # Public: Creates a new self-classification rule
80
+ #
81
+ # name:string - Enter a string specifying the name of the self-classification rule.
82
+ #
83
+ # type:string - {'phint', 'url'} Specify the type of classification rule.
84
+ #
85
+ # phints:[{phint}] - If you are creating a phint-based rule,
86
+ # enter a list of your phint definitions.
87
+ # Each phint requires the following properties:
88
+ # key - The phint key operator - The criteria
89
+ # used for determining how the phint value
90
+ # is applied ('is' or 'contains')
91
+ # value - The full or partial phint value,
92
+ # depending on the specified operator.
93
+ #
94
+ # urls:[string(s)] - Provide a list of your URL definitions
95
+ # if you are creating for URL-based rules.
96
+ #
97
+ # referrer:string - {'True','False'} If you are creating a
98
+ # URL-based rule, specify whether the URL to
99
+ # be classified is the site URL (False) or
100
+ # the referrer URL (True).
101
+ #
102
+ # exact:string - {'True','False'} If you are creating a
103
+ # URL-based rule, specify whether the URL collected
104
+ # from your site must match the URL in your
105
+ # rule (True) or match a top-level URL (False) so
106
+ # that you can target users visiting the child pages
107
+ # without specifying them.
108
+ #
109
+ # partner_id:integer - Enter the unique ID assigned to your BlueKai DMP seat.
110
+ #
111
+ # site_ids (optional):[interger(s)] - Enter a list of containers/site IDs to which
112
+ # the self-classification rule applies. If
113
+ # you do not include this parameter, the
114
+ # rule is applicable to ALL the
115
+ # container/site IDs in your seat.
116
+ #
117
+ # category_ids:[integer(s)] - a list of category IDs to which
118
+ # the self-classification rule applies.
119
+ #
120
+ # JSON example for Phint-based self-classification rule
121
+ # {
122
+ # "name": "Phint Example",
123
+ # "type": "phint",
124
+ # "phints": [
125
+ # {
126
+ # "key": "x",
127
+ # "value": "123",
128
+ # "operator": "is"
129
+ # }
130
+ # ],
131
+ # "partner_id": 123,
132
+ # "site_ids": [1234],
133
+ # "category_ids": [12345]
134
+ # }
135
+ #
136
+ # JSON example for URL-based self-classiifcation rule
137
+ # {
138
+ # "name": "URL Example",
139
+ # "type": "url",
140
+ # "urls": ["http://shop.yoursite.com"],
141
+ # "referrer": false,
142
+ # "exact": false,
143
+ # "partner_id": 123,
144
+ # "site_ids": [1234],
145
+ # "category_ids": [123456]
146
+ # }
147
+ # Returns: hash of created self-classification rule
148
+ def rule_create(body)
149
+ body = { partner_id: @partner_id }.merge(body)
150
+ request('POST', '/Services/WS/classificationRules', {}, body)
151
+ end
152
+
153
+ # Public: Update a self-classification rule
154
+ #
155
+ # rule_id:integer (MANDATORY) - id of classification rule to be updated
156
+ #
157
+ # for other parameters refer to documentation of rule_create(body)
158
+ #
159
+ # Returns: hash of updated self-classification rule
160
+ def rule_update(rule_id, body)
161
+ body = { partner_id: @partner_id }.merge(body)
162
+ request('PUT', "/Services/WS/classificationRules/#{rule_id}", {}, body)
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,90 @@
1
+ module Bluekai
2
+ class UserData < Client
3
+ ####
4
+ #### User Data
5
+ ####
6
+ #### API definition can be found here
7
+ #### https://kb.bluekai.com/display/PD/User+Data+API
8
+ ####
9
+
10
+ # Public: method to add attributes to a user's online profile,
11
+ # and to return the categories for which they qualified in one
12
+ # or more campaigns.
13
+ #
14
+ # siteid:integer - Enter the site ID associated with the
15
+ # BlueKai Container you deployed on your site. If you are sending data
16
+ # to BlueKai, the specified site ID must be included in the
17
+ # classification rules used to map your phints (user attributes)
18
+ # to categories in your taxonomy. If you are getting data, the
19
+ # specified site ID must be in the pixel URL of the campaign
20
+ # targeting the user.
21
+ #
22
+ # userid:string - Enter the encrypted BlueKai UUID (BKUUID) for the user. The BKUUID may
23
+ # be returned by the ID swap tag you deployed on your site.
24
+ #
25
+ # puserid:string - Enter your Partner-based UUID (PUUID) for the user.
26
+ #
27
+ # pfield:string - If you entered a puserid that was ID swapped with BlueKai via
28
+ # phints (for example, you used the BlueKai CoreTag to send the
29
+ # puserid to BlueKai), you must do the following in order to use it for
30
+ # sending and getting user data: 1. In the pfield parameter, enter the
31
+ # type of key (fieldname) associated with the puserid you are passing.
32
+ # The pfield is used to uniquely identify your puserid(s) in the
33
+ # BlueKai platform. 2. Contact your BlueKai Account Manager to
34
+ # enable your pfield in the BlueKai system.
35
+ #
36
+ # idfa:string - If you are sending or getting data on an iOS mobile app user, enter the
37
+ # Identifier for Advertising (IDFA) of the mobile iOS device.
38
+ # Note: The data you are sending or getting is linked exclusively to the
39
+ # IDFA, which operates in a primary ID space (the data is not linked to
40
+ # a BKUUID). You do not need to pass the userid or puserid when passing the
41
+ # idfa.If you pass both an idfa and a userid/puserid, the user will be
42
+ # looked up based on the userid/puserid.
43
+ #
44
+ # adid:string - If you are sending or getting data on an Android mobile app user,
45
+ # enter the Google Advertising ID of the mobile Android device. Note: The
46
+ # data you are sending or getting is linked exclusively to the AdID,
47
+ # which operates in a primary ID space (the data is not linked to a
48
+ # BKUUID). You do not need to pass the userid or puserid when
49
+ # passing the adid.If you pass both an adid and a userid/puserid,
50
+ # the user will be looked up based on the userid/puserid.
51
+ #
52
+ # useragent:string - If you are sending or getting data on a mobile user (via their
53
+ # BlueKai statistical ID), enter the user agent of the mobile device
54
+ # and the ipaddress.
55
+ #
56
+ # ipaddress:string - If you are sending or getting data on a mobile user (via their
57
+ # BlueKai statistical ID), enter the IP address of the user's
58
+ # mobile device and the useragent.
59
+ #
60
+ # create_profile:string - Enter 1 to create a new user profile in the BlueKai Profile
61
+ # Store, and add the categories specified in the phint field to it.
62
+ #
63
+ # phint:string - Enter a phint or a list of phints (key-value pairs that represent user
64
+ # attributes) to tag the user with. The maximum number of phints you
65
+ # can pass is restricted by the maximum size of the HTTP GET
66
+ # request, which is 2,048 bytes.
67
+ # Syntax for passing multiple phints: category1=value&phint=category2=value
68
+ # Example: v=123&phint=v=345
69
+ #
70
+ # filterbycampids:string - Enter a campaign ID or a comma-separated list of campaign IDs
71
+ # to filter the categories returned by the
72
+ # User Data API based on the campaigns that won the user.
73
+ #
74
+ # Syntax for passing multiple campaign IDs: campaignId1=value&filterbycampids=campaignId2=value
75
+ # Example: 44966&filterbycampids=41674
76
+ #
77
+ # target:integer - By default, this flag is set to 1, which means that the User Data
78
+ # API returns the categories that user has been tagged with. Enter 0
79
+ # to disable user targeting and not return any user categories.
80
+ def user_data(site_id, query)
81
+ request('GET', "/getdata/#{site_id}/v1.2", query, nil)
82
+ end
83
+
84
+ private
85
+
86
+ def domain
87
+ 'http://api.tags.bluekai.com'
88
+ end
89
+ end
90
+ end
@@ -1,3 +1,3 @@
1
1
  module Bluekai
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
data/lib/bluekai.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'bluekai/version'
2
2
  require 'bluekai/client'
3
3
  require 'bluekai/error'
4
+ require 'bluekai/rule'
5
+ require 'bluekai/category'
6
+ require 'bluekai/user_data'
4
7
 
5
8
  module Bluekai
6
9
  # Your code goes here...
@@ -0,0 +1 @@
1
+ 6yKY4ELmcOD1mWIoiTNkfeNKtA6P6UlUH0tnW2DuYvk%3D
@@ -0,0 +1 @@
1
+ 1CzTegZKodeBp5tYeJoYsPvFcd75MOWRz5SV%2FZrVB1w%3D
@@ -0,0 +1 @@
1
+ %2FOMmOpBsb88KpnipB5og6HaMrTjXEjNPDYuwLoTEgT0%3D
@@ -0,0 +1 @@
1
+ PcRmnygfAQ2726R%2BkEJekFp5rmBboLgbhbcxrq3iCfQ%3D
@@ -2,11 +2,11 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: https://bluekai-domain.com/Services/WS/classificationCategories?bksig=oiIT/%2BY9Y/IHdSlOu80lscu9p76Ez78X8AGi5tTXKYc=&bkuid=bluekai-api-user-key
5
+ uri: https://services.bluekai.com/Services/WS/classificationCategories?bksig=1CzTegZKodeBp5tYeJoYsPvFcd75MOWRz5SV/ZrVB1w=&bkuid=bluekai-api-user-key
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"analytics_excluded":"false","description":"an example category","mutex_children":"false","name":"Test
9
- Category 123","navigation_only":"false","notes":"Just an API test","parent_id":"422741"}'
9
+ Category 123","navigation_only":"false","notes":"Just an API test","parent_id":"424547"}'
10
10
  headers:
11
11
  Accept:
12
12
  - application/json
@@ -18,9 +18,9 @@ http_interactions:
18
18
  message: OK
19
19
  headers:
20
20
  Date:
21
- - Wed, 08 Apr 2015 10:21:29 GMT
21
+ - Wed, 15 Apr 2015 09:55:23 GMT
22
22
  Set-Cookie:
23
- - JSESSIONID=213DF2DFD4497967DE02681C2EB5EF07; Path=/Services; HttpOnly
23
+ - JSESSIONID=BFC398D84CD7A9F2E28DA873A55047CF; Path=/Services; HttpOnly
24
24
  Content-Type:
25
25
  - application/json
26
26
  Cneonction:
@@ -32,18 +32,18 @@ http_interactions:
32
32
  string: |-
33
33
  {
34
34
  "name" : "Test Category 123",
35
- "id" : 424251,
35
+ "id" : 426057,
36
36
  "description" : "an example category",
37
37
  "leaf" : true,
38
38
  "notes" : "Just an API test",
39
- "parent_id" : 422741,
40
- "created_at" : "2015-04-08 05:21:29-0500",
41
- "updated_at" : "2015-04-08 05:21:29-0500",
39
+ "parent_id" : 424547,
40
+ "created_at" : "2015-04-15 04:55:23-0500",
41
+ "updated_at" : "2015-04-15 04:55:23-0500",
42
+ "navigation_only" : false,
42
43
  "analytics_excluded" : false,
43
44
  "mutex_children" : false,
44
- "navigation_only" : false,
45
45
  "rules" : [ ]
46
46
  }
47
47
  http_version:
48
- recorded_at: Wed, 08 Apr 2015 10:21:32 GMT
48
+ recorded_at: Wed, 15 Apr 2015 09:55:24 GMT
49
49
  recorded_with: VCR 2.9.3
@@ -0,0 +1,104 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://services.bluekai.com/Services/WS/classificationCategories?bksig=UBH5ABTZ0lJteX19/H5SxV7R70l9pT4Uf5UFFzdFyrE=&bkuid=bluekai-api-user-key&offset=0&size=4&sort_by=name&sorting_order=asc
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
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
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Tue, 14 Apr 2015 11:56:26 GMT
23
+ Set-Cookie:
24
+ - JSESSIONID=762114A14F8B1C4D0769EA1354B105A8; Path=/Services; HttpOnly
25
+ Content-Type:
26
+ - application/json
27
+ Cneonction:
28
+ - close
29
+ Transfer-Encoding:
30
+ - chunked
31
+ body:
32
+ encoding: UTF-8
33
+ string: |-
34
+ {
35
+ "categories" : [ {
36
+ "name" : "Accessories",
37
+ "id" : 424261,
38
+ "description" : "Accessories category",
39
+ "leaf" : true,
40
+ "notes" : "",
41
+ "parent_id" : 424270,
42
+ "created_at" : "2015-04-08 08:57:41-0400",
43
+ "updated_at" : "2015-04-08 09:12:57-0400",
44
+ "navigation_only" : false,
45
+ "analytics_excluded" : false,
46
+ "mutex_children" : false,
47
+ "rules" : [ {
48
+ "id" : 12543,
49
+ "name" : "ST_SHARE_ACCESSORIES"
50
+ } ]
51
+ }, {
52
+ "name" : "Accessories",
53
+ "id" : 424276,
54
+ "description" : "Accessories category",
55
+ "leaf" : true,
56
+ "notes" : "",
57
+ "parent_id" : 424269,
58
+ "created_at" : "2015-04-08 08:57:41-0400",
59
+ "updated_at" : "2015-04-08 09:07:20-0400",
60
+ "navigation_only" : false,
61
+ "analytics_excluded" : false,
62
+ "mutex_children" : false,
63
+ "rules" : [ {
64
+ "id" : 12538,
65
+ "name" : "ST_BUY_ACCESSORIES"
66
+ } ]
67
+ }, {
68
+ "name" : "Accessories",
69
+ "id" : 424283,
70
+ "description" : "Accessories category",
71
+ "leaf" : true,
72
+ "notes" : "",
73
+ "parent_id" : 424271,
74
+ "created_at" : "2015-04-08 08:57:41-0400",
75
+ "updated_at" : "2015-04-08 09:14:34-0400",
76
+ "navigation_only" : false,
77
+ "analytics_excluded" : false,
78
+ "mutex_children" : false,
79
+ "rules" : [ {
80
+ "id" : 12548,
81
+ "name" : "ST_DETAIL_ACCESSORIES"
82
+ } ]
83
+ }, {
84
+ "name" : "Accessories",
85
+ "id" : 424284,
86
+ "description" : "Accessories category",
87
+ "leaf" : true,
88
+ "notes" : "",
89
+ "parent_id" : 424272,
90
+ "created_at" : "2015-04-08 08:57:41-0400",
91
+ "updated_at" : "2015-04-08 09:15:57-0400",
92
+ "navigation_only" : false,
93
+ "analytics_excluded" : false,
94
+ "mutex_children" : false,
95
+ "rules" : [ {
96
+ "id" : 12553,
97
+ "name" : "ST_HEART_ACCESSORIES"
98
+ } ]
99
+ } ],
100
+ "total_count" : 84
101
+ }
102
+ http_version:
103
+ recorded_at: Tue, 14 Apr 2015 11:56:26 GMT
104
+ recorded_with: VCR 2.9.3