cronofy 0.5.1 → 0.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d0afe819b273745fd9fb45e994b4835cabdc550
4
- data.tar.gz: d33b65a5ec924612d396005c50e865bf5c9f8d1b
3
+ metadata.gz: 2ae2a778d8655f5597b36536b2863ea149b65ca7
4
+ data.tar.gz: a8b1bcb188baeebfe217c5604c7610afda612f70
5
5
  SHA512:
6
- metadata.gz: c3aca358170c157673ae3922a67d9b26b81802ecf8d3b0181f0da515c8994362df822fddd464f4977570e6de961ff49aee8f7eee2aa2f45fbc880f4d2ebe7c06
7
- data.tar.gz: 1e5df32e5963153b92e472a5d60f7f7e84d675cfdfbd8598a79788caaa8f23de003d84ea402a0f8afbb6694cf5013c8df9b17388d2072c592b13cfcec3aadc48
6
+ metadata.gz: bf72f4d548b137c384258013ea0096b7756c0e712b0f2f9c509be671c2678bf673d9358104dfb0b21f71acfa12ece8f1419b42fe4882fe2e6bee5fe50ed9be7c
7
+ data.tar.gz: d807871a023cc56bb82cd165bafd474cdda14cb6ff9bce1743f69ac5892b65958c64f9a6f205a8365382823c4dd95aa1ab682218ce25fa7f68e6df2412131ef7
data/lib/cronofy/auth.rb CHANGED
@@ -6,6 +6,8 @@ module Cronofy
6
6
  attr_reader :access_token
7
7
 
8
8
  def initialize(client_id, client_secret, token = nil, refresh_token = nil)
9
+ @client_credentials_missing = blank?(client_id) || blank?(client_secret)
10
+
9
11
  @auth_client = OAuth2::Client.new(client_id, client_secret, site: ::Cronofy.app_url, connection_opts: { headers: { "User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}" } })
10
12
  @api_client = OAuth2::Client.new(client_id, client_secret, site: ::Cronofy.api_url, connection_opts: { headers: { "User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}" } })
11
13
 
@@ -81,9 +83,16 @@ module Cronofy
81
83
  private
82
84
 
83
85
  def do_request(&block)
86
+ if @client_credentials_missing
87
+ raise CredentialsMissingError.new("OAuth client_id and client_secret must be set")
88
+ end
84
89
  block.call
85
90
  rescue OAuth2::Error => e
86
91
  raise Errors.map_error(e)
87
92
  end
93
+
94
+ def blank?(value)
95
+ value.nil? || value.strip.empty?
96
+ end
88
97
  end
89
98
  end
@@ -1,3 +1,3 @@
1
1
  module Cronofy
2
- VERSION = "0.5.1".freeze
2
+ VERSION = "0.5.2".freeze
3
3
  end
@@ -163,6 +163,15 @@ describe Cronofy::Auth do
163
163
  expect{ subject }.to raise_error(Cronofy::UnknownError)
164
164
  end
165
165
  end
166
+
167
+ context "client_id and client_secret not set" do
168
+ let(:client_id) { " " }
169
+ let(:client_secret) { " " }
170
+
171
+ it "throws a credentials missing error" do
172
+ expect { subject }.to raise_error(Cronofy::CredentialsMissingError, "OAuth client_id and client_secret must be set")
173
+ end
174
+ end
166
175
  end
167
176
  end
168
177
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cronofy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergii Paryzhskyi