majestic_seo_api 1.2.8 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/majestic_seo/api/client.rb +27 -14
- data/lib/majestic_seo_api.rb +1 -1
- data/majestic_seo_api.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe0486a6a6caabfa56a80f4a4b1af15a717c6998
|
4
|
+
data.tar.gz: 3547882b94326e2eb7d89118dd25783064b43bc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
when :
|
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.
|
71
|
+
"http://developer.majestic.com/api/#{format}"
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
74
75
|
def set_connection
|
75
|
-
@connection = Faraday.new(:
|
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
|
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
|
-
|
143
|
-
|
144
|
-
request.
|
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
|
-
|
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
|
data/lib/majestic_seo_api.rb
CHANGED
data/majestic_seo_api.gemspec
CHANGED
@@ -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.
|
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.
|
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:
|
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.
|
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
|