majestic_seo_api 1.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5b4571ac9b35fde014ce2613067c56a2fe3a233
4
- data.tar.gz: d4d1fa3c11e01184b462f8b26dcf7168c4055ced
3
+ metadata.gz: fe0486a6a6caabfa56a80f4a4b1af15a717c6998
4
+ data.tar.gz: 3547882b94326e2eb7d89118dd25783064b43bc9
5
5
  SHA512:
6
- metadata.gz: 97e51ca3ba7170bfcd21824732cc9fe1d709fe28966bfbc69e41db02be301f3fb53ae87c08248008a43d7e2ea48ff1f4aa450cd287b2572049ab96bbb42b2f21
7
- data.tar.gz: 2725e3f0ed6efb0832f86967efc62c6711b01c3bd2db6990fab3a96fb1d458bd2bae8bcf070cacba01d7bb17aaa90ffddc97c647e1abdba88725828a9ef6607d
6
+ metadata.gz: 2f10a79265c8d76953f666a5f51d02921c11876936c45794bc1af2bd3b8be107b3da2705a0486089b73ad572264dc3df74f15177056a51fb12ea7f86e3324c04
7
+ data.tar.gz: dd8f0d4fa85d68159ad6470bf89cb60e889ddb60aba447697740e0017122eaf4e5b26246a541049c0f41a7376dae89c5d5ac7bcb6bdf109e07307e489ee4107d
@@ -61,18 +61,19 @@ module MajesticSeo
61
61
  self.config ||= YAML.load_file(File.join(File.dirname(__FILE__), "../../generators/templates/majestic_seo.template.yml"))[env] rescue nil
62
62
  self.config ||= {}
63
63
  end
64
-
65
- def set_api_url
66
- @api_url = case @environment.to_sym
67
- when :sandbox then "http://developer.majesticseo.com/api_command"
68
- when :production then "http://enterprise.majesticseo.com/api_command"
64
+
65
+ #TODO: Switch to the JSON API
66
+ def set_api_url(format = :xml)
67
+ @api_url = case @environment.to_sym
68
+ when :sandbox then "http://developer.majestic.com/api/#{format}"
69
+ when :production then "http://api.majestic.com/api/#{format}"
69
70
  else
70
- "http://developer.majesticseo.com/api_command"
71
+ "http://developer.majestic.com/api/#{format}"
71
72
  end
72
73
  end
73
74
 
74
75
  def set_connection
75
- @connection = Faraday.new(:url => @api_url, :ssl => {:verify => false}) do |builder|
76
+ @connection = Faraday.new(url: @api_url, ssl: {verify: false}) do |builder|
76
77
  builder.request :url_encoded
77
78
  builder.request :retry
78
79
  builder.response :logger if (@verbose)
@@ -134,18 +135,30 @@ module MajesticSeo
134
135
 
135
136
  # 'parameters' a hash containing the command parameters.
136
137
  # 'options' a hash containing command/call options (timeout, proxy settings etc)
137
- def execute_request(parameters = {}, options = {})
138
- response = nil
139
-
138
+ def execute_request(parameters = {}, options = {}, retries = 3)
139
+ response = nil
140
+ timeout = options.delete(:timeout) { |opt| 60 }
141
+ open_timeout = options.delete(:open_timeout) { |opt| 60 }
142
+
140
143
  begin
141
144
  log(:info, "[MajesticSeo::Api::Client] - Sending API Request to Majestic SEO. Parameters: #{parameters.inspect}. Options: #{options.inspect}")
142
- response = @connection.get do |request|
143
- request.params = parameters if (!parameters.empty?)
144
- request.options = options if (!options.empty?)
145
+
146
+ response = @connection.get do |request|
147
+ request.params = parameters if (!parameters.empty?)
148
+ request.options = options if (!options.empty?)
149
+ request.options[:timeout] = timeout
150
+ request.options[:open_timeout] = open_timeout
145
151
  end
152
+
146
153
  rescue StandardError => e
147
154
  log(:error, "[MajesticSeo::Api::Client] - Error occurred while trying to perform API-call with parameters: #{parameters.inspect}. Error Class: #{e.class.name}. Error Message: #{e.message}. Stacktrace: #{e.backtrace.join("\n")}")
148
- response = nil
155
+ retries -= 1
156
+
157
+ if retries > 0
158
+ retry
159
+ else
160
+ raise e
161
+ end
149
162
  end
150
163
 
151
164
  return response
@@ -1,5 +1,5 @@
1
1
  module MajesticSeoApi
2
- VERSION = "1.2.8"
2
+ VERSION = "1.3.0"
3
3
 
4
4
  require File.join(File.dirname(__FILE__), 'majestic_seo/railtie') if defined?(Rails)
5
5
 
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'majestic_seo_api'
6
- s.version = '1.2.8'
6
+ s.version = '1.3.0'
7
7
 
8
8
  s.homepage = "http://developer-support.majesticseo.com/connectors/"
9
9
  s.email = "sebastian@agiley.se"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: majestic_seo_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Majestic-12 Ltd
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-10 00:00:00.000000000 Z
12
+ date: 2015-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: 1.3.5
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.2.2
148
+ rubygems_version: 2.4.8
149
149
  signing_key:
150
150
  specification_version: 2
151
151
  summary: Interface for communicating with Majestic SEO's API