closeio 0.0.14 → 1.0.0

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: 8e0648bd0375689ef1853b50f5601027b23cd14f
4
- data.tar.gz: 4bd978aa34f085e457e4e039fcfb6ddc8679af10
3
+ metadata.gz: b8a7a4b35e0d609b13ec45b4fd743ddfc82eb7d9
4
+ data.tar.gz: 60c26a812eb6fc5d5d2fecd4e2c286073b6017da
5
5
  SHA512:
6
- metadata.gz: b587454b09c9f58e222743b9adf6acbb8cd532e306f447c6b41b5c79106997af504617dc1fad24cd96bfb05c2ac5ffe04c441a2a963bf079cc1f71f4f0c86db8
7
- data.tar.gz: 2239a9adf7de9bf17b499af45d718529845156aa0416882c387ff45d2674690d43e8883feed76532d27a155d2a72f3a719e902f249668495ef6db6f660d3e3e8
6
+ metadata.gz: 75d9f6b832bc73cbc5237c45418643e6a04933642b73352e1bed8e35efad0a7631054e24e5f22498af24ad133e97b1bd8c2b726e4d26f1335f1cabafc679cb41
7
+ data.tar.gz: edd1e41ba79df58e83d0402c27d710c3325f83781f86cfa147c044f5f34c2d3134d1fdb83efd747cb4d33655a5777317c9157ee5cf6a37cee6bfbdbe5a848788
data/README.md CHANGED
@@ -11,13 +11,8 @@ Add this line to your application's Gemfile:
11
11
  # then...
12
12
  bundle install
13
13
 
14
- # Add your Close.io api key as an ENV variable
15
- ENV['CLOSEIO_API_KEY']='xxxxxxxx'
16
-
17
- # or if you're using Rails
18
- 1. Create a `closeio.yml` file
19
- 2. Set `api_key:` to your Closeio api key
20
- 3. Place it in `/config/initializers/`
14
+ # Set your Api Key (in a `config/initializer` or `config/environment/*`)
15
+ Closeio.configure("xxxxxx")
21
16
  ````
22
17
 
23
18
  ### Usage
data/lib/closeio.rb CHANGED
@@ -22,3 +22,9 @@ require 'closeio/user'
22
22
  require 'closeio/version'
23
23
  require 'closeio/config'
24
24
  require 'closeio/railtie' if defined?(Rails)
25
+
26
+ module Closeio
27
+ def self.configure(api_key=nil)
28
+ Base.configure(api_key)
29
+ end
30
+ end
data/lib/closeio/base.rb CHANGED
@@ -3,7 +3,6 @@ module Closeio
3
3
 
4
4
  include HTTParty
5
5
  base_uri 'https://app.close.io/api/v1'
6
- basic_auth ENV['CLOSEIO_API_KEY'], ''
7
6
  headers 'Content-Type' => 'application/json'
8
7
  #debug_output $stdout
9
8
  format :json
@@ -26,11 +25,16 @@ module Closeio
26
25
  end
27
26
 
28
27
  class << self
29
- def bad_response response
30
- if response.class == HTTParty::Response
31
- raise HTTParty::ResponseError, response
32
- end
33
- raise StandardError, 'Unknown error'
28
+ def configure(api_key)
29
+ @default_options.merge!(basic_auth: {
30
+ username: api_key,
31
+ password: ''
32
+ })
33
+ end
34
+
35
+ def bad_response(response)
36
+ raise "Unauthorized" if response.values.include? "Unauthorized"
37
+ raise response
34
38
  end
35
39
 
36
40
  def all response = nil, opts={}
@@ -39,7 +43,7 @@ module Closeio
39
43
  if res.success?
40
44
  res['data'].nil? ? [] : res['data'].map{|obj| new(obj)}
41
45
  else
42
- bad_response res
46
+ bad_response(res)
43
47
  end
44
48
  end
45
49
 
@@ -1,3 +1,3 @@
1
1
  module Closeio
2
- VERSION = "0.0.14"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: closeio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Brooks