camper 0.0.6 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +48 -2
- data/Gemfile.lock +10 -11
- data/README.md +14 -0
- data/camper.gemspec +1 -0
- data/examples/people.rb +11 -0
- data/examples/projects.rb +12 -0
- data/examples/recordings.rb +13 -0
- data/examples/todolists.rb +50 -0
- data/examples/todos.rb +21 -6
- data/lib/camper.rb +2 -0
- data/lib/camper/api/{comment.rb → comments.rb} +3 -1
- data/lib/camper/api/{message.rb → messages.rb} +1 -1
- data/lib/camper/api/people.rb +97 -0
- data/lib/camper/api/projects.rb +120 -0
- data/lib/camper/api/recordings.rb +84 -0
- data/lib/camper/api/todolists.rb +103 -0
- data/lib/camper/api/todos.rb +198 -0
- data/lib/camper/client.rb +7 -4
- data/lib/camper/core_extensions/object.rb +156 -0
- data/lib/camper/error.rb +6 -0
- data/lib/camper/recording_types.rb +22 -0
- data/lib/camper/request.rb +2 -13
- data/lib/camper/url_utils.rb +26 -0
- data/lib/camper/version.rb +1 -1
- metadata +31 -7
- data/lib/camper/api/project.rb +0 -24
- data/lib/camper/api/todo.rb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dbee68b43218a497b29c8006b70cb344d0925c879f5220aef14228e12cd6dce
|
4
|
+
data.tar.gz: fc3f58b2d04d11912e6fd497c86eba3039dae579c645eb8a5a5493d9076283d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00fabce0dc901476883b26af2e71b8b68fab3859577172e3a4456d20b099ffed533961917388e3eba39fa334f8b9097b73804a15a97264bc9cc6ebd8911b26a1
|
7
|
+
data.tar.gz: b360150b837d8d0d89e794f7145c711a7ef86f88267d9b17d6829b1988ef425f8c82f53b4c0037f74c6a63f655689c93438da9c7f618e5c02c004bffbea27f16
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,49 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [Unreleased](https://github.com/renehernandez/camper/tree/HEAD)
|
4
|
+
|
5
|
+
**Implemented enhancements:**
|
6
|
+
|
7
|
+
- Implement trash\_todo endpoint [\#58](https://github.com/renehernandez/camper/issues/58)
|
8
|
+
- Implement trash\_todolist endpoint [\#57](https://github.com/renehernandez/camper/issues/57)
|
9
|
+
- To-do API is missing update\_todo endpoint [\#49](https://github.com/renehernandez/camper/issues/49)
|
10
|
+
- update\_todolist endpoint now sends the current description if none is specified [\#62](https://github.com/renehernandez/camper/pull/62)
|
11
|
+
- Add trash\_todolist endpoint [\#61](https://github.com/renehernandez/camper/pull/61)
|
12
|
+
- Add trash\_todo endpoint implementation [\#60](https://github.com/renehernandez/camper/pull/60)
|
13
|
+
- Add recordings api [\#53](https://github.com/renehernandez/camper/pull/53)
|
14
|
+
- Add update\_todo implementation [\#52](https://github.com/renehernandez/camper/pull/52)
|
15
|
+
|
16
|
+
**Fixed bugs:**
|
17
|
+
|
18
|
+
- return tag should mention PaginatedResponse instead of Array [\#56](https://github.com/renehernandez/camper/issues/56)
|
19
|
+
- Get endpoints params need to be set under query field [\#54](https://github.com/renehernandez/camper/issues/54)
|
20
|
+
- Update endpoints documentation to use PaginatedResponse [\#59](https://github.com/renehernandez/camper/pull/59)
|
21
|
+
- Fix query string generation in get endpoints [\#55](https://github.com/renehernandez/camper/pull/55)
|
22
|
+
|
23
|
+
## [v0.0.10](https://github.com/renehernandez/camper/tree/v0.0.10) (2020-10-30)
|
24
|
+
|
25
|
+
**Implemented enhancements:**
|
26
|
+
|
27
|
+
- Complete projects api [\#51](https://github.com/renehernandez/camper/pull/51)
|
28
|
+
|
29
|
+
## [v0.0.9](https://github.com/renehernandez/camper/tree/v0.0.9) (2020-10-28)
|
30
|
+
|
31
|
+
**Implemented enhancements:**
|
32
|
+
|
33
|
+
- Split todos and todolists APIs [\#47](https://github.com/renehernandez/camper/pull/47)
|
34
|
+
|
35
|
+
**Merged pull requests:**
|
36
|
+
|
37
|
+
- Bump rubocop from 0.92.0 to 1.0.0 [\#44](https://github.com/renehernandez/camper/pull/44)
|
38
|
+
|
39
|
+
## [v0.0.8](https://github.com/renehernandez/camper/tree/v0.0.8) (2020-10-27)
|
40
|
+
|
41
|
+
**Implemented enhancements:**
|
42
|
+
|
43
|
+
- Add people API [\#46](https://github.com/renehernandez/camper/pull/46)
|
44
|
+
- Raise error if resource can't be commented [\#45](https://github.com/renehernandez/camper/pull/45)
|
45
|
+
|
46
|
+
## [v0.0.7](https://github.com/renehernandez/camper/tree/v0.0.7) (2020-10-04)
|
4
47
|
|
5
48
|
**Implemented enhancements:**
|
6
49
|
|
@@ -30,7 +73,6 @@
|
|
30
73
|
|
31
74
|
- Implement pagination according to basecamp 3 API [\#20](https://github.com/renehernandez/camper/issues/20)
|
32
75
|
- Implement pagination according to Basecamp 3 API [\#26](https://github.com/renehernandez/camper/pull/26)
|
33
|
-
- Remove unreleasedLabel field [\#15](https://github.com/renehernandez/camper/pull/15)
|
34
76
|
|
35
77
|
**Merged pull requests:**
|
36
78
|
|
@@ -59,6 +101,10 @@
|
|
59
101
|
- Request a new access token once it expires [\#13](https://github.com/renehernandez/camper/issues/13)
|
60
102
|
- Retry for new access token [\#16](https://github.com/renehernandez/camper/pull/16)
|
61
103
|
|
104
|
+
**Fixed bugs:**
|
105
|
+
|
106
|
+
- Remove unreleasedLabel field [\#15](https://github.com/renehernandez/camper/pull/15)
|
107
|
+
|
62
108
|
**Documentation:**
|
63
109
|
|
64
110
|
- Initial documentation [\#5](https://github.com/renehernandez/camper/issues/5)
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
camper (0.0.
|
4
|
+
camper (0.0.10)
|
5
|
+
concurrent-ruby (~> 1.1)
|
5
6
|
httparty (~> 0.18)
|
6
7
|
rack-oauth2 (~> 1.14)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
|
-
activesupport (6.0.3.
|
12
|
+
activesupport (6.0.3.4)
|
12
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
14
|
i18n (>= 0.7, < 2)
|
14
15
|
minitest (~> 5.1)
|
@@ -38,7 +39,7 @@ GEM
|
|
38
39
|
minitest (5.14.2)
|
39
40
|
multi_xml (0.6.0)
|
40
41
|
parallel (1.19.2)
|
41
|
-
parser (2.7.
|
42
|
+
parser (2.7.2.0)
|
42
43
|
ast (~> 2.4.1)
|
43
44
|
pry (0.13.1)
|
44
45
|
coderay (~> 1.1)
|
@@ -52,7 +53,7 @@ GEM
|
|
52
53
|
rack (>= 2.1.0)
|
53
54
|
rainbow (3.0.0)
|
54
55
|
rake (13.0.1)
|
55
|
-
regexp_parser (1.8.
|
56
|
+
regexp_parser (1.8.2)
|
56
57
|
rexml (3.2.4)
|
57
58
|
rspec (3.9.0)
|
58
59
|
rspec-core (~> 3.9.0)
|
@@ -67,29 +68,27 @@ GEM
|
|
67
68
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
69
|
rspec-support (~> 3.9.0)
|
69
70
|
rspec-support (3.9.3)
|
70
|
-
rubocop (0.
|
71
|
+
rubocop (1.0.0)
|
71
72
|
parallel (~> 1.10)
|
72
73
|
parser (>= 2.7.1.5)
|
73
74
|
rainbow (>= 2.2.2, < 4.0)
|
74
|
-
regexp_parser (>= 1.
|
75
|
+
regexp_parser (>= 1.8)
|
75
76
|
rexml
|
76
|
-
rubocop-ast (>= 0.
|
77
|
+
rubocop-ast (>= 0.6.0)
|
77
78
|
ruby-progressbar (~> 1.7)
|
78
79
|
unicode-display_width (>= 1.4.0, < 2.0)
|
79
|
-
rubocop-ast (0.
|
80
|
+
rubocop-ast (1.0.0)
|
80
81
|
parser (>= 2.7.1.5)
|
81
|
-
strscan (>= 1.0.0)
|
82
82
|
rubocop-performance (1.8.1)
|
83
83
|
rubocop (>= 0.87.0)
|
84
84
|
rubocop-ast (>= 0.4.0)
|
85
85
|
ruby-progressbar (1.10.1)
|
86
|
-
strscan (1.0.3)
|
87
86
|
thread_safe (0.3.6)
|
88
87
|
tzinfo (1.2.7)
|
89
88
|
thread_safe (~> 0.1)
|
90
89
|
unicode-display_width (1.7.0)
|
91
90
|
yard (0.9.25)
|
92
|
-
zeitwerk (2.4.
|
91
|
+
zeitwerk (2.4.1)
|
93
92
|
|
94
93
|
PLATFORMS
|
95
94
|
ruby
|
data/README.md
CHANGED
@@ -24,6 +24,20 @@ Or install it yourself as:
|
|
24
24
|
$ gem install camper
|
25
25
|
```
|
26
26
|
|
27
|
+
## Status of API endpoints
|
28
|
+
|
29
|
+
The up-to-date list of Basecamp API endpoints can be found at [here](https://github.com/basecamp/bc3-api#api-endpoints).
|
30
|
+
|
31
|
+
Currently, Camper supports the following endpoints:
|
32
|
+
|
33
|
+
* [Comments](https://github.com/basecamp/bc3-api/blob/master/sections/comments.md): Implementation at [comments.rb](https://github.com/renehernandez/camper/blob/main/lib/camper/api/comments.rb) (Partial)
|
34
|
+
* [Messages](https://github.com/basecamp/bc3-api/blob/master/sections/messages.md): Implementation at [messages.rb](https://github.com/renehernandez/camper/blob/main/lib/camper/api/messages.rb) (Partial)
|
35
|
+
* [People](https://github.com/basecamp/bc3-api/blob/master/sections/people.md): Implementation at [people.rb](https://github.com/renehernandez/camper/blob/main/lib/camper/api/people.rb) (Complete)
|
36
|
+
* [Projects](https://github.com/basecamp/bc3-api/blob/master/sections/projects.md): Implementation at [projects.rb](https://github.com/renehernandez/camper/blob/main/lib/camper/api/projects.rb) (Complete)
|
37
|
+
* [Recordings](https://github.com/basecamp/bc3-api/blob/master/sections/recordings.md): Implementation at [recordings.rb](https://github.com/renehernandez/camper/blob/main/lib/camper/api/recordings.rb)
|
38
|
+
* [To-do list](https://github.com/basecamp/bc3-api/blob/master/sections/todolists.md): Implementation at [todolists.rb](https://github.com/renehernandez/camper/blob/main/lib/camper/api/todolists.rb) (Complete)
|
39
|
+
* [To-dos](https://github.com/basecamp/bc3-api/blob/master/sections/todos.md): Implementation at [todos.rb](https://github.com/renehernandez/camper/blob/main/lib/camper/api/todos.rb) (Complete)
|
40
|
+
|
27
41
|
## Usage
|
28
42
|
|
29
43
|
### Configuration
|
data/camper.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
spec.add_dependency 'httparty', '~> 0.18'
|
30
30
|
spec.add_dependency 'rack-oauth2', '~> 1.14'
|
31
|
+
spec.add_dependency 'concurrent-ruby', '~> 1.1'
|
31
32
|
|
32
33
|
spec.add_development_dependency 'rake', '~> 13.0'
|
33
34
|
spec.add_development_dependency 'rspec', '~> 3.9'
|
data/examples/people.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'camper'
|
4
|
+
|
5
|
+
client = Camper.client
|
6
|
+
|
7
|
+
project = client.project(ENV['PROJECT_ID'])
|
8
|
+
|
9
|
+
puts "Project name: #{project.name}"
|
10
|
+
puts "Project description: #{project.description}"
|
11
|
+
|
12
|
+
client.update_project(project, name: 'Hermes Testing', description: 'Hermes integration testing')
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'camper'
|
4
|
+
|
5
|
+
client = Camper.client
|
6
|
+
|
7
|
+
projects = client.projects
|
8
|
+
|
9
|
+
projects.auto_paginate do |p|
|
10
|
+
puts "Project: #{p.name}"
|
11
|
+
|
12
|
+
todoset = client.todoset(p)
|
13
|
+
|
14
|
+
puts "Ratio of completed Todos in Todoset: #{todoset.completed_ratio}"
|
15
|
+
|
16
|
+
puts 'Listing active todolists'
|
17
|
+
client.todolists(todoset).auto_paginate(5) do |list|
|
18
|
+
puts "Todolist: #{list.title}"
|
19
|
+
|
20
|
+
client.todos(list).auto_paginate do |todo|
|
21
|
+
puts "Todo: #{todo.title}"
|
22
|
+
puts "Get Todo using project id: #{client.todo(p.id, todo.id).title}"
|
23
|
+
puts "Get Todo using project resource: #{client.todo(p, todo.id).title}"
|
24
|
+
puts "Get Todo using todolist resource: #{client.todo(list, todo.id).title}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
client.todolists(p)
|
30
|
+
rescue Camper::Error::InvalidParameter, NoMethodError
|
31
|
+
puts 'Cannot use a project p to get the todolists'
|
32
|
+
end
|
33
|
+
|
34
|
+
puts 'Listing archived todolists'
|
35
|
+
client.todolists(todoset, status: :archived).auto_paginate do |list|
|
36
|
+
client.todos(list).auto_paginate do |todo|
|
37
|
+
puts "Todo: #{todo.title}"
|
38
|
+
puts "Can be commented: #{todo.can_be_commented?}"
|
39
|
+
puts "It's completed: #{todo.completed}"
|
40
|
+
|
41
|
+
client.complete_todo(todo)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
puts 'Create a new todolist'
|
46
|
+
new_list = client.create_todolist(todoset, 'Temporary list')
|
47
|
+
puts "Todolist title: #{new_list.title}"
|
48
|
+
puts 'Trash list'
|
49
|
+
client.trash_todolist(new_list)
|
50
|
+
end
|
data/examples/todos.rb
CHANGED
@@ -10,18 +10,33 @@ end
|
|
10
10
|
|
11
11
|
projects = client.projects
|
12
12
|
|
13
|
-
|
14
|
-
puts "Project: #{p.inspect}"
|
13
|
+
selected_todo = nil
|
15
14
|
|
16
|
-
|
15
|
+
projects.auto_paginate do |p|
|
16
|
+
puts "Project: #{p.name}"
|
17
17
|
|
18
18
|
todoset = client.todoset(p)
|
19
19
|
|
20
|
+
puts "Ratio of completed Todos in Todoset: #{todoset.completed_ratio}"
|
21
|
+
|
20
22
|
client.todolists(todoset).auto_paginate(5) do |list|
|
21
23
|
puts "Todolist: #{list.title}"
|
22
24
|
|
23
|
-
client.todos(list).auto_paginate do |todo|
|
24
|
-
puts todo.
|
25
|
+
client.todos(list).auto_paginate(1) do |todo|
|
26
|
+
puts "Todo: #{todo.title}"
|
27
|
+
puts "Get Todo using project id: #{client.todo(p.id, todo.id).title}"
|
28
|
+
puts "Get Todo using project resource: #{client.todo(p, todo.id).title}"
|
29
|
+
puts "Get Todo using todolist resource: #{client.todo(list, todo.id).title}"
|
30
|
+
|
31
|
+
selected_todo = todo
|
25
32
|
end
|
33
|
+
|
34
|
+
puts 'Create new todo'
|
35
|
+
new_todo = client.create_todo(list, 'new todo')
|
36
|
+
puts "New Todo title: #{new_todo.title}"
|
37
|
+
puts 'Trash new todo'
|
38
|
+
client.trash_todo(new_todo)
|
26
39
|
end
|
27
|
-
end
|
40
|
+
end
|
41
|
+
|
42
|
+
client.update_todo(selected_todo, { description: 'New Description' })
|
data/lib/camper.rb
CHANGED
@@ -6,7 +6,9 @@ require 'rack/oauth2'
|
|
6
6
|
require 'camper/version'
|
7
7
|
require 'camper/logging'
|
8
8
|
require 'camper/error'
|
9
|
+
require 'camper/recording_types'
|
9
10
|
require 'camper/configuration'
|
11
|
+
require 'camper/url_utils'
|
10
12
|
require 'camper/authorization'
|
11
13
|
require 'camper/resource'
|
12
14
|
require 'camper/pagination_data'
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Camper::Client
|
4
|
-
module
|
4
|
+
module CommentsAPI
|
5
5
|
def create_comment(resource, content)
|
6
|
+
raise Error::ResourceCannotBeCommented, resource unless resource.can_be_commented?
|
7
|
+
|
6
8
|
post(resource.comments_url, override_path: true, body: { content: content })
|
7
9
|
end
|
8
10
|
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Camper::Client
|
4
|
+
# Defines methods related to people.
|
5
|
+
# @see https://github.com/basecamp/bc3-api/blob/master/sections/people.md
|
6
|
+
module PeopleAPI
|
7
|
+
# Get all people visible to the current user
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# client.people
|
11
|
+
#
|
12
|
+
# @return [PaginatedResponse<Resource>]
|
13
|
+
# @see https://github.com/basecamp/bc3-api/blob/master/sections/people.md#get-all-people
|
14
|
+
def people
|
15
|
+
get('/people')
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get all active people on the project with the given ID
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# client.people_in_project(10)
|
22
|
+
# @example
|
23
|
+
# client.people_in_project("20")
|
24
|
+
# @example
|
25
|
+
# client.people_in_project(my_project)
|
26
|
+
#
|
27
|
+
# @param project [Resource|Integer|String] A project resource or a project id
|
28
|
+
# @return [PaginatedResponse<Resource>]
|
29
|
+
# @see https://github.com/basecamp/bc3-api/blob/master/sections/people.md#get-people-on-a-project
|
30
|
+
def people_in_project(project)
|
31
|
+
id = project.respond_to?(:id) ? project.id : project
|
32
|
+
|
33
|
+
get("/projects/#{id}/people")
|
34
|
+
end
|
35
|
+
|
36
|
+
# Allows granting new and existing people access to a project, and revoking access from existing people.
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# client.update_access_in_project(10, { grant: [102, 127] })
|
40
|
+
# @example
|
41
|
+
# client.update_access_in_project("8634", { revoke: [300, 12527] })
|
42
|
+
# @example
|
43
|
+
# client.update_access_in_project(my_project, {
|
44
|
+
# create: [{
|
45
|
+
# name: "Victor Copper",
|
46
|
+
# email_address: "victor@hanchodesign.com"
|
47
|
+
# }]
|
48
|
+
# })
|
49
|
+
#
|
50
|
+
# @param project [Resource|Integer|String] A project resource or a project id
|
51
|
+
# @param options [Hash] options to update access, either grant, revoke or create new people
|
52
|
+
# @return [Resource]
|
53
|
+
# @raise [Error::InvalidParameter] if no option is specified
|
54
|
+
# @see https://github.com/basecamp/bc3-api/blob/master/sections/people.md#update-who-can-access-a-project
|
55
|
+
def update_access_in_project(project, options = {})
|
56
|
+
raise Camper::Error::InvalidParameter, 'options cannot be empty' if options.empty?
|
57
|
+
|
58
|
+
id = project.respond_to?(:id) ? project.id : project
|
59
|
+
|
60
|
+
put("/projects/#{id}/people/users", body: { **options })
|
61
|
+
end
|
62
|
+
|
63
|
+
# Get all people on this Basecamp account who can be pinged
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# client.pingable_people
|
67
|
+
#
|
68
|
+
# @return [PaginatedResponse<Resource>]
|
69
|
+
# @see https://github.com/basecamp/bc3-api/blob/master/sections/people.md#get-pingable-people
|
70
|
+
def pingable_people
|
71
|
+
get('/circles/people')
|
72
|
+
end
|
73
|
+
|
74
|
+
# Get the profile for the user with the given ID
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# client.person(234790)
|
78
|
+
#
|
79
|
+
# @param id [Integer|String] A user id
|
80
|
+
# @return [Resource]
|
81
|
+
# @see https://github.com/basecamp/bc3-api/blob/master/sections/people.md#get-person
|
82
|
+
def person(id)
|
83
|
+
get("/people/#{id}")
|
84
|
+
end
|
85
|
+
|
86
|
+
# Get the current user's personal info.
|
87
|
+
#
|
88
|
+
# @example
|
89
|
+
# client.profile
|
90
|
+
#
|
91
|
+
# @return [Resource]
|
92
|
+
# @see https://github.com/basecamp/bc3-api/blob/master/sections/people.md#get-my-personal-info
|
93
|
+
def profile
|
94
|
+
get('/my/profile')
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|