ten_thousand_feet 0.0.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 +7 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +91 -0
- data/Rakefile +1 -0
- data/lib/ten_thousand_feet.rb +8 -0
- data/lib/ten_thousand_feet/api/assignments.rb +23 -0
- data/lib/ten_thousand_feet/api/phases.rb +19 -0
- data/lib/ten_thousand_feet/api/projects.rb +35 -0
- data/lib/ten_thousand_feet/api/time_entries.rb +27 -0
- data/lib/ten_thousand_feet/api/user_status.rb +15 -0
- data/lib/ten_thousand_feet/api/users.rb +23 -0
- data/lib/ten_thousand_feet/client.rb +61 -0
- data/lib/ten_thousand_feet/version.rb +3 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/ten_thousand_feet/api/assignment_spec.rb +74 -0
- data/spec/ten_thousand_feet/api/phases_spec.rb +61 -0
- data/spec/ten_thousand_feet/api/projects_spec.rb +103 -0
- data/spec/ten_thousand_feet/api/time_entries_spec.rb +76 -0
- data/spec/ten_thousand_feet/api/user_status_spec.rb +42 -0
- data/spec/ten_thousand_feet/api/users_spec.rb +68 -0
- data/spec/ten_thousand_feet/client_spec.rb +10 -0
- data/ten_thousand_feet.gemspec +30 -0
- metadata +202 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 001042bedc132b62a277d47cfe33406c0dee57ee
|
4
|
+
data.tar.gz: 0087ee0c7ff7f4227cf3a3e525da51c320076148
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f985b95d8cc93714fde312705fde1d3aaa807a9535535941ae8a9589e1ad62db130996e956ee5e182c575398f285e3fb67f80747e5b9c20260beab60a53632b7
|
7
|
+
data.tar.gz: 328221c49b86ab803ea2a377c916bb94f6077f11ac4092646484dd8629272ec457f045f72d3a2669c9cc127fdd874d5eb1eb11c794acb6e72673595a4aaf2f34
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kyle Suss
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# TenThousandFeet
|
2
|
+
|
3
|
+
Ruby wrapper for the [10,000ft API (BETA)](http://10kft.github.io/api-documentation).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem 'ten_thousand_feet'
|
8
|
+
|
9
|
+
Or
|
10
|
+
|
11
|
+
gem install ten_thousand_feet
|
12
|
+
|
13
|
+
## Setup
|
14
|
+
|
15
|
+
require 'ten_thousand_feet'
|
16
|
+
|
17
|
+
# Initialize a new 10,000ft client
|
18
|
+
client = TenThousandFeet.new(auth: YOUR_AUTH_TOKEN)
|
19
|
+
|
20
|
+
# API Methods
|
21
|
+
Note: 'options' will be different for each method. Check the official API documentation for a list of available options for each call.
|
22
|
+
|
23
|
+
'options' should be passed in as a hash:
|
24
|
+
|
25
|
+
# user_id = 1969
|
26
|
+
#
|
27
|
+
# options = {
|
28
|
+
# first_name: 'Austin',
|
29
|
+
# last_name: 'Powers',
|
30
|
+
# display_name: 'Austin Danger Powers'
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# client.update_user(user_id, options)
|
34
|
+
|
35
|
+
## Users
|
36
|
+
|
37
|
+
client.get_users(options)
|
38
|
+
client.show_user(user_id, options)
|
39
|
+
client.update_user(user_id, options)
|
40
|
+
client.create_user(options)
|
41
|
+
|
42
|
+
## User Status
|
43
|
+
|
44
|
+
client.get_user_statuses(user_id, options)
|
45
|
+
client.create_user_status(user_id, options)
|
46
|
+
|
47
|
+
## Assignments
|
48
|
+
|
49
|
+
client.get_assignments(user_id, options)
|
50
|
+
client.show_assignment(assignment_id, user_id, options)
|
51
|
+
client.create_assignment(project_id, user_id, options)
|
52
|
+
client.delete_assignment(assignment_id, user_id, options)
|
53
|
+
|
54
|
+
## Projects
|
55
|
+
|
56
|
+
client.get_projects(options)
|
57
|
+
client.show_project(project_id, options)
|
58
|
+
client.update_project(project_id, options)
|
59
|
+
client.create_project(options)
|
60
|
+
client.delete_project(project_id, options)
|
61
|
+
client.get_project_time_entries(project_id, options)
|
62
|
+
client.get_project_users(project_id, options)
|
63
|
+
|
64
|
+
## Phases
|
65
|
+
|
66
|
+
client.get_phases(project_id, options)
|
67
|
+
client.create_phases(project_id, options)
|
68
|
+
client.update_phases(project_id, phase_id, options)
|
69
|
+
|
70
|
+
## Time Entries
|
71
|
+
|
72
|
+
client.get_time_entries(user_id, options)
|
73
|
+
client.show_time_entry(time_entry_id, user_id, options)
|
74
|
+
client.update_time_entry(time_entry_id, user_id, options)
|
75
|
+
client.create_time_entry(user_id, options)
|
76
|
+
client.delete_time_entry(time_entry_id, user_id, project_id, options)
|
77
|
+
|
78
|
+
## To-Do
|
79
|
+
|
80
|
+
* Budget Items
|
81
|
+
* Budget Item Categories
|
82
|
+
* Tags Per Project
|
83
|
+
* Tags Per User
|
84
|
+
|
85
|
+
## Contributing
|
86
|
+
|
87
|
+
1. Fork it
|
88
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
89
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
90
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
91
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module TenThousandFeet
|
2
|
+
module API
|
3
|
+
module Assignments
|
4
|
+
|
5
|
+
def get_assignments(user_id, options={})
|
6
|
+
get("/users/#{user_id}/assignments", options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def show_assignment(id, user_id, options={})
|
10
|
+
get("/users/#{user_id}/assignments/#{id}", options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_assignment(project_id, user_id, options={})
|
14
|
+
post("/users/#{user_id}/assignments", options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete_assignment(id, user_id, options={})
|
18
|
+
delete("/users/#{user_id}/assignments/#{id}", options)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module TenThousandFeet
|
2
|
+
module API
|
3
|
+
module Phases
|
4
|
+
|
5
|
+
def get_phases(project_id, options={})
|
6
|
+
get("/projects/#{project_id}/phases", options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_phase(project_id, options={})
|
10
|
+
post("/projects/#{project_id}/phases", options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def update_phase(project_id, phase_id, options={})
|
14
|
+
put("/projects/#{project_id}/phases/#{phase_id}", options)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module TenThousandFeet
|
2
|
+
module API
|
3
|
+
module Projects
|
4
|
+
|
5
|
+
def get_projects(options={})
|
6
|
+
get("/projects", options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def show_project(id, options={})
|
10
|
+
get("/projects/#{id}", options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_project(options={})
|
14
|
+
post("/projects", options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_project(id, options={})
|
18
|
+
put("/projects/#{id}", options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete_project(id, options={})
|
22
|
+
delete("/projects/#{id}", options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_project_time_entries(id, options={})
|
26
|
+
get("/projects/#{id}/time_entries", options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_project_users(id, options={})
|
30
|
+
get("/projects/#{id}/users", options)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module TenThousandFeet
|
2
|
+
module API
|
3
|
+
module TimeEntries
|
4
|
+
|
5
|
+
def get_time_entries(user_id, options={})
|
6
|
+
get("/users/#{user_id}/time_entries", options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def show_time_entry(id, user_id, options={})
|
10
|
+
get("/users/#{user_id}/time_entries/#{id}", options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_time_entry(user_id, options={})
|
14
|
+
post("/users/#{user_id}/time_entries", options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_time_entry(id, user_id, options={})
|
18
|
+
put("/users/#{user_id}/time_entries/#{id}", options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete_time_entry(id, user_id, project_id, options={})
|
22
|
+
delete("projects/#{project_id}/users/#{user_id}/time_entries/#{id}", options)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module TenThousandFeet
|
2
|
+
module API
|
3
|
+
module UserStatus
|
4
|
+
|
5
|
+
def get_user_statuses(user_id, options={})
|
6
|
+
get("/users/#{user_id}/statuses", options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_user_status(user_id, options={})
|
10
|
+
post("/users/#{user_id}/statuses", options)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module TenThousandFeet
|
2
|
+
module API
|
3
|
+
module Users
|
4
|
+
|
5
|
+
def get_users(options={})
|
6
|
+
get("/users", options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def show_user(id, options={})
|
10
|
+
get("/users/#{id}", options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_user(options={})
|
14
|
+
post("/users", options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_user(id, options={})
|
18
|
+
put("/users/#{id}", options)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
require 'ten_thousand_feet/api/users'
|
5
|
+
require 'ten_thousand_feet/api/phases'
|
6
|
+
require 'ten_thousand_feet/api/projects'
|
7
|
+
require 'ten_thousand_feet/api/user_status'
|
8
|
+
require 'ten_thousand_feet/api/assignments'
|
9
|
+
require 'ten_thousand_feet/api/time_entries'
|
10
|
+
|
11
|
+
module TenThousandFeet
|
12
|
+
class Client
|
13
|
+
|
14
|
+
attr_reader :auth
|
15
|
+
|
16
|
+
include API::Users
|
17
|
+
include API::Phases
|
18
|
+
include API::Projects
|
19
|
+
include API::UserStatus
|
20
|
+
include API::Assignments
|
21
|
+
include API::TimeEntries
|
22
|
+
|
23
|
+
def initialize(options={})
|
24
|
+
@auth = options[:auth]
|
25
|
+
end
|
26
|
+
|
27
|
+
def api_url
|
28
|
+
"https://vnext-api.10000ft.com/api/v1"
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_options
|
32
|
+
{ auth: @auth }
|
33
|
+
end
|
34
|
+
|
35
|
+
def get(path, options = {})
|
36
|
+
params = default_options.merge(options)
|
37
|
+
response = RestClient.get(api_url + path, params)
|
38
|
+
|
39
|
+
JSON.parse(response)
|
40
|
+
end
|
41
|
+
|
42
|
+
def post(path, options = {})
|
43
|
+
params = default_options.merge(options)
|
44
|
+
response = RestClient.post(api_url + path, params)
|
45
|
+
|
46
|
+
JSON.parse(response)
|
47
|
+
end
|
48
|
+
|
49
|
+
def put(path, options = {})
|
50
|
+
params = default_options.merge(options)
|
51
|
+
response = RestClient.put(api_url + path, params)
|
52
|
+
|
53
|
+
JSON.parse(response)
|
54
|
+
end
|
55
|
+
|
56
|
+
def delete(path, options = {})
|
57
|
+
params = default_options.merge(options)
|
58
|
+
RestClient.delete(api_url + path, params)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'rest-client'
|
3
|
+
require 'ten_thousand_feet/client'
|
4
|
+
require 'ten_thousand_feet'
|
5
|
+
require 'yaml'
|
6
|
+
require 'vcr'
|
7
|
+
require 'webmock'
|
8
|
+
|
9
|
+
$AUTH = YAML.load_file('auth.yml')
|
10
|
+
|
11
|
+
VCR.configure do |c|
|
12
|
+
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
13
|
+
c.hook_into :webmock
|
14
|
+
c.allow_http_connections_when_no_cassette = true
|
15
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TenThousandFeet
|
4
|
+
module API
|
5
|
+
describe Assignments do
|
6
|
+
|
7
|
+
let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
|
8
|
+
let!(:user) { client.get_users['data'][0] }
|
9
|
+
let!(:projects) {
|
10
|
+
VCR.use_cassette('projects') do
|
11
|
+
client.get_projects
|
12
|
+
end
|
13
|
+
}
|
14
|
+
let!(:project) { projects['data'][0] }
|
15
|
+
let!(:assignments) {
|
16
|
+
VCR.use_cassette('assignments') do
|
17
|
+
client.get_assignments(user['id'])
|
18
|
+
end
|
19
|
+
}
|
20
|
+
let!(:assignment) { assignments['data'][0] }
|
21
|
+
let!(:id) { assignment['id'] }
|
22
|
+
|
23
|
+
describe '#get_assignments' do
|
24
|
+
it 'retrieves a list of assignments for a user' do
|
25
|
+
VCR.use_cassette('get_assignments') do
|
26
|
+
expect(assignments['data']).to_not be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#show_assignments' do
|
32
|
+
it 'retrieves details of a assignment' do
|
33
|
+
VCR.use_cassette('show_assignments') do
|
34
|
+
id = assignments['data'][0]['id']
|
35
|
+
assignment = client.show_assignment(id, user['id'])
|
36
|
+
expect(assignment['id']).to eq id
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#create_assignment' do
|
42
|
+
def assignment_attributes
|
43
|
+
{
|
44
|
+
project_id: project['id'],
|
45
|
+
starts_at: '2013-10-10',
|
46
|
+
ends_at: '2013-10-10'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'creates a new assignment' do
|
51
|
+
VCR.use_cassette('create_assignment') do
|
52
|
+
assignment_count_before = assignments['data'].count
|
53
|
+
response = client.create_assignment(project['id'], user['id'], assignment_attributes)
|
54
|
+
|
55
|
+
new_assignments = client.get_assignments(user['id'])
|
56
|
+
assignment_count_after = new_assignments['data'].count
|
57
|
+
|
58
|
+
expect(assignment_count_after).to eq (assignment_count_before + 1)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#delete_assignment' do
|
64
|
+
context 'given a valid time entry' do
|
65
|
+
it 'deletes the assignment' do
|
66
|
+
VCR.use_cassette('delete_assignment') do
|
67
|
+
response = client.delete_assignment(id, user['id'])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TenThousandFeet
|
4
|
+
module API
|
5
|
+
describe Phases do
|
6
|
+
|
7
|
+
let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
|
8
|
+
let!(:projects) {
|
9
|
+
VCR.use_cassette('projects') do
|
10
|
+
client.get_projects
|
11
|
+
end
|
12
|
+
}
|
13
|
+
let!(:project) { projects['data'][0] }
|
14
|
+
let!(:id) { project['id'] }
|
15
|
+
|
16
|
+
describe '#get_phases' do
|
17
|
+
it 'retrieves a list of phases for a given project' do
|
18
|
+
VCR.use_cassette('get_phases') do
|
19
|
+
phases = client.get_phases(id)
|
20
|
+
expect(phases['data']).to_not be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#create_phase' do
|
26
|
+
def phase_attributes
|
27
|
+
{
|
28
|
+
phase_name: 'Groovy baby',
|
29
|
+
starts_at: '2014-09-15',
|
30
|
+
ends_at: '2014-10-15'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'creates a new phase for a given project' do
|
35
|
+
VCR.use_cassette('create_phase') do
|
36
|
+
response = client.create_phase(id, phase_attributes)
|
37
|
+
phase = client.get_phases(id)
|
38
|
+
expect(phase['data'][0]['phase_name']).to eq phase_attributes[:phase_name]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#update_phase' do
|
44
|
+
def phase_attributes
|
45
|
+
{
|
46
|
+
phase_name: 'Groovy baby',
|
47
|
+
starts_at: '2014-09-15',
|
48
|
+
ends_at: '2014-10-15'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'updates a given phases attributes' do
|
53
|
+
phase = client.create_phase(id, phase_attributes)
|
54
|
+
phase_name = "#{rand(0..100)} So Groovy"
|
55
|
+
response = client.update_phase(id, phase['id'], { phase_name: phase_name })
|
56
|
+
expect(response['phase_name']).to eq phase_name
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TenThousandFeet
|
4
|
+
module API
|
5
|
+
describe Projects do
|
6
|
+
|
7
|
+
let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
|
8
|
+
let!(:projects) {
|
9
|
+
VCR.use_cassette('projects') do
|
10
|
+
client.get_projects
|
11
|
+
end
|
12
|
+
}
|
13
|
+
let!(:project) { projects['data'][0] }
|
14
|
+
let!(:id) { project['id'] }
|
15
|
+
|
16
|
+
describe '#get_projects' do
|
17
|
+
it 'retrieves a list of projects' do
|
18
|
+
VCR.use_cassette('get_projects') do
|
19
|
+
name = projects['data'][0]['name']
|
20
|
+
expect(name).to_not be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#show_projects' do
|
26
|
+
it 'retrieves details of a specific project' do
|
27
|
+
VCR.use_cassette('show_projects') do
|
28
|
+
id = projects['data'][0]['id']
|
29
|
+
project = client.show_project(id)
|
30
|
+
expect(project['id']).to eq id
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#create_projects' do
|
36
|
+
def project_attributes
|
37
|
+
{
|
38
|
+
name: '1 Billion Dollars',
|
39
|
+
client: 'Dr. Evil'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'creates a new project' do
|
44
|
+
VCR.use_cassette('create_project') do
|
45
|
+
project_count_before = projects['data'].count
|
46
|
+
response = client.create_project(project_attributes)
|
47
|
+
|
48
|
+
new_projects = client.get_projects
|
49
|
+
project_count_after = new_projects['data'].count
|
50
|
+
|
51
|
+
expect(project_count_after).to eq (project_count_before + 1)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#update_project' do
|
57
|
+
context 'given a valid project' do
|
58
|
+
it 'updates an attribute for the project' do
|
59
|
+
name = "#{rand(0..100)} Billion Dollars"
|
60
|
+
response = client.update_project(id, { name: name })
|
61
|
+
expect(response['name']).to eq name
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#delete_project' do
|
67
|
+
context 'given a valid project' do
|
68
|
+
def project_attributes
|
69
|
+
{
|
70
|
+
name: '1 Billion Dollars',
|
71
|
+
client: 'Dr. Evil'
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'deletes a project' do
|
76
|
+
VCR.use_cassette('delete_project') do
|
77
|
+
new_project = client.create_project(project_attributes)
|
78
|
+
response = client.delete_project(new_project['id'])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#get_project_time_entries' do
|
85
|
+
it 'retrieves a list of time entries for a given project' do
|
86
|
+
VCR.use_cassette('get_project_time_entries') do
|
87
|
+
response = client.get_project_time_entries(id)
|
88
|
+
expect(response['data']).to_not be_nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#get_project_time_users' do
|
94
|
+
it 'retrieves a list of users for a given project' do
|
95
|
+
VCR.use_cassette('get_project_time_users') do
|
96
|
+
response = client.get_project_users(id)
|
97
|
+
expect(response['data']).to_not be_nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TenThousandFeet
|
4
|
+
module API
|
5
|
+
describe TimeEntries do
|
6
|
+
|
7
|
+
let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
|
8
|
+
let!(:user) { client.get_users['data'][0] }
|
9
|
+
let!(:projects) {
|
10
|
+
VCR.use_cassette('projects') do
|
11
|
+
client.get_projects
|
12
|
+
end
|
13
|
+
}
|
14
|
+
let!(:project) { projects['data'][0] }
|
15
|
+
let!(:time_entries) {
|
16
|
+
VCR.use_cassette('time_entries') do
|
17
|
+
client.get_time_entries(user['id'])
|
18
|
+
end
|
19
|
+
}
|
20
|
+
let!(:time_entry) { time_entries['data'][0] }
|
21
|
+
let!(:id) { time_entry['id'] }
|
22
|
+
|
23
|
+
describe '#get_time_entries' do
|
24
|
+
it 'retrieves a list of time entries for a user' do
|
25
|
+
VCR.use_cassette('get_time_entries') do
|
26
|
+
hours = time_entries['data'][0]['hours']
|
27
|
+
expect(hours).to_not be_nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#show_time_entries' do
|
33
|
+
it 'retrieves details of a specific time entry' do
|
34
|
+
VCR.use_cassette('show_time_entries') do
|
35
|
+
id = time_entries['data'][0]['id']
|
36
|
+
time_entry = client.show_time_entry(id, user['id'])
|
37
|
+
expect(time_entry['id']).to eq id
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#create_time_entry' do
|
43
|
+
#Required parameters: :date, :hours, :leave_type_id/:project_id/:assignable_id
|
44
|
+
def time_entry_attributes
|
45
|
+
{
|
46
|
+
hours: 10,
|
47
|
+
date: '2013-10-10',
|
48
|
+
project_id: project['id']
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'creates a new project' do
|
53
|
+
VCR.use_cassette('create_time_entry') do
|
54
|
+
time_entry_count_before = time_entries['data'].count
|
55
|
+
response = client.create_time_entry(user['id'], time_entry_attributes)
|
56
|
+
|
57
|
+
new_time_entries = client.get_time_entries(user['id'])
|
58
|
+
time_entry_count_after = new_time_entries['data'].count
|
59
|
+
|
60
|
+
expect(time_entry_count_after).to eq (time_entry_count_before + 1)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#update_time_entry' do
|
66
|
+
context 'given a valid time entry' do
|
67
|
+
it 'updates an attribute for the entry' do
|
68
|
+
hours = rand(0..100)
|
69
|
+
response = client.update_time_entry(id, user['id'], { hours: hours })
|
70
|
+
expect(response['hours']).to eq hours
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TenThousandFeet
|
4
|
+
module API
|
5
|
+
describe UserStatus do
|
6
|
+
|
7
|
+
let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
|
8
|
+
let!(:users) {
|
9
|
+
VCR.use_cassette('users') do
|
10
|
+
client.get_users
|
11
|
+
end
|
12
|
+
}
|
13
|
+
let!(:user) { users['data'][0] }
|
14
|
+
let!(:id) { user['id'] }
|
15
|
+
|
16
|
+
describe '#get_user_statuses' do
|
17
|
+
it 'retrieves a list of statuses for a given user' do
|
18
|
+
VCR.use_cassette('get_user_statuses') do
|
19
|
+
status = client.get_user_statuses(id)
|
20
|
+
expect(status['data']).to_not be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#create_user_status' do
|
26
|
+
def user_status_attributes
|
27
|
+
{
|
28
|
+
status: 'ITO'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'creates a new status for a given user' do
|
33
|
+
VCR.use_cassette('create_user_status') do
|
34
|
+
response = client.create_user_status(id, user_status_attributes)
|
35
|
+
status = client.get_user_statuses(id)
|
36
|
+
expect(status['data'][0]['status']).to eq 'ITO'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TenThousandFeet
|
4
|
+
module API
|
5
|
+
describe Users do
|
6
|
+
|
7
|
+
let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
|
8
|
+
let!(:users) {
|
9
|
+
VCR.use_cassette('users') do
|
10
|
+
client.get_users
|
11
|
+
end
|
12
|
+
}
|
13
|
+
let!(:user) { users['data'][0] }
|
14
|
+
let!(:id) { user['id'] }
|
15
|
+
|
16
|
+
describe '#get_users' do
|
17
|
+
it 'retrieves a list of users' do
|
18
|
+
VCR.use_cassette('get_users') do
|
19
|
+
name = users['data'][0]['first_name']
|
20
|
+
expect(name).to_not be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#show_users' do
|
26
|
+
it 'retrieves details of a specific user' do
|
27
|
+
VCR.use_cassette('show_users') do
|
28
|
+
id = users['data'][0]['id']
|
29
|
+
user = client.show_user(id)
|
30
|
+
expect(user['id']).to eq id
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#create_user' do
|
36
|
+
def user_attributes
|
37
|
+
{
|
38
|
+
first_name: 'Austin',
|
39
|
+
last_name: 'Powers',
|
40
|
+
email: 'austin@yeahbaby.com'
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'creates a new user' do
|
45
|
+
VCR.use_cassette('create_user') do
|
46
|
+
user_count_before = users['data'].count
|
47
|
+
response = client.create_user(user_attributes)
|
48
|
+
|
49
|
+
new_users = client.get_users
|
50
|
+
user_count_after = new_users['data'].count
|
51
|
+
|
52
|
+
expect(user_count_after).to eq (user_count_before + 1)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#update_user' do
|
58
|
+
context 'given a valid user' do
|
59
|
+
it 'updates an attribute for the user' do
|
60
|
+
name = "AustinPowers#{rand(0..100)}"
|
61
|
+
response = client.update_user(id, { first_name: name })
|
62
|
+
expect(response['first_name']).to eq name
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ten_thousand_feet/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ten_thousand_feet"
|
8
|
+
spec.version = TenThousandFeet::VERSION
|
9
|
+
spec.authors = ["Kyle Suss"]
|
10
|
+
spec.email = ["susskyle@gmail.com"]
|
11
|
+
spec.description = %q{The 10,000ft Ruby API Client}
|
12
|
+
spec.summary = %q{Provides Ruby wrappers for the 10,000ft API.}
|
13
|
+
spec.homepage = "http://tackmobile.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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 "rest-client"
|
22
|
+
spec.add_dependency "hashie"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "multi_json"
|
27
|
+
spec.add_development_dependency "vcr"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
spec.add_development_dependency "webmock", "1.8.0"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ten_thousand_feet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kyle Suss
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: multi_json
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
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
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.8.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.8.0
|
139
|
+
description: The 10,000ft Ruby API Client
|
140
|
+
email:
|
141
|
+
- susskyle@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- .gitignore
|
147
|
+
- .rspec
|
148
|
+
- Gemfile
|
149
|
+
- LICENSE.txt
|
150
|
+
- README.md
|
151
|
+
- Rakefile
|
152
|
+
- lib/ten_thousand_feet.rb
|
153
|
+
- lib/ten_thousand_feet/api/assignments.rb
|
154
|
+
- lib/ten_thousand_feet/api/phases.rb
|
155
|
+
- lib/ten_thousand_feet/api/projects.rb
|
156
|
+
- lib/ten_thousand_feet/api/time_entries.rb
|
157
|
+
- lib/ten_thousand_feet/api/user_status.rb
|
158
|
+
- lib/ten_thousand_feet/api/users.rb
|
159
|
+
- lib/ten_thousand_feet/client.rb
|
160
|
+
- lib/ten_thousand_feet/version.rb
|
161
|
+
- spec/spec_helper.rb
|
162
|
+
- spec/ten_thousand_feet/api/assignment_spec.rb
|
163
|
+
- spec/ten_thousand_feet/api/phases_spec.rb
|
164
|
+
- spec/ten_thousand_feet/api/projects_spec.rb
|
165
|
+
- spec/ten_thousand_feet/api/time_entries_spec.rb
|
166
|
+
- spec/ten_thousand_feet/api/user_status_spec.rb
|
167
|
+
- spec/ten_thousand_feet/api/users_spec.rb
|
168
|
+
- spec/ten_thousand_feet/client_spec.rb
|
169
|
+
- ten_thousand_feet.gemspec
|
170
|
+
homepage: http://tackmobile.com
|
171
|
+
licenses:
|
172
|
+
- MIT
|
173
|
+
metadata: {}
|
174
|
+
post_install_message:
|
175
|
+
rdoc_options: []
|
176
|
+
require_paths:
|
177
|
+
- lib
|
178
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - '>='
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
requirements: []
|
189
|
+
rubyforge_project:
|
190
|
+
rubygems_version: 2.1.11
|
191
|
+
signing_key:
|
192
|
+
specification_version: 4
|
193
|
+
summary: Provides Ruby wrappers for the 10,000ft API.
|
194
|
+
test_files:
|
195
|
+
- spec/spec_helper.rb
|
196
|
+
- spec/ten_thousand_feet/api/assignment_spec.rb
|
197
|
+
- spec/ten_thousand_feet/api/phases_spec.rb
|
198
|
+
- spec/ten_thousand_feet/api/projects_spec.rb
|
199
|
+
- spec/ten_thousand_feet/api/time_entries_spec.rb
|
200
|
+
- spec/ten_thousand_feet/api/user_status_spec.rb
|
201
|
+
- spec/ten_thousand_feet/api/users_spec.rb
|
202
|
+
- spec/ten_thousand_feet/client_spec.rb
|