spinacz 0.0.2 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abfaae33e5afb1849ea7176580cbfad7e99c43f0
4
- data.tar.gz: 9e26db1407a20c3b29fa99c91176bf8851172573
3
+ metadata.gz: 439afa41a814152f9659815e93aaa929f7e1ecea
4
+ data.tar.gz: 0b6a1c82108c98915d15df69ad0adc5f0bdbc31a
5
5
  SHA512:
6
- metadata.gz: ab53c2022d2210bb8436bb76d900e0a3272527a51794e4396bef860b116430b343878e6c7819a358ac002680ecdbc8a329a4192f41bebaa7fc5f8b94adb7c6a3
7
- data.tar.gz: 93697fdcc105e950abe145362d129f2d516b7038e883af97b2d3128c68b839f3b08aedead541d7f30349ed0f2e77153377ba573d471f305be6d67b256b3086f2
6
+ metadata.gz: 6d740d3acf2d99b58a6d7824ca74fc7b53a57ce84d2b0c4c3ffc830c24c44304f59bd78fd78ccdb9871ba69f1b3e59ec1fbc0ad148d80c3836b90b7ad4fc20bf
7
+ data.tar.gz: c2ada1f0ad87c427fe932096b20b7989761c0979b49ff45ccae159876c2d986b51825ed439830cc5cec5b92935339494abead55a0306113974cba3b2a4845559
@@ -5,11 +5,11 @@ module Spinacz
5
5
  URL = 'https://spinacz.pl'
6
6
 
7
7
  def initialize(credentials = {})
8
- @email = credentials[:email] || self.class.email || ENV['SPINACZ_EMAIL']
8
+ @email = credentials[:email] || ENV['SPINACZ_EMAIL']
9
9
  @email = @email.strip if @email
10
- @password = credentials[:password] || self.class.password || ENV['SPINACZ_PASSWORD']
10
+ @password = credentials[:password] || ENV['SPINACZ_PASSWORD']
11
11
  @password = @password.strip if @password
12
- @token = credentials[:token] || self.class.token || ENV['SPINACZ_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
- req.url endpoint
101
- req.headers['Content-Type'] = 'application/json'
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
@@ -1,4 +1,5 @@
1
1
  module Spinacz
2
2
  class CredentialsMissingError < StandardError; end
3
3
  class CredentialsInvalidError < StandardError; end
4
+ class ParametersInvalidError < StandardError; end
4
5
  end
@@ -1,3 +1,3 @@
1
1
  module Spinacz
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spinacz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Jan Adamczyk