Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renamed the config file to cj.yml, it can now hold the developer_key …

…and the website_id (which is a required field for the ProductCatalogSearch service). You can now override the developer_key in every service call by passing the :developer_key parameter to the #find methods.
  • Loading branch information...
commit 065030e207c4591e1b9077bb1cbca4654c60728c 1 parent aee9b6b
Jose Fernandez authored
View
2  cj.yml.tpl
@@ -0,0 +1,2 @@
+developer_key: 243hfjs41bf3fbb753c0a4a9061137335edf03387474b0dc7e8557a2cb56693efd3270239e4a414731036da42d91
+website_id: 12345
View
1  cj_key.yml.tpl
@@ -1 +0,0 @@
-008efcffd663243hfjs41bf3fbb753c0a4a9061137335edf03387474b0dc7e8557a2cb56693efd3270239e4a414731036da42d91
View
4 install.rb
@@ -1,5 +1,5 @@
require 'fileutils'
-cj_config = File.dirname(__FILE__) + '/../../../config/cj_key.yml'
-FileUtils.cp File.dirname(__FILE__) + '/cj_key.yml.tpl', cj_config unless File.exist?(cj_config)
+cj_config = File.dirname(__FILE__) + '/../../../config/cj.yml'
+FileUtils.cp File.dirname(__FILE__) + '/cj.yml.tpl', cj_config unless File.exist?(cj_config)
puts IO.read(File.join(File.dirname(__FILE__), 'README.markdown'))
View
10 lib/cj4r.rb
@@ -20,17 +20,15 @@ module DefaultMappingRegistry
module Cj4r
class ConfigFileNotFoundError < StandardError; end
- class DeveloperKeyError < StandardError; end
def self.included(base)
- mattr_reader :developer_key
+ mattr_reader :config
begin
- config_path = RAILS_ROOT + "/config/cj_key.yml"
- @@developer_key = File.open(File.expand_path(config_path)) { |f| f.read }.chomp
- raise DeveloperKeyError.new("Developer key is empty: %s" % config_path) if @@developer_key.blank?
+ config_path = RAILS_ROOT + "/config/cj.yml"
+ @@config = YAML.load(ERB.new(File.read(config_path)).result).symbolize_keys
rescue Errno::ENOENT
- raise ConfigFileNotFoundError.new("Config file not found: %s" % config_path )
+ raise ConfigFileNotFoundError.new("Cj4r config file not found: %s" % config_path )
end
end
end
View
5 lib/services/daily_publisher_commission_service.rb
@@ -5,7 +5,8 @@ class DailyPublisherCommission
class << self # Class methods
def find(*args)
options = args.extract_options!
- options[:date] = options[:date].nil? ? 1.day.ago.strftime("%m/%d/%Y") : options[:date].strftime("%m/%d/%Y")
+ options[:developer_key] ||= Cj4r.config[:developer_key]
+ options[:date] = options[:date].nil? ? 1.day.ago.strftime("%m/%d/%Y") : options[:date].strftime("%m/%d/%Y")
options[:date_type] ||= 'event'
options[:advertiser_ids] ||= ''
options[:website_ids] ||= ''
@@ -37,7 +38,7 @@ def find_last(options)
def find_every(options)
params = FindPublisherCommissions.new(
- Cj4r.developer_key,
+ options[:developer_key],
options[:date],
options[:date_type],
options[:advertiser_ids],
View
5 lib/services/product_catalog_search_service.rb
@@ -5,7 +5,8 @@ class ProductCatalogSearch
class << self # Class methods
def find(*args)
options = args.extract_options!
- options[:website_id] ||= ''
+ options[:developer_key] ||= Cj4r.config[:developer_key]
+ options[:website_id] ||= Cj4r.config[:website_id]
options[:advertiser_ids] ||= ''
options[:keywords] ||= ''
options[:serviceable_area] ||= ''
@@ -44,7 +45,7 @@ def find_last(options)
def find_every(options)
params = Search.new(
- Cj4r.developer_key,
+ options[:developer_key],
options[:website_id],
options[:advertiser_ids],
options[:keywords],
View
3  lib/services/real_time_commission_service.rb
@@ -5,6 +5,7 @@ class RealTimeCommission
class << self # Class methods
def find(*args)
options = args.extract_options!
+ options[:developer_key] ||= Cj4r.config[:developer_key]
options[:website_ids] ||= ''
options[:look_back_x_hours] ||= 4
options[:advertiser_ids] ||= ''
@@ -34,7 +35,7 @@ def find_last(options)
def find_every(options)
params = RetrieveLatestTransactions.new(
- Cj4r.developer_key,
+ options[:developer_key],
options[:website_ids],
options[:look_back_x_hours],
options[:advertiser_ids],
Please sign in to comment.
Something went wrong with that request. Please try again.