plangrade-ruby 0.2.0 → 0.3.0

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: b4534d0455ce323b5b9a3895c1cb98889da6bb52
4
- data.tar.gz: ad8e35b7ce70f104c6981c7d78394a3ebcfa2113
3
+ metadata.gz: f586e34e9b14bdbf1876bf3ef5a529796c851ac7
4
+ data.tar.gz: 26ddeaa6b6ede4f906b6e3373b19530f55fa8836
5
5
  SHA512:
6
- metadata.gz: 79a7c8509b7571d148eedc7de8ca6e29068f922f7d7097134e1963bdd608697cba738083c10832cfa15ea041cce9847ed8830b282e5bef49deefe87ec94ad382
7
- data.tar.gz: 1f84282566199f2d4063b70f7b25ff6570a44011ea1801e7f50882867039fb46b451794cefdc77b82cc342dde652271645b979dd076fd30b4c45e24d586bdf99
6
+ metadata.gz: 1df7976f370ea8d7efa29844e5b4e4158ac3c4e72aa11ba2e33f0d17e03d9156288fb3231a801916fae78811edbf89d3ced681e35ee613b6e4f7841357580429
7
+ data.tar.gz: d333fce2d7a39b241eda7480ab5e382cb18634baa47e1675e7d757eb0615d6d05ede65af02a81b962f2c2f8bff73f550d26588bfd26da0353569ea714293960e
checksums.yaml.gz.sig CHANGED
Binary file
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ bin/
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
@@ -15,6 +16,7 @@ spec/reports
15
16
  test/tmp
16
17
  test/version_tmp
17
18
  tmp
19
+ vendor/bundle
18
20
  *.bundle
19
21
  *.so
20
22
  *.o
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - jruby
7
+
8
+ branches:
9
+ only:
10
+ - master
11
+ before_install:
12
+ - gem update --system
13
+ - gem --version
14
+
15
+ notifications:
16
+ email:
17
+ recipients:
18
+ - topherreynoso@gmail.com
19
+ on_failure: change
20
+ on_success: never
data/Gemfile CHANGED
@@ -1,4 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ group :test do
4
+ gem 'rspec', '>= 2.11'
5
+ gem 'simplecov', :require => false
6
+ gem 'coveralls', :require => false
7
+ gem 'webmock', '>= 1.10.1'
8
+ end
9
+
3
10
  # Specify your gem's dependencies in plangrade-ruby.gemspec
4
11
  gemspec
