Module: Semrush

Defined in:
lib/semrush.rb,
lib/semrush/base.rb,
lib/semrush/report.rb,
lib/semrush/version.rb,
lib/semrush/analytics.rb,
lib/semrush/exception.rb,
lib/semrush/exception/bad_query.rb,
lib/semrush/exception/bad_api_key.rb,
lib/semrush/exception/bad_argument.rb,
lib/semrush/exception/nothing_found.rb,
lib/semrush/exception/unknown_error.rb,
lib/semrush/exception/api_access_disabled.rb,
lib/semrush/exception/api_report_type_disabled.rb,
lib/semrush/exception/api_units_balance_is_zero.rb

Defined Under Namespace

Modules: Exception Classes: Analytics, Base, Report

Constant Summary collapse

API_REPORT_URL =
"https://api.semrush.com/?type=%REPORT_TYPE%&%REQUEST_TYPE%=%REQUEST%&key=%API_KEY%&display_limit=%LIMIT%&display_offset=%OFFSET%&export=api&database=%DB%&export_columns=%EXPORT_COLUMNS%&display_sort=%DISPLAY_SORT%&display_filter=%DISPLAY_FILTER%&display_date=%DISPLAY_DATE%"
API_ANALYTICS_URL =
"https://api.semrush.com/analytics/v1?type=%REPORT_TYPE%&targets=%TARGETS%&target_types=%TARGET_TYPES%&target=%TARGET%&target_type=%TARGET_TYPE%&key=%API_KEY%&display_limit=%LIMIT%&display_offset=%OFFSET%&export_columns=%EXPORT_COLUMNS%&display_sort=%DISPLAY_SORT%&display_filter=%DISPLAY_FILTER%"
API_UNITS_URL =
"https://www.semrush.com/users/countapiunits.html?key=%API_KEY%"
VERSION =

we want to follow the API version: for API 3.0, the gem will be version 3.0.x

"3.0.25"
@@api_key =
""
@@debug =
false
@@before =
Proc.new{}
@@after =
Proc.new{}

Class Method Summary collapse

Class Method Details

.config {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Semrush)

    the object that the method was called on

Raises:



26
27
28
29
30
31
# File 'lib/semrush.rb', line 26

def self.config
  yield self
  raise Exception::BadApiKey.new if @@api_key.nil? || @@api_key.empty?
  raise Exception::BadArgument.new(self, "before is not a proc: proc type is required.") unless @@before.is_a?(Proc)
  raise Exception::BadArgument.new(self, "after is not a proc: proc type is required.") unless @@after.is_a?(Proc)
end