camper 0.0.7 → 0.0.8

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
  SHA256:
3
- metadata.gz: fa90563f8a1f1cc3ba09a874f10130511620dbe0afb687aedf2a70f7d97bde14
4
- data.tar.gz: 753c1ca3bedeff92690f267e75c045357535fcc10bedc7b7df42f64ca9f9d7b8
3
+ metadata.gz: ac986df88ec826cc3b15bb75ba1bab382a144f6fdbf9900881907e7f82aab633
4
+ data.tar.gz: 122bba57a7e32a886390dbae0220122c86417c064a9ed9815085639fb5f4519c
5
5
  SHA512:
6
- metadata.gz: 179b1ecd4431b2049ddbb135a260f6b47ade0a8e3a3aef021f8027e4ba7b8ff0561567179fd503fe317a66099ca30b46296e6e99c3deead27a9e0ee347aed9c5
7
- data.tar.gz: a976b84f32e91336a0be556417098de9218aec0d1f05c632c9bc41d4f99f699364d152ec4caf1b89917a32ccf13c61ac447529930e57ca0ab127250f954d096f
6
+ metadata.gz: 9c7dbea42ec5e6ab228fe0fe627e61e45877f9c82803391005d0c45c262231c165bd523036f3bd38072be2c0ace8510dfc61f2ab792dc8ad27e66b3deae710c5
7
+ data.tar.gz: 1a7d91f083e430ee984bf81e1f55f5a70281721071e2fd86a947ac7b26a99fc18324bd4da88cbaa2d8ab34e989f2f6396197a904670e785ae42b002b07667b78
@@ -1,6 +1,13 @@
1
1
  # Changelog
2
2
 
