awis-sdk-ruby 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +87 -0
- data/Gemfile +5 -3
- data/Rakefile +7 -5
- data/awis.gemspec +20 -17
- data/bin/console +4 -3
- data/lib/awis.rb +18 -20
- data/lib/awis/api.rb +8 -6
- data/lib/awis/api/base.rb +3 -1
- data/lib/awis/api/category_browse.rb +10 -7
- data/lib/awis/api/category_listings.rb +15 -12
- data/lib/awis/api/sites_linking_in.rb +10 -7
- data/lib/awis/api/traffic_history.rb +12 -9
- data/lib/awis/api/url_info.rb +11 -5
- data/lib/awis/client.rb +9 -6
- data/lib/awis/config.rb +3 -1
- data/lib/awis/connection.rb +87 -13
- data/lib/awis/exceptions.rb +3 -1
- data/lib/awis/hash.rb +2 -0
- data/lib/awis/models.rb +9 -7
- data/lib/awis/models/base.rb +4 -2
- data/lib/awis/models/base_entity.rb +2 -0
- data/lib/awis/models/category_browse.rb +14 -2
- data/lib/awis/models/category_listings.rb +4 -2
- data/lib/awis/models/sites_linking_in.rb +4 -2
- data/lib/awis/models/traffic_history.rb +10 -2
- data/lib/awis/models/url_info.rb +9 -7
- data/lib/awis/utils.rb +5 -4
- data/lib/awis/utils/extra.rb +3 -1
- data/lib/awis/utils/hash.rb +2 -0
- data/lib/awis/utils/variable.rb +3 -1
- data/lib/awis/utils/xml.rb +3 -1
- data/lib/awis/version.rb +3 -1
- metadata +57 -46
- data/lib/awis/utils/request.rb +0 -153
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3f60e08f71c0092e6c7ff4185e1e64a6af7776d9
|
4
|
+
data.tar.gz: cb3a28d169416fb66d36ff7d662295b777709de7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b27b1755fc104f0fc196f1ed91c5e0d93408f3fbd62ccb39b3f7d02c135e2a34eca4db3d4a8a60ee819e0b9bf84aa48c8a392da7e5ed1c4d139e2f4474c0d553
|
7
|
+
data.tar.gz: 9d9e2c0011a964374a10a9d89680b57aeebbe44bc5333980f4e40fe163af26c699caecdfbf493f1222aa7f136c59ae084407409ea6223752ed78862f0bfff388
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
TargetRubyVersion: 2.4
|
4
|
+
Exclude:
|
5
|
+
- '**/*.yml'
|
6
|
+
- 'test/**/*'
|
7
|
+
- 'pkg/*'
|
8
|
+
- 'tmp/*'
|
9
|
+
|
10
|
+
Style/StringLiterals:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Documentation:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/RegexpLiteral:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Layout/SpaceInsideHashLiteralBraces:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/LineLength:
|
23
|
+
Max: 160
|
24
|
+
|
25
|
+
Metrics/ModuleLength:
|
26
|
+
Max: 500
|
27
|
+
|
28
|
+
Metrics/BlockLength:
|
29
|
+
Exclude:
|
30
|
+
- 'test/**/*'
|
31
|
+
|
32
|
+
Layout/DotPosition:
|
33
|
+
EnforcedStyle: trailing
|
34
|
+
|
35
|
+
Style/RedundantFreeze:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
Style/FormatString:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Metrics/ClassLength:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Lint/AssignmentInCondition:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
Layout/EmptyLinesAroundAccessModifier:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Style/SingleLineBlockParams:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Style/NumericLiterals:
|
54
|
+
Exclude:
|
55
|
+
- 'spec/**/*'
|
56
|
+
|
57
|
+
Style/StringLiteralsInInterpolation:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Metrics/MethodLength:
|
61
|
+
Max: 30
|
62
|
+
|
63
|
+
Layout/CaseIndentation:
|
64
|
+
# Valid values are: case, end
|
65
|
+
EnforcedStyle: end
|
66
|
+
IndentOneStep: false
|
67
|
+
|
68
|
+
Metrics/AbcSize:
|
69
|
+
Max: 40
|
70
|
+
|
71
|
+
Metrics/CyclomaticComplexity:
|
72
|
+
Max: 10
|
73
|
+
|
74
|
+
Metrics/PerceivedComplexity:
|
75
|
+
Max: 15
|
76
|
+
|
77
|
+
Metrics/ParameterLists:
|
78
|
+
Max: 10
|
79
|
+
|
80
|
+
Lint/UselessAssignment:
|
81
|
+
Enabled: false
|
82
|
+
|
83
|
+
Style/NumericLiterals:
|
84
|
+
Enabled: false
|
85
|
+
|
86
|
+
Rails:
|
87
|
+
Enabled: true
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
|
6
|
+
require 'rake/testtask'
|
5
7
|
Rake::TestTask.new(:test) do |test|
|
6
|
-
test.libs <<
|
7
|
-
test.pattern =
|
8
|
+
test.libs << 'lib' << 'test'
|
9
|
+
test.pattern = 'test/**/*_test.rb'
|
8
10
|
test.verbose = true
|
9
11
|
end
|
10
12
|
|
11
|
-
task :
|
13
|
+
task default: :test
|
data/awis.gemspec
CHANGED
@@ -1,32 +1,35 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'awis/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'awis-sdk-ruby'
|
8
9
|
spec.version = Awis::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Encore Shao']
|
11
|
+
spec.email = ['encore.shao@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
13
|
+
spec.summary = 'Ruby - Amazon Alexa Web Information Service Library (AWIS)'
|
14
|
+
spec.description = 'Ruby - Amazon Alexa Web Information Service Library (AWIS)'
|
15
|
+
spec.homepage = 'https://github.com/encoreshao/amazon-awis'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
18
|
f.match(%r{^(test|spec|features)/})
|
18
19
|
end
|
19
|
-
spec.bindir =
|
20
|
+
spec.bindir = 'exe'
|
20
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
-
spec.require_paths = [
|
22
|
+
spec.require_paths = ['lib']
|
22
23
|
|
23
|
-
spec.required_ruby_version =
|
24
|
+
# spec.required_ruby_version = '>= 1.9.3'
|
24
25
|
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
26
|
+
spec.add_dependency 'aws-sigv4'
|
27
|
+
spec.add_dependency 'multi_xml'
|
28
|
+
spec.add_dependency 'nokogiri'
|
27
29
|
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
30
|
+
spec.add_development_dependency 'minitest'
|
31
|
+
spec.add_development_dependency 'mocha'
|
32
|
+
spec.add_development_dependency 'pry'
|
33
|
+
spec.add_development_dependency 'rubocop'
|
34
|
+
spec.add_development_dependency 'webmock'
|
32
35
|
end
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'awis'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "awis"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/lib/awis.rb
CHANGED
@@ -1,24 +1,22 @@
|
|
1
|
-
|
2
|
-
require "nokogiri"
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require "awis/exceptions"
|
8
|
-
require "awis/connection"
|
9
|
-
require "awis/config"
|
10
|
-
require "awis/client"
|
11
|
-
require "awis/api"
|
12
|
-
require "awis/models"
|
3
|
+
require 'multi_xml'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'aws-sigv4'
|
13
6
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
7
|
+
require 'awis/version'
|
8
|
+
require 'awis/hash'
|
9
|
+
require 'awis/utils'
|
10
|
+
require 'awis/exceptions'
|
11
|
+
require 'awis/connection'
|
12
|
+
require 'awis/config'
|
13
|
+
require 'awis/client'
|
14
|
+
require 'awis/api'
|
15
|
+
require 'awis/models'
|
21
16
|
|
22
|
-
|
23
|
-
|
17
|
+
module Awis
|
18
|
+
SERVICE_PATH = 'api'
|
19
|
+
SERVICE_NAME = 'awis'
|
20
|
+
SERVICE_REGION = 'us-west-1'
|
21
|
+
SERVICE_HOST = "#{SERVICE_NAME}.amazonaws.com"
|
24
22
|
end
|
data/lib/awis/api.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Awis
|
2
4
|
module API
|
3
|
-
autoload :Base,
|
4
|
-
autoload :UrlInfo,
|
5
|
-
autoload :TrafficHistory,
|
6
|
-
autoload :SitesLinkingIn,
|
7
|
-
autoload :CategoryListings,
|
8
|
-
autoload :CategoryBrowse,
|
5
|
+
autoload :Base, 'awis/api/base'
|
6
|
+
autoload :UrlInfo, 'awis/api/url_info'
|
7
|
+
autoload :TrafficHistory, 'awis/api/traffic_history'
|
8
|
+
autoload :SitesLinkingIn, 'awis/api/sites_linking_in'
|
9
|
+
autoload :CategoryListings, 'awis/api/category_listings'
|
10
|
+
autoload :CategoryBrowse, 'awis/api/category_browse'
|
9
11
|
end
|
10
12
|
end
|
data/lib/awis/api/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Awis
|
2
4
|
module API
|
3
5
|
class Base
|
@@ -39,7 +41,7 @@ module Awis
|
|
39
41
|
|
40
42
|
def before_validation_arguments(arguments)
|
41
43
|
raise ArgumentError, "Invalid arguments. should be like { url: 'site.com' }" unless arguments.is_a?(Hash)
|
42
|
-
raise ArgumentError,
|
44
|
+
raise ArgumentError, 'Invalid arguments. the url must be configured.' unless arguments.key?(:url)
|
43
45
|
end
|
44
46
|
|
45
47
|
class << self
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Awis
|
2
4
|
module API
|
3
5
|
class CategoryBrowse < Base
|
4
|
-
DEFAULT_RESPONSE_GROUP = %w
|
6
|
+
DEFAULT_RESPONSE_GROUP = %w[categories related_categories language_categories letter_bars].freeze
|
5
7
|
|
6
8
|
def load_request_uri(arguments = {})
|
7
9
|
validation_arguments!(arguments)
|
@@ -10,9 +12,10 @@ module Awis
|
|
10
12
|
end
|
11
13
|
|
12
14
|
private
|
15
|
+
|
13
16
|
def before_validation_arguments(arguments)
|
14
17
|
raise ArgumentError, "Invalid arguments. should be like { path: 'Top/Arts' }" unless arguments.is_a?(Hash)
|
15
|
-
raise ArgumentError,
|
18
|
+
raise ArgumentError, 'Invalid arguments. the path must be configured.' unless arguments.key?(:path)
|
16
19
|
end
|
17
20
|
|
18
21
|
def validation_arguments!(arguments)
|
@@ -25,15 +28,15 @@ module Awis
|
|
25
28
|
|
26
29
|
def params
|
27
30
|
{
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
'Action' => action_name,
|
32
|
+
'ResponseGroup' => response_groups,
|
33
|
+
'Path' => arguments[:path],
|
34
|
+
'Descriptions' => request_description_params
|
32
35
|
}
|
33
36
|
end
|
34
37
|
|
35
38
|
def response_groups
|
36
|
-
arguments[:response_group].sort.map { |group| camelize(group) }.join(
|
39
|
+
arguments[:response_group].sort.map { |group| camelize(group) }.join(',')
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Awis
|
2
4
|
module API
|
3
5
|
class CategoryListings < Base
|
4
|
-
DEFAULT_RESPONSE_GROUP = %w
|
6
|
+
DEFAULT_RESPONSE_GROUP = %w[listings].freeze
|
5
7
|
|
6
8
|
def load_request_uri(arguments = {})
|
7
9
|
validation_arguments!(arguments)
|
@@ -10,16 +12,17 @@ module Awis
|
|
10
12
|
end
|
11
13
|
|
12
14
|
private
|
15
|
+
|
13
16
|
def before_validation_arguments(arguments)
|
14
17
|
raise ArgumentError, "Invalid arguments. should be like { path: '/Top/Games/Card_Games' }" unless arguments.is_a?(Hash)
|
15
|
-
raise ArgumentError,
|
18
|
+
raise ArgumentError, 'Invalid arguments. the path must be configured.' unless arguments.key?(:path)
|
16
19
|
end
|
17
20
|
|
18
21
|
def validation_arguments!(arguments)
|
19
22
|
before_validation_arguments(arguments)
|
20
23
|
|
21
24
|
@arguments = arguments
|
22
|
-
@arguments[:sort_by] = arguments.fetch(:sort_by,
|
25
|
+
@arguments[:sort_by] = arguments.fetch(:sort_by, 'popularity')
|
23
26
|
@arguments[:recursive] = arguments.fetch(:recursive, true)
|
24
27
|
@arguments[:descriptions] = arguments.fetch(:descriptions, true)
|
25
28
|
@arguments[:start] = arguments.fetch(:start, 0)
|
@@ -28,14 +31,14 @@ module Awis
|
|
28
31
|
|
29
32
|
def params
|
30
33
|
{
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
'Action' => action_name,
|
35
|
+
'ResponseGroup' => response_groups,
|
36
|
+
'Path' => arguments[:path],
|
37
|
+
'Recursive' => recursive_param,
|
38
|
+
'Descriptions' => request_description_params,
|
39
|
+
'SortBy' => sort_by_param,
|
40
|
+
'Count' => arguments[:count],
|
41
|
+
'Start' => arguments[:start]
|
39
42
|
}
|
40
43
|
end
|
41
44
|
|
@@ -48,7 +51,7 @@ module Awis
|
|
48
51
|
end
|
49
52
|
|
50
53
|
def response_groups
|
51
|
-
DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(
|
54
|
+
DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(',')
|
52
55
|
end
|
53
56
|
end
|
54
57
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Awis
|
2
4
|
module API
|
3
5
|
class SitesLinkingIn < Base
|
4
|
-
DEFAULT_RESPONSE_GROUP = %w
|
6
|
+
DEFAULT_RESPONSE_GROUP = %w[sites_linking_in].freeze
|
5
7
|
|
6
8
|
def load_request_uri(arguments = {})
|
7
9
|
validation_arguments!(arguments)
|
@@ -10,6 +12,7 @@ module Awis
|
|
10
12
|
end
|
11
13
|
|
12
14
|
private
|
15
|
+
|
13
16
|
def validation_arguments!(arguments)
|
14
17
|
before_validation_arguments(arguments)
|
15
18
|
|
@@ -20,16 +23,16 @@ module Awis
|
|
20
23
|
|
21
24
|
def params
|
22
25
|
{
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
'Action' => action_name,
|
27
|
+
'Url' => arguments[:url],
|
28
|
+
'ResponseGroup' => response_groups,
|
29
|
+
'Count' => arguments[:count],
|
30
|
+
'Start' => arguments[:start]
|
28
31
|
}
|
29
32
|
end
|
30
33
|
|
31
34
|
def response_groups
|
32
|
-
DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(
|
35
|
+
DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(',')
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Awis
|
2
4
|
module API
|
3
5
|
class TrafficHistory < Base
|
4
|
-
DEFAULT_RESPONSE_GROUP = %w
|
6
|
+
DEFAULT_RESPONSE_GROUP = %w[history].freeze
|
5
7
|
|
6
8
|
def load_request_uri(arguments = {})
|
7
9
|
validation_arguments!(arguments)
|
@@ -10,13 +12,14 @@ module Awis
|
|
10
12
|
end
|
11
13
|
|
12
14
|
private
|
15
|
+
|
13
16
|
def params
|
14
17
|
{
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
'Action' => action_name,
|
19
|
+
'Url' => arguments[:url],
|
20
|
+
'ResponseGroup' => response_groups,
|
21
|
+
'Range' => arguments[:range],
|
22
|
+
'Start' => start_date
|
20
23
|
}
|
21
24
|
end
|
22
25
|
|
@@ -25,15 +28,15 @@ module Awis
|
|
25
28
|
|
26
29
|
@arguments = arguments
|
27
30
|
@arguments[:range] = arguments.fetch(:range, 31)
|
28
|
-
@arguments[:start] = arguments.fetch(:start) { Time.now - (3600 * 24 * @arguments[:range].to_i) }
|
31
|
+
@arguments[:start] = arguments.fetch(:start) { Time.zone.now - (3600 * 24 * @arguments[:range].to_i) }
|
29
32
|
end
|
30
33
|
|
31
34
|
def start_date
|
32
|
-
arguments[:start].respond_to?(:strftime) ? arguments[:start].strftime(
|
35
|
+
arguments[:start].respond_to?(:strftime) ? arguments[:start].strftime('%Y%m%d') : arguments[:start]
|
33
36
|
end
|
34
37
|
|
35
38
|
def response_groups
|
36
|
-
DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(
|
39
|
+
DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(',')
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|