awis-sdk-ruby 2.0.0 → 2.1.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 +4 -4
- data/README.md +8 -4
- data/lib/awis/api/base.rb +2 -2
- data/lib/awis/client.rb +7 -12
- data/lib/awis/connection.rb +8 -1
- data/lib/awis/models/base.rb +23 -0
- data/lib/awis/models/category_browse.rb +1 -1
- data/lib/awis/models/category_listings.rb +2 -1
- data/lib/awis/models/sites_linking_in.rb +2 -1
- data/lib/awis/models/traffic_history.rb +2 -1
- data/lib/awis/models/url_info.rb +14 -12
- data/lib/awis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1b8b0369cacf309ffff5b752c458d3465ef51b7b085fd9c55fce22f8651807d
|
4
|
+
data.tar.gz: a78a3affebba1ae56d03b0db2173044e29ae5139d02a8ea3051ba5a0b0708c13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7229cf7a29ab8992f30e9aef6e51471250de75a7830a1021b4df1fb6d00ce5009fbf2b2410f9cb7903dfb580cda97b73b3f0080f49023d9bfac09a252eaa7c11
|
7
|
+
data.tar.gz: 503f910fbb860e7aab95022c0559a5c36418ddbd602e06cd6009dc07c305364075ef7b6e97987be08627773387add3f2be9710ed0bd48cb4921b7ee5754da4cd
|
data/README.md
CHANGED
@@ -50,6 +50,14 @@ returns object that contains attributes:
|
|
50
50
|
* asin
|
51
51
|
* xml
|
52
52
|
|
53
|
+
New methods:
|
54
|
+
|
55
|
+
* is_404?
|
56
|
+
* not_found?
|
57
|
+
* pretty_xml
|
58
|
+
|
59
|
+
`pretty_xml` method will easily to review the XML response from the terminal
|
60
|
+
|
53
61
|
returns object that contains relationships:
|
54
62
|
|
55
63
|
**contact_info**
|
@@ -104,10 +112,6 @@ returns object that contains relationships:
|
|
104
112
|
- title
|
105
113
|
- absolute_path
|
106
114
|
|
107
|
-
New methods:
|
108
|
-
|
109
|
-
* is_404?
|
110
|
-
|
111
115
|
You can specify options:
|
112
116
|
|
113
117
|
* url
|
data/lib/awis/api/base.rb
CHANGED
data/lib/awis/client.rb
CHANGED
@@ -29,18 +29,13 @@ module Awis
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def parse_response_with_request(kclass, args)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
when 'CategoryBrowse'
|
40
|
-
Models::CategoryBrowse.new API::CategoryBrowse.new.fetch(args)
|
41
|
-
when 'CategoryListings'
|
42
|
-
Models::CategoryListings.new API::CategoryListings.new.fetch(args)
|
43
|
-
end
|
32
|
+
raise ArgumentError, 'Amazon class was missing!' unless [
|
33
|
+
'UrlInfo', 'SitesLinkingIn', 'TrafficHistory',
|
34
|
+
'CategoryBrowse', 'CategoryListings'
|
35
|
+
].include?(kclass)
|
36
|
+
|
37
|
+
response = Kernel.const_get("Awis::API::#{kclass}").new.fetch(args)
|
38
|
+
Kernel.const_get("Awis::Models::#{kclass}").new(response)
|
44
39
|
end
|
45
40
|
end
|
46
41
|
end
|
data/lib/awis/connection.rb
CHANGED
@@ -31,13 +31,20 @@ module Awis
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def get(params = {})
|
34
|
-
|
34
|
+
set_params(params)
|
35
|
+
|
35
36
|
handle_response(request).body
|
36
37
|
end
|
37
38
|
|
39
|
+
def set_params(params)
|
40
|
+
@params = params
|
41
|
+
end
|
42
|
+
|
38
43
|
private
|
39
44
|
|
40
45
|
def handle_response(response)
|
46
|
+
puts ['URI ', response.uri].join if debug
|
47
|
+
|
41
48
|
case response
|
42
49
|
when Net::HTTPSuccess
|
43
50
|
response
|
data/lib/awis/models/base.rb
CHANGED
@@ -5,6 +5,14 @@ module Awis
|
|
5
5
|
class Base
|
6
6
|
attr_accessor :response, :status_code, :request_id
|
7
7
|
|
8
|
+
def initialize(response)
|
9
|
+
response_data = loading_response(response)
|
10
|
+
|
11
|
+
set_xml(response_data)
|
12
|
+
# Need to implement on sub-class
|
13
|
+
setup_data!(response_data)
|
14
|
+
end
|
15
|
+
|
8
16
|
def loading_response(response)
|
9
17
|
Awis::Utils::XML.new(response.response_body)
|
10
18
|
end
|
@@ -27,6 +35,21 @@ module Awis
|
|
27
35
|
def success?
|
28
36
|
status_code == 'Success'
|
29
37
|
end
|
38
|
+
|
39
|
+
def pretty_xml
|
40
|
+
doc = Nokogiri.XML(@xml.data) do |config|
|
41
|
+
config.default_xml.noblanks
|
42
|
+
end
|
43
|
+
puts doc.to_xml(:indent => 2)
|
44
|
+
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def set_xml(response)
|
51
|
+
@xml = response
|
52
|
+
end
|
30
53
|
end
|
31
54
|
end
|
32
55
|
end
|
data/lib/awis/models/url_info.rb
CHANGED
@@ -4,7 +4,7 @@ module Awis
|
|
4
4
|
module Models
|
5
5
|
class UrlInfo < Base
|
6
6
|
attr_accessor :data_url, :rank, :asin, :contact_info, :content_data, :usage_statistics, :related_links,
|
7
|
-
:categories, :
|
7
|
+
:categories, :contributing_subdomains, :rank_by_country
|
8
8
|
|
9
9
|
def initialize(response)
|
10
10
|
@usage_statistics = []
|
@@ -13,11 +13,10 @@ module Awis
|
|
13
13
|
@contributing_subdomains = []
|
14
14
|
@rank_by_country = []
|
15
15
|
|
16
|
-
|
16
|
+
super(response)
|
17
17
|
end
|
18
18
|
|
19
19
|
def setup_data!(response)
|
20
|
-
@xml = response
|
21
20
|
content_data = {
|
22
21
|
owned_domains: []
|
23
22
|
}
|
@@ -156,10 +155,6 @@ module Awis
|
|
156
155
|
relationship_collections(@contributing_subdomains, contributing_subdomains, 5, ContributingSubdomain)
|
157
156
|
end
|
158
157
|
|
159
|
-
def is_404?
|
160
|
-
success? && rank == 404
|
161
|
-
end
|
162
|
-
|
163
158
|
def init_entity_data(attr_name, data, kclass)
|
164
159
|
return if data.empty?
|
165
160
|
|
@@ -212,6 +207,11 @@ module Awis
|
|
212
207
|
@geos_hash ||= geos_sorted.reduce({}, :merge)
|
213
208
|
end
|
214
209
|
|
210
|
+
def not_found?
|
211
|
+
([content_data.data_url, content_data.site_title] & [404, '404']).size > 0
|
212
|
+
end
|
213
|
+
alias :is_404? :not_found?
|
214
|
+
|
215
215
|
def domains
|
216
216
|
content_data.owned_domains.map(&:domain)
|
217
217
|
end
|
@@ -241,10 +241,10 @@ module Awis
|
|
241
241
|
end
|
242
242
|
|
243
243
|
def daily_GDN_page_views
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
244
|
+
return unless rank
|
245
|
+
|
246
|
+
alexa_gdn.each do |max_pvs, gdn_range|
|
247
|
+
return gdn_range if rank > max_pvs
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
@@ -254,6 +254,7 @@ module Awis
|
|
254
254
|
return rating if get_median_load_time > max_load_time
|
255
255
|
end
|
256
256
|
end
|
257
|
+
|
257
258
|
'AVERAGE ( < 5s)'
|
258
259
|
end
|
259
260
|
|
@@ -312,7 +313,8 @@ module Awis
|
|
312
313
|
end
|
313
314
|
|
314
315
|
class ContentData < BaseEntity
|
315
|
-
attr_accessor :data_url, :site_title, :site_description, :online_since,
|
316
|
+
attr_accessor :data_url, :site_title, :site_description, :online_since,
|
317
|
+
:speed_median_load_time, :speed_percentile, :adult_content,
|
316
318
|
:language_locale, :links_in_count, :owned_domains
|
317
319
|
|
318
320
|
def initialize(options)
|
data/lib/awis/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awis-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Encore Shao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sigv4
|