data/README.md CHANGED
@@ -3,12 +3,18 @@
3
3
  [![Code Climate](https://codeclimate.com/github/topherreynoso/plangrade-ruby/badges/gpa.svg)](https://codeclimate.com/github/topherreynoso/plangrade-ruby)
4
4
 
5
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.
6
+
7
+ Supports OAuth 2.0 authentication, including `refresh_token`. Read the [plangrade docs](https://docs.plangrade.com/#authentication) for more details.
8
+
9
+ 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.
10
+
11
+ See the [plangrade-ruby-client](https://github.com/topherreynoso/plangrade-ruby-client) example for implementation of both omniauth-plangrade and plangrade-ruby.
12
+
7
13
  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).
8
14
 
9
15
  ## Installing
10
16
 
11
- Add oauth2 and this line to your application's Gemfile:
17
+ Add this line to your application's Gemfile:
12
18
 
13
19
  gem 'plangrade-ruby'
14
20
 
@@ -22,87 +28,218 @@ The plangrade API requires authentication for access to certain endpoints. Below
22
28
 
23
29
  ### Register your application
24
30
 
25
- Setup a plangrade client application at the [plangrade developer site](https://plangrade.com/oauth/applications).
31
+ Setup a plangrade client application at the [plangrade developer site](https://plangrade.com/oauth/applications).
26
32
 
27
- ## Contributing
33
+ ### Using omniauth-plangrade to obtain an access token
28
34
 
29
- 1. Fork it ( https://github.com/[my-github-username]/plangrade-ruby/fork )
30
- 2. Create your feature branch (`git checkout -b my-new-feature`)
31
- 3. Commit your changes (`git commit -am 'Add some feature'`)
32
- 4. Push to the branch (`git push origin my-new-feature`)
33
- 5. Create a new Pull Request
35
+ You can use [omniauth-plangrade](https://github.com/topherreynoso/omniauth-plangrade) to obtain a valid access token, as demonstrated below.
34
36
 
37
+ ```ruby
38
+ # In your redirect_uri after the user authorized access, just parse the omniauth response
39
+ auth = request.env["omniauth.auth"]
40
+ access_token = auth["credentials"]["token"]
41
+ refresh_token = auth["credentials"]["refresh_token"]
42
+ ```
35
43
 
44
+ ### Using plangrade-ruby OAuth2 Client to obtain an access token
36
45
 
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.
46
+ This gem comes bundled with an OAuth2 wrapper that provides convenience methods for getting through the OAuth2 flow.
39
47
 
40
- ## Installing
48
+ ```ruby
49
+ # Be sure to require plangrade in any controller where you utilize plangrade-ruby
50
+ require 'plangrade'
41
51
 
42
- Add omniauth-oauth2 and this line to your application's Gemfile:
52
+ # Begin by getting the authorization url
53
+ plangrade_client = Plangrade::OAuth2Client.new(ENV['PLANGRADE_CLIENT_ID'], ENV['PLANGRADE_CLIENT_SECRET'])
54
+ auth_url = plangrade_client.webserver_authorization_url(:redirect_uri => 'your_redirect_uri')
55
+ ```
43
56
 
44
- gem 'omniauth-plangrade'
57
+ After the user follows the link created above and authorizes your app, they will be redirected to your `redirect_uri`, with a code in the params that you can use to obtain an access token.
45
58
 
46
- Then execute:
59
+ ```ruby
60
+ plangrade_client = Plangrade::OAuth2Client.new(ENV['PLANGRADE_CLIENT_ID'], ENV['PLANGRADE_CLIENT_SECRET'])
61
+ response = plangrade_client.exchange_auth_code_for_token({:params => {:code => params[:code], :redirect_uri => 'your_redirect_uri'}})
62
+ token = JSON.parse response.body
63
+ access_token = token["access_token"]
64
+ refresh_token = token["refresh_token"]
65
+ ```
47
66
 
48
- $ bundle install
67
+ You may want to store the `access_token` since it is good for two hours. You may also want to store the `refresh_token` since it can be used to get a new `access_token` at any time, so long as the user does not revoke your app's authorization.
68
+
69
+ ### Using a stored `refresh_token` to obtain an access token
70
+
71
+ This gem also allows you to use a `refresh_token` to obtain a new `access_token`.
72
+
73
+ ```ruby
74
+ # Set up a plangrade OAuth2 client and retrieve your refresh_token
75
+ plangrade_client = Plangrade::OAuth2Client.new(ENV['PLANGRADE_CLIENT_ID'], ENV['PLANGRADE_CLIENT_SECRET'])
76
+ response = plangrade_client.refresh_access_token({:params => {:refresh_token => 'your_refresh_token'}})
77
+ token = JSON.parse response.body
78
+ access_token = token["access_token"]
79
+ refresh_token = token["refresh_token"]
80
+ ```
81
+
82
+ ### Using plangrade API client to access REST endpoints
83
+
84
+ You can view the current state of the client using the `Plangrade#options` method.
85
+
86
+ ```ruby
87
+ require 'plangrade'
88
+
89
+ Plangrade.options
90
+ #> {:site_url=>"https://plangrade.com", :client_id=>your_client_id, :client_secret=>your_client_secret, :access_token=>current_access_token, :http_adapter=>Plangrade::Connection, :connection_options=>{:max_redirect=>5, :use_ssl=>true}}
91
+ ```
92
+
93
+ To change the configuration parameters use the `configure` method. If you set your client_id and client_secret as `ENV['PLANGRADE_CLIENT_ID']` and `ENV['PLANGRADE_CLIENT_SECRET']` then this will automatically be set for you.
94
+
95
+ ```ruby
96
+ Plangrade.configure do |p|
97
+ p.client_id = your_client_id
98
+ p.client_secret = your_client_secret
99
+ end
100
+ ```
101
+
102
+ At this point the `access_token` is nil. This will need to be set and, in the next section, we will see how to do this.
49
103
 
50
104
  ## Usage
51
105
 
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).
106
+ This gem offers two way to interact with plangrade's API:
107
+
108
+ 1. Calling methods on `Plangrade` module.
109
+ 2. Calling methods on an instance of `Plangrade::Client`.
53
110
 
54
- Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
111
+ ### Calling methods on the plangrade module
112
+
113
+ In order for this to work, you will need to set up your `access_token`. This assumes that you already configured the client with your default options as was described above.
55
114
 
56
115
  ```ruby
57
- Rails.application.config.middleware.use OmniAuth::Builder do
58
- provider :plangrade, ENV['PLANGRADE_CLIENT_ID'], ENV['PLANGRADE_CLIENT_SECRET']
116
+ # Set up your access_token
117
+ Plangrade.configure do |p|
118
+ p.access_token = your_access_token
59
119
  end
120
+
121
+ # Get the current user
122
+ Plangrade.current_user
60
123
  ```
61
124
 
62
- [See the example rails app for full examples](https://github.com/topherreynoso/plangrade-ruby-client) of both the server and client-side flows.
125
+ ### Calling methods on an instance of Plangrade::Client
126
+
127
+ **Note:** Use this if you wish to create multiple client instances with different `client_id`, `client_secret`, and/or `access_token`. If your application uses a single pair of `client_id` and `client_secret` credentials, you ONLY need to specify the `access_token`.
128
+
129
+ ```ruby
130
+ # Create a client instance using the access_token
131
+ plangrade = Plangrade::Client.new(:access_token => your_access_token)
132
+ ```
63
133
 
64
- ## Auth Hash
134
+ Call methods on the instance.
65
135
 
66
- Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
136
+ **User**
137
+
138
+ Current user info
139
+
140
+ ```ruby
141
+ user = plangrade.current_user
142
+ user_name = user[:name]
143
+ ```
144
+
145
+ Create new user
67
146
 
68
147
  ```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
- }
148
+ new_user_id = plangrade.create_user(params)
90
149
  ```
91
150
 
92
- ### How it Works
151
+ Update user
93
152
 
94
- The client-side flow is supported by parsing the authorization code from the signed request which plangrade places in a cookie.
153
+ ```ruby
154
+ updated_user = plangrade.update_user(id, params)
155
+ ```
156
+
157
+ Delete user
158
+
159
+ ```ruby
160
+ plangrade.delete_user(id)
161
+ ```
162
+
163
+ **Companies**
164
+
165
+ Create new company
166
+
167
+ ```ruby
168
+ new_company_id = plangrade.create_company(params)
169
+ ```
170
+
171
+ Get company info
172
+
173
+ ```ruby
174
+ company = plangrade.get_company(id)
175
+ ```
176
+
177
+ Get all of a user's companies
178
+
179
+ ```ruby
180
+ companies = plangrade.all_companies
181
+ ```
182
+
183
+ Update company
184
+
185
+ ```ruby
186
+ updated_company = plangrade.update_company(id, params)
187
+ ```
188
+
189
+ Delete company
190
+
191
+ ```ruby
192
+ plangrade.delete_company(id)
193
+ ```
194
+
195
+ **Participants**
196
+
197
+ Create new participant
198
+
199
+ ```ruby
200
+ new_participant_id = plangrade.create_participant(params)
201
+ ```
202
+
203
+ Get participant info
204
+
205
+ ```ruby
206
+ participant = plangrade.get_participant(id)
207
+ ```
208
+
209
+ Get all of a company's participants
210
+
211
+ ```ruby
212
+ participants = plangrade.all_participants(:company_id => id, params)
213
+ ```
214
+
215
+ Update participant info
216
+
217
+ ```ruby
218
+ updated_participant = plangrade.update_participant(id, params)
219
+ ```
220
+
221
+ Archive participant
222
+
223
+ ```ruby
224
+ archived_participant_id = plangrade.archive_participant(id)
225
+ ```
226
+
227
+ Delete participant
228
+
229
+ ```ruby
230
+ plangrade.delete_participant(id)
231
+ ```
95
232
 
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:
233
+ ## Supported Ruby Versions
97
234
 
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.
235
+ This library aims to support and is [tested against](https://travis-ci.org/topherreynoso/plangrade-ruby) the following Ruby versions:
101
236
 
102
- ## Token Expiry
237
+ 1. Ruby 1.9.3
238
+ 2. Ruby 2.0.0
239
+ 3. Ruby 2.1.0
240
+ 4. jruby
103
241
 
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.
242
+ This library may inadvertently work (or seem to work) on other Ruby implementations, however, support will only be provided for the versions listed above.
106
243
 
107
244
  ## License
108
245
 
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
- require "bundler/gem_tasks"
1
+ require "bundler/gem_tasks"
2
+ require 'rake'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec) do |t|
6
+ t.verbose = true
7
+ end
8
+
9
+ desc "Run spec"
10
+ task :default => :spec
@@ -6,19 +6,19 @@ module Plangrade
6
6
  end
7
7
 
8
8
  def update_company(id, opts={})
9
- put("/api/v1/companies/#{id}", opts).body[:company]
9
+ put("/api/v1/companies/#{id}", opts)
10
10
  end
11
11
 
12
12
  def delete_company(id)
13
- delete("/api/v1/companies/#{id}", opts)
13
+ delete("/api/v1/companies/#{id}")
14
14
  end
15
15
 
16
16
  def get_company(id)
17
- get("/api/v1/companies/#{id}").body[:company]
17
+ get("/api/v1/companies/#{id}")
18
18
  end
19
19
 
20
20
  def all_companies(opts={})
21
- get("/api/v1/companies", opts).body[:companies]
21
+ get("/api/v1/companies", opts)
22
22
  end
23
23
  end
24
24
  end
@@ -6,23 +6,24 @@ module Plangrade
6
6
  end
7
7
 
8
8
  def update_participant(id, opts={})
9
- put("/api/v1/participants/#{id}", opts).body[:participant]
9
+ put("/api/v1/participants/#{id}", opts)
10
10
  end
11
11
 
12
12
  def delete_participant(id)
13
- delete("/api/v1/participants/#{id}", opts)
13
+ delete("/api/v1/participants/#{id}")
14
14
  end
15
15
 
16
16
  def archive_participant(id)
17
- get("api/v1/participants/archive?participant_id=#{id}")
17
+ get("/api/v1/participants/archive?participant_id=#{id}")
18
18
  end
19
19
 
20
20
  def get_participant(id)
21
- get("/api/v1/participants/#{id}").body[:participant]
21
+ get("/api/v1/participants/#{id}")
22
22
  end
23
23
 
24
24
  def all_participants(opts={})
25
- get("/api/v1/participants", opts).body[:participants]
25
+ company_id = opts[:company_id]
26
+ get("/api/v1/participants?company_id=#{company_id}")
26
27
  end
27
28
  end
28
29
  end
@@ -6,15 +6,15 @@ module Plangrade
6
6
  end
7
7
 
8
8
  def update_user(id, opts={})
9
- put("/api/v1/users/#{id}", opts).body[:user]
9
+ put("/api/v1/users/#{id}", opts)
10
10
  end
11
11
 
12
12
  def delete_user(id)
13
- delete("/api/v1/users/#{id}", opts)
13
+ delete("/api/v1/users/#{id}")
14
14
  end
15
15
 
16
16
  def current_user
17
- get('/api/v1/me').body
17
+ get('/api/v1/me')
18
18
  end
19
19
  end
20
20
  end
@@ -44,6 +44,7 @@ module Plangrade
44
44
  #
45
45
  # >> client = PlangradeClient.new(config)
46
46
  # >> client.exchange_auth_code_for_token({
47
+ # :code => '123456789'
47
48
  # :redirect_uri => 'http://localhost:3000/auth/plangrade/callback',
48
49
  # })
49
50
  #
@@ -9,7 +9,7 @@ module Plangrade
9
9
  new(:id => id)
10
10
  end
11
11
 
12
- attr_accessor_deffered :id, :name, :ein, :grade
12
+ attr_accessor_deffered :name, :ein, :grade
13
13
 
14
14
  def update!(params)
15
15
  api_handler.update_company(@id, params)
@@ -1,6 +1,6 @@
1
1
  module Plangrade
2
2
  module Resources
3
- class Participants < Plangrade::Resources::Base
3
+ class Participant < Plangrade::Resources::Base
4
4
 
5
5
  def self.create(company_id, first_name, last_name, street1, street2, city, state, zip, dob, ssn, email, phone, employee_id)
6
6
 
@@ -13,7 +13,7 @@ module Plangrade
13
13
  new(:id => id)
14
14
  end
15
15
 
16
- attr_accessor_deffered :id, :company_id, :employee_id, :first_name, :last_name, :street1, :street2, :city, :state, :zip,
16
+ attr_accessor_deffered :company_id, :employee_id, :first_name, :last_name, :street1, :street2, :city, :state, :zip,
17
17
  :dob, :ssn, :email, :phone
18
18
 
19
19
  def update!(params)
@@ -2,8 +2,8 @@ module Plangrade
2
2
  module Resources
3
3
  class User < Plangrade::Resources::Base
4
4
 
5
- def self.current
6
- result = api_handler.current_resource_owner
5
+ def self.current_user
6
+ result = api_handler.current_user
7
7
  return nil unless result.success?
8
8
  new(result.body)
9
9
  end
@@ -15,7 +15,7 @@ module Plangrade
15
15
  new(:id => id)
16
16
  end
17
17
 
18
- attr_accessor_deffered :id, :email, :name
18
+ attr_accessor_deffered :email, :name
19
19
 
20
20
  def update!(params)
21
21
  api_handler.update_user(@id, params)
@@ -1,5 +1,5 @@
1
1
  module Plangrade
2
2
  module Ruby
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = %q{plangrade API client}
12
12
  spec.description = %q{A ruby wrapper for accessing plangrade's REST API}
13
13
  spec.homepage = "https://github.com/topherreynoso/plangrade-ruby"
14
- spec.license = "MIT"
14
+ spec.licenses = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -21,19 +21,15 @@ Gem::Specification.new do |spec|
21
21
  spec.cert_chain = ['certs/public.pem']
22
22
  spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.6"
25
- spec.add_development_dependency "rake"
26
- spec.add_development_dependency "minitest"
27
- spec.add_development_dependency "vcr"
28
- spec.add_development_dependency "webmock"
29
-
30
- spec.add_dependency "faraday"
31
- spec.add_dependency "json"
32
24
  spec.add_dependency 'oj', '~> 2.0'
33
25
  spec.add_dependency 'multi_json', '~> 1.8'
34
26
  spec.add_dependency 'rest-client', '~> 1.6'
35
27
  spec.add_dependency 'addressable', '~> 2.3'
36
28
  spec.add_dependency 'oauth2-client', '~> 2.0'
37
29
 
38
- spec.post_install_message = %q{ Thanks for installing! For API help go to http://docs.plangrade.com }
30
+ spec.add_development_dependency 'rake'
31
+ spec.add_development_dependency 'rspec'
32
+ spec.add_development_dependency 'simplecov', '>= 0.8'
33
+ spec.add_development_dependency 'webmock', '>= 1.9'
34
+ spec.add_development_dependency 'yard', '>= 0.8'
39
35
  end
@@ -0,0 +1,72 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # Copyright (c) Microsoft Corporation
4
+ # All rights reserved.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13
+ # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
14
+ # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
15
+ # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
16
+ #
17
+ # See the Apache Version 2.0 License for specific language governing
18
+ # permissions and limitations under the License.
19
+
20
+ require File.expand_path('../../spec_helper', __FILE__)
21
+ require 'ostruct'
22
+
23
+ describe Plangrade::Api::Company do
24
+
25
+ before :all do
26
+ @client = Plangrade::Client.new(
27
+ :site_url => 'https://plangrade.com',
28
+ :client_id => 'PRbTcg9qjgKsp4jjpm1pw',
29
+ :client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
30
+ :access_token => 'TolNOFka9Uls2DxahNi78A'
31
+ )
32
+ end
33
+
34
+ subject { @client }
35
+
36
+ describe 'create_company' do
37
+ it 'makes an http request' do
38
+ params = {:name => 'plangrade, llc', :ein => '123456789'}
39
+ @client.should_receive(:post).with('/api/v1/companies', params)
40
+ @client.create_company(params)
41
+ end
42
+ end
43
+
44
+ describe 'update_company' do
45
+ it 'makes an http request' do
46
+ params = {:name => 'plangrade, inc'}
47
+ @client.should_receive(:put).with('/api/v1/companies/1', params)
48
+ @client.update_company(1, params)
49
+ end
50
+ end
51
+
52
+ describe 'delete_company' do
53
+ it 'makes an http request' do
54
+ @client.should_receive(:delete).with('/api/v1/companies/1')
55
+ @client.delete_company(1)
56
+ end
57
+ end
58
+
59
+ describe 'get_company' do
60
+ it 'makes an http request' do
61
+ @client.should_receive(:get).with('/api/v1/companies/1')
62
+ @client.get_company(1)
63
+ end
64
+ end
65
+
66
+ describe 'all_companies' do
67
+ it 'makes an http request' do
68
+ @client.should_receive(:get).with('/api/v1/companies', {:page => 1, :letter => 'm'})
69
+ @client.all_companies({:page => 1, :letter => 'm'})
70
+ end
71
+ end
72
+ end