spinacz 0.0.2 → 0.0.6
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/lib/spinacz/client.rb +18 -7
- data/lib/spinacz/errors.rb +1 -0
- data/lib/spinacz/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 439afa41a814152f9659815e93aaa929f7e1ecea
|
4
|
+
data.tar.gz: 0b6a1c82108c98915d15df69ad0adc5f0bdbc31a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d740d3acf2d99b58a6d7824ca74fc7b53a57ce84d2b0c4c3ffc830c24c44304f59bd78fd78ccdb9871ba69f1b3e59ec1fbc0ad148d80c3836b90b7ad4fc20bf
|
7
|
+
data.tar.gz: c2ada1f0ad87c427fe932096b20b7989761c0979b49ff45ccae159876c2d986b51825ed439830cc5cec5b92935339494abead55a0306113974cba3b2a4845559
|
data/lib/spinacz/client.rb
CHANGED
@@ -5,11 +5,11 @@ module Spinacz
|
|
5
5
|
URL = 'https://spinacz.pl'
|
6
6
|
|
7
7
|
def initialize(credentials = {})
|
8
|
-
@email = credentials[:email] ||
|
8
|
+
@email = credentials[:email] || ENV['SPINACZ_EMAIL']
|
9
9
|
@email = @email.strip if @email
|
10
|
-
@password = credentials[:password] ||
|
10
|
+
@password = credentials[:password] || ENV['SPINACZ_PASSWORD']
|
11
11
|
@password = @password.strip if @password
|
12
|
-
@token = credentials[:token] ||
|
12
|
+
@token = credentials[:token] || ENV['SPINACZ_TOKEN']
|
13
13
|
@token = @token.strip if @token
|
14
14
|
end
|
15
15
|
|
@@ -97,13 +97,24 @@ module Spinacz
|
|
97
97
|
end
|
98
98
|
|
99
99
|
response = conn.send(call_type) do |req|
|
100
|
-
|
101
|
-
|
100
|
+
if call_type == :get
|
101
|
+
req.url endpoint, json_data
|
102
|
+
else
|
103
|
+
req.url endpoint
|
104
|
+
req.body = json_data_converted
|
105
|
+
end
|
106
|
+
|
107
|
+
# req.headers['Content-Type'] = 'application/json'
|
102
108
|
req.headers['Authorization'] = @token if @token.present?
|
103
|
-
req.body = json_data_converted if req.method == :post
|
104
109
|
end
|
105
110
|
|
106
|
-
JSON.parse(response.body)
|
111
|
+
body = JSON.parse(response.body)
|
112
|
+
|
113
|
+
if body['error'].nil?
|
114
|
+
body['success']
|
115
|
+
else
|
116
|
+
raise Spinacz::ParametersInvalidError, 'wrong parameters provided'
|
117
|
+
end
|
107
118
|
end
|
108
119
|
|
109
120
|
def check_credentials
|
data/lib/spinacz/errors.rb
CHANGED
data/lib/spinacz/version.rb
CHANGED