plangrade-ruby 0.1.0 → 0.1.1

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: cb7fed01df975dd638af267527af1a719395e374
4
- data.tar.gz: d670aeca677569a9ca64cdbd929ebc935586f018
3
+ metadata.gz: e619eacc7d4a878d10fec701d501d8bf0ef296b4
4
+ data.tar.gz: 236a3735f4ce32ba02db731335bbeab08b80633c
5
5
  SHA512:
6
- metadata.gz: 0a9538c366ca0155f591587aae4769945ac4cd40b276121b53f0715dab701dd4ff76de6e7d2aec4c7469f12c7e1716c1f9b04cd49b52b83d393f001c466d6c65
7
- data.tar.gz: 78d5952db9f81ca1e191b10034f149281f7ae325db55a86416b4ce4415a59eb9ed0b61ff2077f8dc57a377bf54f85617c93eddcaafcc0f76b7c1b84a9a369833
6
+ metadata.gz: 288c51bd0973e2380d1ebc1b78736c3f6b53d44ec8c6f5d21cd1da6b2ceac48c1fd54d83ea13d04a896999feff3d038a4de17ec0ac60200cf74c27f8e4bfefab
7
+ data.tar.gz: d1fcfe4ff3e727c1c5b90477df4fb53db1c9561ace5d3ceb0696b2a9347ba0bd4f94f1b4f0ae47146511c434b4624af0df9104966c65af03e1288270c5b66214
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -1,24 +1,28 @@
1
- # Plangrade::Ruby
1
+ # plangrade API Gem
2
+ [![Gem Version](https://badge.fury.io/rb/plangrade-ruby.svg)](http://badge.fury.io/rb/plangrade-ruby)
3
+ [![Code Climate](https://codeclimate.com/github/topherreynoso/plangrade-ruby/badges/gpa.svg)](https://codeclimate.com/github/topherreynoso/plangrade-ruby)
2
4
 
3
- TODO: Write a gem description
5
+ Ruby wrapper for the plangrade API.
6
+ Supports OAuth 2.0 authentication, including `refresh_token`. Read the [plangrade docs](https://docs.plangrade.com/#authentication) for more details. Additionally, this may be used in conjunction with [omniauth-plangrade](https://github.com/topherreynoso/omniauth-plangrade) in order to facilitate authentication and obtaining a valid `access_token` and `refresh_token` pair for use with this gem to access plangrade API endpoints.
7
+ This README provides only a basic overview of how to use this gem. For more information about the API endpoints, look at the [plangrade docs](https://docs.plangrade.com/#authentication).
4
8
 
5
- ## Installation
9
+ ## Installing
6
10
 
7
- Add this line to your application's Gemfile:
11
+ Add oauth2 and this line to your application's Gemfile:
8
12
 
9
13
  gem 'plangrade-ruby'
10
14
 
11
15
  And then execute:
12
16
 
13
- $ bundle
17
+ $ bundle install
14
18
 
15
- Or install it yourself as:
19
+ ## Configuration
16
20
 
17
- $ gem install plangrade-ruby
21
+ The plangrade API requires authentication for access to certain endpoints. Below are the basic steps to get this done.
18
22
 
19
- ## Usage
23
+ ### Register your application
20
24
 
21
- TODO: Write usage instructions here
25
+ Setup a plangrade client application at the [plangrade developer site](https://plangrade.com/oauth/applications).
22
26
 
23
27
  ## Contributing
24
28
 
@@ -27,3 +31,87 @@ TODO: Write usage instructions here
27
31
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
32
  4. Push to the branch (`git push origin my-new-feature`)
29
33
  5. Create a new Pull Request
34
+
35
+
36
+
37
+ plangrade OAuth2 strategy for OmniAuth.
38
+ Supports the OAuth 2.0 server-side and client-side flows. Read the plangrade docs for more details: [docs.plangrade.com](https://docs.plangrade.com/#authentication). Additionally, this may be used in conjunction with [plangrade-ruby](https://github.com/topherreynoso/plangrade-ruby) in order to refresh tokens and access plangrade API endpoints.
39
+
40
+ ## Installing
41
+
42
+ Add omniauth-oauth2 and this line to your application's Gemfile:
43
+
44
+ gem 'omniauth-plangrade'
45
+
46
+ Then execute:
47
+
48
+ $ bundle install
49
+
50
+ ## Usage
51
+
52
+ `OmniAuth::Strategies::Plangrade` is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: [https://github.com/intridea/omniauth](https://github.com/intridea/omniauth).
53
+
54
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
55
+
56
+ ```ruby
57
+ Rails.application.config.middleware.use OmniAuth::Builder do
58
+ provider :plangrade, ENV['PLANGRADE_CLIENT_ID'], ENV['PLANGRADE_CLIENT_SECRET']
59
+ end
60
+ ```
61
+
62
+ [See the example rails app for full examples](https://github.com/topherreynoso/plangrade-ruby-client) of both the server and client-side flows.
63
+
64
+ ## Auth Hash
65
+
66
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
67
+
68
+ ```ruby
69
+ {
70
+ :provider => 'plangrade',
71
+ :uid => '1234567',
72
+ :info => {
73
+ :name => 'Compliance Man',
74
+ :email => 'compliance@plangrade.com',
75
+ },
76
+ :credentials => {
77
+ :token => 'ABCDEF...', # OAuth 2.0 access_token, which you may wish to store
78
+ :refresh_token => 'ABCDEF...', #OAuth 2.0 refresh_token, which you may wish to store
79
+ :expires_at => 1321747205, # when the access token expires (it always will)
80
+ :expires => true # this will always be true
81
+ },
82
+ :extra => {
83
+ :raw_info => {
84
+ :id => '1234567',
85
+ :name => 'Compliance Man',
86
+ :email => 'compliance@plangrade.com',
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ ### How it Works
93
+
94
+ The client-side flow is supported by parsing the authorization code from the signed request which plangrade places in a cookie.
95
+
96
+ When you call `/auth/plangrade/callback`, the success callback will pass the cookie back to the server. omniauth-plangrade will see this cookie and:
97
+
98
+ 1. parse it,
99
+ 2. extract the authorization code contained in it,
100
+ 3. and hit plangrade and obtain an access token which will get placed in the `request.env['omniauth.auth']['credentials']` hash.
101
+
102
+ ## Token Expiry
103
+
104
+ The expiration time of the access token you obtain is 2 hours.
105
+ The refresh_token, however, has no expiration and may be used until a user revokes your app's access.
106
+
107
+ ## License
108
+
109
+ Copyright (c) 2014 Christopher Reynoso
110
+
111
+ MIT License
112
+
113
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
114
+
115
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
116
+
117
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -6,7 +6,7 @@ module Plangrade
6
6
  end
7
7
 
8
8
  def update_company(id, opts={})
9
- put("/api/v1/companies/#{id}", opts)
9
+ put("/api/v1/companies/#{id}", opts).body[:company]
10
10
  end
11
11
 
12
12
  def delete_company(id)
@@ -6,7 +6,7 @@ module Plangrade
6
6
  end
7
7
 
8
8
  def update_participant(id, opts={})
9
- put("/api/v1/participants/#{id}", opts)
9
+ put("/api/v1/participants/#{id}", opts).body[:participant]
10
10
  end
11
11
 
12
12
  def delete_participant(id)
@@ -14,7 +14,7 @@ module Plangrade
14
14
  end
15
15
 
16
16
  def archive_participant(id)
17
- get("api/v1/participants/archive?participant_id=#{id}").body
17
+ get("api/v1/participants/archive?participant_id=#{id}")
18
18
  end
19
19
 
20
20
  def get_participant(id)
@@ -6,7 +6,7 @@ module Plangrade
6
6
  end
7
7
 
8
8
  def update_user(id, opts={})
9
- put("/api/v1/users/#{id}", opts)
9
+ put("/api/v1/users/#{id}", opts).body[:user]
10
10
  end
11
11
 
12
12
  def delete_user(id)
@@ -72,7 +72,6 @@ module Plangrade
72
72
  # client_id={client_id}&code=G3Y6jU3a&grant_type=authorization_code&
73
73
  # redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fplangrade%2Fcallback&client_secret={client_secret}
74
74
  def access_token_from_authorization_code(code, opts={})
75
- opts[:authenticate] ||= :body
76
75
  authorization_code.get_token(code, opts)
77
76
  end
78
77
 
@@ -1,5 +1,5 @@
1
1
  module Plangrade
2
2
  module Ruby
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
data.tar.gz.sig CHANGED
@@ -1,6 +1 @@
1
- q�r����Dw��E\��8OW8j6\i�wc��ty
2
- ���KfWj2�����3#Ă���75�qm:����8�~�ß
3
- PI�[Y�|6;��9̬ۤq����j۰FA�L#N�������|ڽ�=��"0�
4
- eZ^c�
5
-
6
- �u�⾟�󎳚p�v� �pd����\T4tu�M��`|�}@!뇒�⚻f��m�A�mo=�ŧK
1
+ ����؄7�Ba%����VU?:J{�y�#|+���q��@1�ھi�������bVb��7Ƹ�K���ĝ8 oi8䫗l�����ݽ�7�\���'��G1���N4`�1�g{n�D4Zy )nL��>Sx_j*���U�jГ�~WB������޺P4y����E;�K㊵��`�� �۸�����j���p}�H{�
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plangrade-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Reynoso
@@ -30,7 +30,7 @@ cert_chain:
30
30
  ELzPS5fItQUB4UE0DT9qDr7LmfnG1tLPIeDgMScUes6zSSckWtaXKjQRy7OG7yGu
31
31
  2YveeRgxu2nn/J4Q6Obf7PqMvpR0z5T8SUptXcRVhHBZDUzrBpNvtNM=
32
32
  -----END CERTIFICATE-----
33
- date: 2014-11-10 00:00:00.000000000 Z
33
+ date: 2014-11-11 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: bundler
@@ -264,4 +264,3 @@ test_files:
264
264
  - test/fixtures/one_user.yml
265
265
  - test/test_helper.rb
266
266
  - test/user/user_test.rb
267
- has_rdoc:
metadata.gz.sig CHANGED
Binary file