This gem can be used inside any ruby project - even outside frameworks.
Add this line to your application's Gemfile:
git 'https://github.com/mberlanda/nielsen_dar_api.git' do
gem 'nielsen_dar_api', '0.1.0'
end
If you want to use it in irb
console, see this answer on StackOverflow regarding gems installed from git repositories:
$ bundle exec irb
# or
$ irb
2.4.0 :001 > require 'bundler/setup'
true
2.4.0 :002 > require 'nielsen_dar_api'
true
You can refer to this example for a working sample.
In order to work, this gem requires your credentials to be set in the configuration:
require 'nielsen_dar_api'
NielsenDarApi.configure do |config|
config.username = ENV['NIELSEN_DAR_USERNAME'] # 'email'
config.password = ENV['NIELSEN_DAR_PASSWORD'] # 'password'
config.basic_token = ENV['NIELSEN_DAR_AUTH_TOKEN'] # 'Basic auth token provided by Nielsen'
end
I would suggest to set this values as environment variables, but you can hard-code them if you prefer.
You can even change some default settings such as config.country_code= 'IT'
At the current stage, there is not yet a proper Client class. You can create one very easily:
class SampleClient
include NielsenDarApi::Helper
end
client = SampleClient.new
When I work on Nielsen DAR Reporting API I tend to follow this flow for every import routine:
- process references: collect all details for every entity
- process exposures: collect exposure overall campaign and placement data + placement daily data
In this first step the gem handles
- process_available_campaigns : check which campaigns are available for my account
- process_demographics : get details about available demographic groups (e.g. All, Female, Female 12-17 ...)
- process_platforms : get details about available platforms (e.g. Computer, Mobile, Total-Digital ...)
- process_market_areas : get details about available market areas (this feature seems to be available only for US
countryCode
) - process_campaigns : get details about campaigns
- process_placements : get details about the sites where the available campaigns are tracked
In this first step the gem handles:
- process_campaign_exposures : gets overall campaign exposure data (either it is finished or not)
- process_placement_exposures : gets overall placement exposure data (either the campaign is finished or not)
- process_placement_daily_data : gets daily placement exposure data