3
- ## [v0.0.6](https://github.com/renehernandez/camper/tree/v0.0.6) (2020-10-01)
3
+ ## [Unreleased](https://github.com/renehernandez/camper/tree/HEAD)
4
+
5
+ **Implemented enhancements:**
6
+
7
+ - Add people API [\#46](https://github.com/renehernandez/camper/pull/46)
8
+ - Raise error if resource can't be commented [\#45](https://github.com/renehernandez/camper/pull/45)
9
+
10
+ ## [v0.0.7](https://github.com/renehernandez/camper/tree/v0.0.7) (2020-10-04)
4
11
 
5
12
  **Implemented enhancements:**
6
13
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- camper (0.0.5)
4
+ camper (0.0.7)
5
5
  httparty (~> 0.18)
6
6
  rack-oauth2 (~> 1.14)
7
7
 
data/README.md CHANGED
@@ -24,6 +24,18 @@ Or install it yourself as:
24
24
  $ gem install camper
25
25
  ```
26
26
 
27
+ ## Implemented 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](./lib/camper/api/comments.rb) **Partial**
34
+ * [Messages](https://github.com/basecamp/bc3-api/blob/master/sections/messages.md): Implementation at [messages.rb](./lib/camper/api/messages.rb) **Partial**
35
+ * [People](https://github.com/basecamp/bc3-api/blob/master/sections/people.md): Implementation at [people.rb](./lib/camper/api/people.rb) **Complete**
36
+ * [Projects](https://github.com/basecamp/bc3-api/blob/master/sections/projects.md): Implementation at [projects.rb](./lib/camper/api/projects.rb) **Partial**
37
+ * [To-dos](https://github.com/basecamp/bc3-api/blob/master/sections/todos.md): Implementation at [todos.rb](./lib/camper/api/todos.rb) **Partial**
38
+
27
39
  ## Usage
28
40
 
29
41
  ### Configuration
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Camper::Client
4
- module CommentAPI
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
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Camper::Client
4
- module MessageAPI
4
+ module MessagesAPI
5
5
  def messages(message_board)
6
6
  get(message_board.messages_url, override_path: true)
7
7
  end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Camper::Client
4
+ # Defines methods related to people.
5
+ # @see ttps://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 [Array<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 [Array<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::RequestIsMissingParameters] 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 RequestIsMissingParameters, '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 [Array<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
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Camper::Client
4
- module ProjectAPI
5
-
4
+ module ProjectsAPI
6
5
  def projects(options = {})
7
- get("/projects", options)
6
+ get('/projects', options)
8
7
  end
9
8
 
10
9
  def project(id)
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Camper::Client
4
- module TodoAPI
5
-
4
+ module TodosAPI
6
5
  # Get the todolists associated with the todoset
7
6
  #
8
7
  # @example
@@ -14,7 +13,7 @@ class Camper::Client
14
13
  # @param options [Hash] extra options to filter the list of todolist
15
14
  # @return [Array<Resource>]
16
15
  # @see https://github.com/basecamp/bc3-api/blob/master/sections/todolists.md#get-to-do-lists
17
- def todolists(todoset, options={})
16
+ def todolists(todoset, options = {})
18
17
  get(todoset.todolists_url, options.merge(override_path: true))
19
18
  end
20
19
 
@@ -42,7 +41,7 @@ class Camper::Client
42
41
  # @param options [Hash] options to filter the list of todos
43
42
  # @return [Resource]
44
43
  # @see https://github.com/basecamp/bc3-api/blob/master/sections/todos.md#get-to-dos
45
- def todos(todolist, options={})
44
+ def todos(todolist, options = {})
46
45
  get(todolist.todos_url, options.merge(override_path: true))
47
46
  end
48
47
 
@@ -62,7 +61,7 @@ class Camper::Client
62
61
  # @param options [Hash] extra configuration for the todo such as due_date and description
63
62
  # @return [Resource]
64
63
  # @see https://github.com/basecamp/bc3-api/blob/master/sections/todos.md#create-a-to-do
65
- def create_todo(todolist, content, options={})
64
+ def create_todo(todolist, content, options = {})
66
65
  post(todolist.todos_url, body: { content: content, **options }, override_path: true)
67
66
  end
68
67
 
@@ -12,12 +12,13 @@ module Camper
12
12
 
13
13
  # Keep in alphabetical order
14
14
  include Authorization
15
- include CommentAPI
15
+ include CommentsAPI
16
16
  include Logging
17
- include MessageAPI
18
- include ProjectAPI
17
+ include MessagesAPI
18
+ include PeopleAPI
19
+ include ProjectsAPI
19
20
  include ResourceAPI
20
- include TodoAPI
21
+ include TodosAPI
21
22
 
22
23
  # Creates a new Client instance.
23
24
  # @raise [Error:MissingCredentials]
@@ -13,6 +13,10 @@ module Camper
13
13
 
14
14
  class MissingBody < Error; end
15
15
 
16
+ class ResourceCannotBeCommented < Error; end
17
+
18
+ class RequestIsMissingParameters < Error; end
19
+
16
20
  # Raised when impossible to parse response body.
17
21
  class Parsing < Error; end
18
22
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Camper
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.8'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - renehernandez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-04 00:00:00.000000000 Z
11
+ date: 2020-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -114,11 +114,12 @@ files:
114
114
  - examples/obtain_acces_token.rb
115
115
  - examples/todos.rb
116
116
  - lib/camper.rb
117
- - lib/camper/api/comment.rb
118
- - lib/camper/api/message.rb
119
- - lib/camper/api/project.rb
117
+ - lib/camper/api/comments.rb
118
+ - lib/camper/api/messages.rb
119
+ - lib/camper/api/people.rb
120
+ - lib/camper/api/projects.rb
120
121
  - lib/camper/api/resource.rb
121
- - lib/camper/api/todo.rb
122
+ - lib/camper/api/todos.rb
122
123
  - lib/camper/authorization.rb
123
124
  - lib/camper/client.rb
124
125
  - lib/camper/configuration.rb
@@ -152,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  requirements: []
155
- rubygems_version: 3.1.2
156
+ rubygems_version: 3.1.4
156
157
  signing_key:
157
158
  specification_version: 4
158
159
  summary: Ruby client for Basecamp 3 API