Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge 5a05db4 into 346dd3a
Browse files Browse the repository at this point in the history
  • Loading branch information
archdx committed Mar 15, 2016
2 parents 346dd3a + 5a05db4 commit 3e98bbd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 86 deletions.
6 changes: 3 additions & 3 deletions lib/metrika/api/counters.rb
Expand Up @@ -10,7 +10,7 @@ def create_counter(params)
end

def counters_path
"/counters"
"/management/v1/counters"
end

def get_counter(id)
Expand All @@ -26,15 +26,15 @@ def delete_counter(id)
end

def counter_path(id)
"/counter/#{id}"
"/management/v1/counter/#{id}"
end

def check_counter(id)
self.get(self.counter_check_path(id))['counter']
end

def counter_check_path(id)
"/counter/#{id}/check"
"/management/v1/counter/#{id}/check"
end
end
end
Expand Down
85 changes: 3 additions & 82 deletions lib/metrika/api/statistics.rb
@@ -1,92 +1,13 @@
module Metrika
module Api
module Statistics
# Traffic
%w( summary deepness hourly load ).each do |report|
define_method "get_counter_stat_traffic_#{report}" do | id, params = {} |
params = self.format_params(params)

self.get(self.send("counter_stat_traffic_#{report}_path"), params.merge(:id => id))
end

define_method "counter_stat_traffic_#{report}_path" do
"/stat/traffic/#{report}"
end
end

# Sources
%w( summary sites search_engines phrases marketing direct_summary direct_platforms direct_regions tags ).each do |report|
define_method "get_counter_stat_sources_#{report}" do | id, params = {} |
params = self.format_params(params)

self.get(self.send("counter_stat_sources_#{report}_path"), params.merge(:id => id))
end

define_method "counter_stat_sources_#{report}_path" do
"/stat/sources/#{report}"
end
end

# Content
%w( popular entrance exit titles url_param user_vars ecommerce ).each do |report|
define_method "get_counter_stat_content_#{report}" do | id, params = {} |
params = self.format_params(params)

self.get(self.send("counter_stat_content_#{report}_path"), params.merge(:id => id))
end

define_method "counter_stat_content_#{report}_path" do
"/stat/content/#{report}"
end
end

# Geo
def get_counter_stat_geo(id, params = {})
def get_counter_stats(id, params = {})
params = self.format_params(params)

self.get(self.counter_stat_geo_path, params.merge(:id => id))
end

def counter_stat_geo_path
"/stat/geo"
raise Metrika::Errors::GeneralError.new("Provide at least metric for query") if params[:metrics].nil?
self.get("/stat/v1/data", params.merge(id: id))
end

# Interest
def get_counter_stat_interest(id, params = {})
params = self.format_params(params)

self.get(self.counter_stat_interest_path, params.merge(:id => id))
end

def counter_stat_interest_path
"/stat/interest"
end

# Demography
%w( age_gender structure ).each do |report|
define_method "get_counter_stat_demography_#{report}" do | id, params = {} |
params = self.format_params(params)

self.get(self.send("counter_stat_demography_#{report}_path"), params.merge(:id => id))
end

define_method "counter_stat_demography_#{report}_path" do
"/stat/demography/#{report}"
end
end

# Tech
%w( browsers os display mobile flash silverlight dotnet java cookies javascript ).each do |report|
define_method "get_counter_stat_tech_#{report}" do | id, params = {} |
params = self.format_params(params)

self.get(self.send("counter_stat_tech_#{report}_path"), params.merge(:id => id))
end

define_method "counter_stat_tech_#{report}_path" do
"/stat/tech/#{report}"
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/metrika/helpers.rb
Expand Up @@ -10,7 +10,7 @@ module Helpers
def format_params(params)
params[:date1] = self.format_date(params[:date1]) if params[:date1].present?
params[:date2] = self.format_date(params[:date2]) if params[:date2].present?

params
end

Expand Down

0 comments on commit 3e98bbd

Please sign in to comment.