cubits 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/README.md +1 -1
- data/cubits.gemspec +1 -1
- data/lib/cubits/connection.rb +27 -3
- data/lib/cubits/helpers.rb +2 -1
- data/lib/cubits/version.rb +1 -1
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e681c887f584d39661aeadad10c1e297abad0ab
|
4
|
+
data.tar.gz: 1cc90230a6bfae073d6ec6ba23a314fcf518f4f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef1a5b930c12ab8dc276eeb8a56552c2a616fd88f773b1d0711cb2318d1a4ff496d1ea4b9a8d63c759a7241a61b582b2354c184f13305b40181ebb4d2b53323d
|
7
|
+
data.tar.gz: acc7922ad9ed67ccba6a1c5525cc0459525dc75a8c7531a07b62032d4893063bfcba361e3f4c38b862ab396b14a39bb609eb966fcccb39f665015d3ebb7cd75b
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -58,7 +58,7 @@ invoice.address # => "3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC"
|
|
58
58
|
|
59
59
|
Creates a new invoice.
|
60
60
|
|
61
|
-
For a list of accepted and returned parameters, see the `POST /api/v1/invoices` page in the [Cubits Help Center](https://cubits.com
|
61
|
+
For a list of accepted and returned parameters, see the `POST /api/v1/invoices` page in the [Cubits Help Center](https://cubits.com) Developer's section.
|
62
62
|
|
63
63
|
|
64
64
|
```ruby
|
data/cubits.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'http', '~> 0.7'
|
21
|
+
spec.add_dependency 'http', '~> 0.7', '>= 0.7.3'
|
22
22
|
spec.add_dependency 'hashie', '~> 3.3'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
data/lib/cubits/connection.rb
CHANGED
@@ -19,6 +19,7 @@ module Cubits
|
|
19
19
|
fail ArgumentError, 'String is expected as :secret' unless params[:secret].is_a?(String)
|
20
20
|
@key = params[:key]
|
21
21
|
@secret = params[:secret]
|
22
|
+
@params = params.dup
|
22
23
|
end
|
23
24
|
|
24
25
|
# Executes a GET request
|
@@ -42,12 +43,17 @@ module Cubits
|
|
42
43
|
# Sends a request to the API
|
43
44
|
#
|
44
45
|
def request(method, path, encoded_data)
|
46
|
+
Cubits.logger.warn 'Connecting to Cubits using insecure connection!' if insecure?
|
45
47
|
url = URI.join(Cubits.base_url, path)
|
46
|
-
url.query = encoded_data if method == :get && !encoded_data.empty?
|
47
48
|
params = {}
|
48
49
|
http = HTTP.with(cubits_headers(path, encoded_data))
|
49
|
-
|
50
|
-
|
50
|
+
if method == :get
|
51
|
+
url.query = encoded_data unless encoded_data.empty?
|
52
|
+
else
|
53
|
+
http = http.with('Content-Type' => CONTENT_TYPE)
|
54
|
+
params[:body] = encoded_data
|
55
|
+
end
|
56
|
+
params[:ssl_context] = ssl_context unless insecure?
|
51
57
|
Cubits.logger.debug "> #{method.to_s.upcase}: #{url}"
|
52
58
|
response = http.send(method, url, params)
|
53
59
|
Cubits.logger.debug "< #{response.code} #{response.reason}"
|
@@ -118,5 +124,23 @@ module Cubits
|
|
118
124
|
"path=#{path} nonce=#{nonce} request_data=#{request_data} msg=#{msg} signature=#{signature}"
|
119
125
|
signature
|
120
126
|
end
|
127
|
+
|
128
|
+
# Returns configured SSLContext
|
129
|
+
#
|
130
|
+
def ssl_context
|
131
|
+
return @ssl_context if @ssl_context
|
132
|
+
@ssl_context = OpenSSL::SSL::SSLContext.new
|
133
|
+
@ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
134
|
+
cert_store = OpenSSL::X509::Store.new
|
135
|
+
cert_store.set_default_paths
|
136
|
+
@ssl_context.cert_store = cert_store
|
137
|
+
@ssl_context
|
138
|
+
end
|
139
|
+
|
140
|
+
# Returns true if an insecure connection is requested (do NOT use in production)
|
141
|
+
#
|
142
|
+
def insecure?
|
143
|
+
@insecure ||= @params[:insecure] || Cubits.base_url.scheme != 'https'
|
144
|
+
end
|
121
145
|
end # class Connection
|
122
146
|
end # module Cubits
|
data/lib/cubits/helpers.rb
CHANGED
@@ -8,7 +8,8 @@ module Cubits
|
|
8
8
|
Cubits.connection.get('/api/v1/test', foo: 'bar')
|
9
9
|
Cubits.connection.post('/api/v1/test', foo: 'bar')
|
10
10
|
true
|
11
|
-
rescue StandardError
|
11
|
+
rescue StandardError => e
|
12
|
+
Cubits.logger.error "Test connection to Cubits failed: #{e}"
|
12
13
|
false
|
13
14
|
end
|
14
15
|
|
data/lib/cubits/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cubits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Kukushkin
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.7'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.7.3
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0.7'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.7.3
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: hashie
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|