Class: Bluekai::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bluekai/client.rb

Overview

A simple BlueKai client

Direct Known Subclasses

Category, Rule, UserData

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
# File 'lib/bluekai/client.rb', line 9

def initialize(opts = {})
  @api_user_key = opts.fetch(:api_user_key, ENV['BLUEKAI_API_USER_KEY']) ||
    fail(Bluekai::Error, 'BlueKai API user key missing')
  @api_private_key = opts.fetch(:api_private_key, ENV['BLUEKAI_API_PRIVATE_KEY']) ||
    fail(Bluekai::Error, 'BlueKai API private key missing')
  @partner_id = opts.fetch(:partner_id, ENV['BLUEKAI_PARTNER_ID']) ||
    fail(Bluekai::Error, 'BlueKai PartnerID missing')
  @opts = opts
end

Instance Attribute Details

#api_user_keyObject (readonly)

Returns the value of attribute api_user_key.



7
8
9
# File 'lib/bluekai/client.rb', line 7

def api_user_key
  @api_user_key
end

Instance Method Details

#pingObject



19
20
21
# File 'lib/bluekai/client.rb', line 19

def ping
  request('GET', '/Services/WS/Ping', {}) == :success rescue false
end

#taxonomy(query = {}) ⇒ Object

Public: Lists categories in the BlueKai taxonomy. API definition can be found here kb.bluekai.com/display/PD/Taxonomy+API

parentId - integer fullPath - 0,1 bkSize - 0,1 Enter 1 to include the inventory of unique users in

the BlueKai network for each category.

intlDataCountryId - Bluekai::Client.-1.-1..24 for country index see

(https://kb.bluekai.com/display/PD/Taxonomy+API)

device_code - = Desktop + Mobile,1 = Desktop, 2 = Mobile showBuyable - 0,1 showLeafStatus - 0,1 description - 0,1 vertical - 0,1 showReceivedAudienceCategories - 0,1 showCategoryPriceAtDate - ‘YYYY-MM-DD’

Returns array of taxonomy nodes.



41
42
43
# File 'lib/bluekai/client.rb', line 41

def taxonomy(query = {})
  request('GET', '/Services/WS/Taxonomy', query)[:nodeList]
end