awis-sdk-ruby 0.1.0 → 0.1.1
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.
- data/README.md +4 -1
- data/lib/awis/api/base.rb +1 -1
- data/lib/awis/config.rb +4 -4
- data/lib/awis/connection.rb +32 -8
- data/lib/awis/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -19,7 +19,10 @@ Awis.config do |c|
|
|
19
19
|
c.access_key_id = AWIS_CONFIG['access_key_id']
|
20
20
|
c.secret_access_key = AWIS_CONFIG['secret_access_key']
|
21
21
|
c.debug = AWIS_CONFIG['debug']
|
22
|
-
c.protocol = 'https'
|
22
|
+
c.protocol = 'https' # Default 'https'
|
23
|
+
c.timeout = 5 # Default 5
|
24
|
+
c.open_timeout = 5 # Default 2
|
25
|
+
c.logger = false # Default nil
|
23
26
|
end
|
24
27
|
```
|
25
28
|
|
data/lib/awis/api/base.rb
CHANGED
data/lib/awis/config.rb
CHANGED
@@ -3,13 +3,13 @@ require "singleton"
|
|
3
3
|
module Awis
|
4
4
|
class Config
|
5
5
|
include Singleton
|
6
|
-
attr_accessor :access_key_id, :secret_access_key, :proxy, :debug, :protocol
|
6
|
+
attr_accessor :access_key_id, :secret_access_key, :proxy, :debug, :protocol,
|
7
|
+
:timeout, :open_timeout, :logger
|
7
8
|
end
|
8
9
|
|
9
10
|
def self.config
|
10
|
-
if block_given?
|
11
|
-
|
12
|
-
end
|
11
|
+
yield Config.instance if block_given?
|
12
|
+
|
13
13
|
Config.instance
|
14
14
|
end
|
15
15
|
end
|
data/lib/awis/connection.rb
CHANGED
@@ -13,8 +13,14 @@ module Awis
|
|
13
13
|
def initialize
|
14
14
|
raise CertificateError.new("Amazon access certificate is missing!") if Awis.config.access_key_id.nil? || Awis.config.secret_access_key.nil?
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
setup_options!
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup_options!
|
20
|
+
@debug = Awis.config.debug || false
|
21
|
+
@protocol = Awis.config.protocol || 'https'
|
22
|
+
@timeout = Awis.config.timeout || 5
|
23
|
+
@open_timeout = Awis.config.open_timeout || 2
|
18
24
|
end
|
19
25
|
|
20
26
|
def params
|
@@ -49,13 +55,23 @@ module Awis
|
|
49
55
|
end
|
50
56
|
|
51
57
|
def request
|
52
|
-
|
58
|
+
connection = Faraday.new(url: host_with_port) do |faraday|
|
59
|
+
faraday.request :url_encoded # form-encode POST params
|
60
|
+
faraday.response :logger do |logger|
|
61
|
+
logger.filter(/(AWSAccessKeyId=)(\w+)/, '\1[REMOVED]')
|
62
|
+
end if Awis.config.logger
|
63
|
+
faraday.adapter :net_http
|
64
|
+
end
|
53
65
|
|
54
|
-
|
66
|
+
connection.get do |req|
|
67
|
+
req.url url_params
|
68
|
+
req.options.open_timeout = @timeout
|
69
|
+
req.options.timeout = @open_timeout
|
70
|
+
end
|
55
71
|
end
|
56
72
|
|
57
|
-
def
|
58
|
-
|
73
|
+
def host_with_port
|
74
|
+
protocol + '://' + Awis::API_HOST
|
59
75
|
end
|
60
76
|
|
61
77
|
def timestamp
|
@@ -66,8 +82,12 @@ module Awis
|
|
66
82
|
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new("sha256"), Awis.config.secret_access_key, sign)).strip
|
67
83
|
end
|
68
84
|
|
69
|
-
def
|
70
|
-
|
85
|
+
def url_params
|
86
|
+
'?' + original_params
|
87
|
+
end
|
88
|
+
|
89
|
+
def request_url
|
90
|
+
URI.parse(host_with_port + url_params)
|
71
91
|
end
|
72
92
|
|
73
93
|
def default_params
|
@@ -87,5 +107,9 @@ module Awis
|
|
87
107
|
def query_params
|
88
108
|
default_params.merge(params).map { |key, value| "#{key}=#{CGI::escape(value.to_s)}" }.sort.join("&")
|
89
109
|
end
|
110
|
+
|
111
|
+
def original_params
|
112
|
+
query_params + "&Signature=" + CGI::escape(signature)
|
113
|
+
end
|
90
114
|
end
|
91
115
|
end
|
data/lib/awis/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awis-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-08-
|
12
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_xml
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
version: '0'
|
168
168
|
segments:
|
169
169
|
- 0
|
170
|
-
hash:
|
170
|
+
hash: 862568070736027421
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project:
|
173
173
|
rubygems_version: 1.8.23
|