bamboohr 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e5f7339f6b13eaba99aaf7ea8a99ad035acbc007
4
+ data.tar.gz: fd9a98c93818903b09b32f1a9613d67b8632a89a
5
+ SHA512:
6
+ metadata.gz: 26bf4f568c31f27cdeba6450db4f811ca956d688873fa10b34068f8856b143ca79d2c217c3e790db696189d1aee926b91a25db4e0d9e03d6e72e97ab76158540
7
+ data.tar.gz: 169b992ed49b7fa4aa37daacc11b03ba3b4d98cd54cb765fa85e57f280c1ae7dbc18ea7a995bf4f986af98e1e66cc70e1ce59169c03cd5c906e45fd583c1a1b6
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .ruby-version
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 2.1.1
3
+ - 2.0.0
4
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bamboohr.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 David Padilla
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # BambooHR
2
+
3
+ Consume [BambooHR's API](http://www.bamboohr.com/api/documentation/) in Ruby
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'bamboohr'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install bamboohr
18
+
19
+ ## Usage
20
+
21
+ Create an instance of the client
22
+
23
+ @client = BambooHR::Client.new
24
+
25
+ Set your company's subdomain
26
+
27
+ @client.subdomain = "crowdint"
28
+
29
+ Set your API key
30
+
31
+ @client.key = "SOME_RANDOM_GIBBERISH"
32
+
33
+ Consume, returns JSON
34
+
35
+ employee_list = @client.employee_list
36
+
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it ( http://github.com/crowdint/bamboohr/fork )
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require "cucumber/rake/task"
3
+ require 'rake/testtask'
4
+
5
+ Cucumber::Rake::Task.new
6
+
7
+ Rake::TestTask.new(:test) do |test|
8
+ test.libs << 'lib' << 'test'
9
+ test.pattern = 'test/**/*_test.rb'
10
+ test.verbose = true
11
+ end
12
+
13
+ task(default: [:test, :cucumber])
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bamboohr/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bamboohr"
8
+ spec.version = BambooHR::VERSION
9
+ spec.authors = ["David Padilla"]
10
+ spec.email = ["david@crowdint.com"]
11
+ spec.summary = %q{Consume BambooHR's API}
12
+ spec.description = %q{Consume BambooHR's API}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "httparty", "~> 0.13.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rr", "~> 1.1.2"
26
+ spec.add_development_dependency "cucumber", "~> 1.3.12"
27
+ spec.add_development_dependency "vcr", "~> 2.8.0"
28
+ spec.add_development_dependency "webmock"
29
+ end
@@ -0,0 +1,8 @@
1
+ Feature: Authentication
2
+
3
+ @vcr
4
+ Scenario: Basic Authentication
5
+ Given I create an instance of the client
6
+ And I set an API key
7
+ And I set the company subdomain
8
+ Then I should be able to authenticate
@@ -0,0 +1,7 @@
1
+ Given(/^I set an API key$/) do
2
+ @client.key = "API_TOKEN"
3
+ end
4
+
5
+ Given(/^I set the company subdomain$/) do
6
+ @client.subdomain = "crowdint"
7
+ end
@@ -0,0 +1,3 @@
1
+ Then(/^I should be able to authenticate$/) do
2
+ assert_equal 200, @client.employee_list!.code
3
+ end
@@ -0,0 +1,3 @@
1
+ Given(/^I create an instance of the client$/) do
2
+ @client = BambooHR::Client.new
3
+ end
@@ -0,0 +1,19 @@
1
+ # env.rb
2
+ #
3
+ require 'bamboohr'
4
+ require 'vcr'
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = 'features/vcr_cassettes'
8
+ c.hook_into :webmock # or :fakeweb
9
+ c.default_cassette_options = { record: :none }
10
+
11
+ # Set your API token to record cassettes, use this option
12
+ # to replace the token with something else
13
+ #
14
+ # c.filter_sensitive_data('API_TOKEN') { '' }
15
+ end
16
+
17
+ VCR.cucumber_tags do |t|
18
+ t.tag '@vcr', use_scenario_name: true
19
+ end
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://API_TOKEN:x@api.bamboohr.com/api/gateway.php/crowdint/v1/employees/directory
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Date:
18
+ - Tue, 18 Mar 2014 22:06:47 GMT
19
+ Server:
20
+ - Apache
21
+ Vary:
22
+ - User-Agent
23
+ Connection:
24
+ - close
25
+ Content-Type:
26
+ - application/json
27
+ body:
28
+ encoding: UTF-8
29
+ string: '{"fields":[{"id":"displayName","type":"text","name":"Display name"},{"id":"firstName","type":"text","name":"First
30
+ name"},{"id":"lastName","type":"text","name":"Last name"},{"id":"jobTitle","type":"list","name":"Job
31
+ title"},{"id":"workPhone","type":"text","name":"Work Phone"},{"id":"workPhoneExtension","type":"text","name":"Work
32
+ Extension"},{"id":"mobilePhone","type":"text","name":"Mobile Phone"},{"id":"workEmail","type":"email","name":"Work
33
+ Email"},{"id":"department","type":"list","name":"Department"},{"id":"location","type":"list","name":"Location"},{"id":"division","type":"list","name":"Division"},{"id":"photoUploaded","type":"bool","name":"Employee
34
+ photo exists"},{"id":"photoUrl","type":"url","name":"Employee photo url"},{"type":"bool","name":"","id":"canUploadPhoto"}],"employees":[{"id":"1","displayName":"Cyan
35
+ Aguirre","firstName":"Cyan","lastName":"Mendoza","jobTitle":"Intern","workPhone":null,"workPhoneExtension":null,"mobilePhone":"312-134-7689","workEmail":"cyan@crowd.com","department":"Development","location":"Colima","division":null,"photoUploaded":false,"photoUrl":"https:\/\/crowdint.bamboohr.com\/images\/photo_placeholder.gif","canUploadPhoto":1}
36
+ ]}'
37
+ http_version:
38
+ recorded_at: Tue, 18 Mar 2014 22:06:48 GMT
39
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,6 @@
1
+ require "bamboohr/version"
2
+
3
+ require "bamboohr/client"
4
+
5
+ module BambooHR
6
+ end
@@ -0,0 +1,30 @@
1
+ require 'httparty'
2
+
3
+ module BambooHR
4
+ class Client
5
+ include HTTParty
6
+ format :json
7
+
8
+ base_uri "https://api.bamboohr.com"
9
+
10
+ attr_accessor :key
11
+ attr_accessor :subdomain
12
+
13
+ def employee_list!
14
+ self.class.get("/api/gateway.php/#{subdomain}/v1/employees/directory", basic_auth: auth, headers: headers)
15
+ end
16
+
17
+ def employee_list
18
+ JSON.parse employee_list!.body
19
+ end
20
+
21
+ private
22
+ def headers
23
+ { 'Accept' => 'application/json' }
24
+ end
25
+
26
+ def auth
27
+ { username: key, password: "x" }
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module BambooHR
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ class BambooHR::ClientTest < Test::Unit::TestCase
4
+ def setup
5
+ @subject = BambooHR::Client.new
6
+ @subject.subdomain = "crowdint"
7
+ @subject.key = "API_TOKEN"
8
+ end
9
+
10
+ def test_employee_list!
11
+ VCR.use_cassette('Authentication/Basic_Authentication') do
12
+ response = @subject.employee_list!
13
+
14
+ assert_equal true, response.class == HTTParty::Response
15
+ assert_equal 200, response.code
16
+ end
17
+ end
18
+
19
+ def test_employee_list
20
+ json = {}
21
+ stub(@subject).employee_list!.mock!.body() { "RESPONSE" }
22
+ mock(JSON).parse("RESPONSE") { json }
23
+
24
+ assert_equal json, @subject.employee_list
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ require 'bundler'
2
+ require 'test/unit'
3
+ require 'rr'
4
+ require 'vcr'
5
+
6
+ Bundler.require
7
+
8
+ require 'bamboohr'
9
+
10
+ VCR.configure do |c|
11
+ c.cassette_library_dir = 'features/vcr_cassettes'
12
+ c.hook_into :webmock # or :fakeweb
13
+ c.default_cassette_options = { record: :none }
14
+
15
+ # Set your API token to record cassettes, use this option
16
+ # to replace the token with something else
17
+ #
18
+ # c.filter_sensitive_data('API_TOKEN') { '' }
19
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bamboohr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Padilla
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.1.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: cucumber
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.12
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.12
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.8.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.8.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Consume BambooHR's API
112
+ email:
113
+ - david@crowdint.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - bamboohr.gemspec
125
+ - features/authentication.feature
126
+ - features/step_definitions/api_settings_steps.rb
127
+ - features/step_definitions/authentication_steps.rb
128
+ - features/step_definitions/client_steps.rb
129
+ - features/support/env.rb
130
+ - features/vcr_cassettes/Authentication/Basic_Authentication.yml
131
+ - lib/bamboohr.rb
132
+ - lib/bamboohr/client.rb
133
+ - lib/bamboohr/version.rb
134
+ - test/bamboohr/client_test.rb
135
+ - test/test_helper.rb
136
+ homepage: ''
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.2.2
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Consume BambooHR's API
160
+ test_files:
161
+ - features/authentication.feature
162
+ - features/step_definitions/api_settings_steps.rb
163
+ - features/step_definitions/authentication_steps.rb
164
+ - features/step_definitions/client_steps.rb
165
+ - features/support/env.rb
166
+ - features/vcr_cassettes/Authentication/Basic_Authentication.yml
167
+ - test/bamboohr/client_test.rb
168
+ - test/test_helper.rb