camper 0.0.5 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 984eef67b2149dac0f1735f6dcda5012b140dd4d3404b8523e23b21096d510de
4
- data.tar.gz: 90b228ed0f5388a6866346c46b98a608d44a8753bec6a7eef844cd85583afd34
3
+ metadata.gz: 1b8a4cdfcb11473573ac1bb1f600964f12f8722093a8a9446a47d1594e4a0963
4
+ data.tar.gz: 43810e0cf19d16b5a2a71789401758f497dfa46d43e70ea8c9e9e5a8160bcb51
5
5
  SHA512:
6
- metadata.gz: 6bac9cf265b6ec6ddcdaa38fb6290e9c35b16c8a4dc1c64446589eea095dd2a4dcda4a491b0e46c20c9aad45e6af4d8168b693dcfc556d125b78fc8de35caf7a
7
- data.tar.gz: c605925535d3052d2844d2fe7ac0ee2b420f2891c78e1e14422bb3e8cf9464399eb741dbdde2fd7611f49743de2097f8a62f06e98e0419d2dc4298551328b604
6
+ metadata.gz: 261ab2cdc09cae324aef2183d5bba9fa087c87337f2b7fe5e007bb91af4c2a6abb56f32a158437f2f71e1acc5670f76fe612911810402e60647c161733bf6199
7
+ data.tar.gz: fe517bdf6508916f6cd037424f6e95a589e1ad27303e25b385d44d51c19c722e7d47ad9d1de28bab7f2da5bbe5ffd05f8255cf4400cff980b6cb31f9594e7f59
data/.gitignore CHANGED
@@ -57,4 +57,4 @@ build-iPhoneSimulator/
57
57
 
58
58
  .rspec_status
59
59
 
60
- .env
60
+ .env*
@@ -7,9 +7,10 @@ AllCops:
7
7
  NewCops: enable
8
8
  Exclude:
9
9
  - 'camper.gemspec'
10
+ - 'lib/camper/core_extensions/object.rb'
10
11
 
11
12
  Layout/LineLength:
12
- Max: 123
13
+ Max: 120
13
14
  Exclude:
14
15
  - 'lib/camper/client/*'
15
16
  - 'spec/**/*'
@@ -18,6 +19,9 @@ Metrics/BlockLength:
18
19
  Exclude:
19
20
  - 'spec/**/*'
20
21
 
22
+ Metrics/AbcSize:
23
+ Max: 20
24
+
21
25
  Style/Documentation:
22
26
  Enabled: false
23
27
 
@@ -0,0 +1,4 @@
1
+ --no-private
2
+ lib/**/*.rb
3
+ examples/*.rb -
4
+ README.md CONTRIBUTING.md CHANGELOG.md
@@ -4,8 +4,50 @@
4
4
 
5
5
  **Implemented enhancements:**
6
6
 
7
+ - Complete projects api [\#51](https://github.com/renehernandez/camper/pull/51)
8
+
9
+ ## [v0.0.9](https://github.com/renehernandez/camper/tree/v0.0.9) (2020-10-28)
10
+
11
+ **Implemented enhancements:**
12
+
13
+ - Split todos and todolists APIs [\#47](https://github.com/renehernandez/camper/pull/47)
14
+
15
+ **Merged pull requests:**
16
+
17
+ - Bump rubocop from 0.92.0 to 1.0.0 [\#44](https://github.com/renehernandez/camper/pull/44)
18
+
19
+ ## [v0.0.8](https://github.com/renehernandez/camper/tree/v0.0.8) (2020-10-27)
20
+
21
+ **Implemented enhancements:**
22
+
23
+ - Add people API [\#46](https://github.com/renehernandez/camper/pull/46)
24
+ - Raise error if resource can't be commented [\#45](https://github.com/renehernandez/camper/pull/45)
25
+
26
+ ## [v0.0.7](https://github.com/renehernandez/camper/tree/v0.0.7) (2020-10-04)
27
+
28
+ **Implemented enhancements:**
29
+
30
+ - Implement handling error according to Basecamp 3 API specifications [\#21](https://github.com/renehernandez/camper/issues/21)
31
+ - Add ability to complete a Todo [\#12](https://github.com/renehernandez/camper/issues/12)
32
+ - Multiple improvements [\#38](https://github.com/renehernandez/camper/pull/38)
33
+ - Error handling improvements [\#37](https://github.com/renehernandez/camper/pull/37)
34
+
35
+ **Documentation:**
36
+
37
+ - Enable documentation in RubyDoc [\#6](https://github.com/renehernandez/camper/issues/6)
38
+ - Add yard documentation [\#41](https://github.com/renehernandez/camper/pull/41)
39
+ - Fix gem badge [\#39](https://github.com/renehernandez/camper/pull/39)
40
+
41
+ **Merged pull requests:**
42
+
43
+ - Rename add\_comment to create\_comment [\#40](https://github.com/renehernandez/camper/pull/40)
44
+ - Bump rubocop from 0.91.0 to 0.92.0 [\#36](https://github.com/renehernandez/camper/pull/36)
45
+
46
+ ## [v0.0.5](https://github.com/renehernandez/camper/tree/v0.0.5) (2020-09-22)
47
+
48
+ **Implemented enhancements:**
49
+
7
50
  - Enable dependabot [\#22](https://github.com/renehernandez/camper/pull/22)
8
- - Retry for new access token [\#16](https://github.com/renehernandez/camper/pull/16)
9
51
 
10
52
  **Fixed bugs:**
11
53
 
@@ -37,6 +79,7 @@
37
79
  **Implemented enhancements:**
38
80
 
39
81
  - Request a new access token once it expires [\#13](https://github.com/renehernandez/camper/issues/13)
82
+ - Retry for new access token [\#16](https://github.com/renehernandez/camper/pull/16)
40
83
 
41
84
  **Fixed bugs:**
42
85
 
@@ -1,14 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- camper (0.0.4)
4
+ camper (0.0.9)
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.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.1.4)
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.0)
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,17 +68,17 @@ 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.91.0)
71
+ rubocop (1.0.0)
71
72
  parallel (~> 1.10)
72
- parser (>= 2.7.1.1)
73
+ parser (>= 2.7.1.5)
73
74
  rainbow (>= 2.2.2, < 4.0)
74
- regexp_parser (>= 1.7)
75
+ regexp_parser (>= 1.8)
75
76
  rexml
76
- rubocop-ast (>= 0.4.0, < 1.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.4.2)
80
- parser (>= 2.7.1.4)
80
+ rubocop-ast (1.0.0)
81
+ parser (>= 2.7.1.5)
81
82
  rubocop-performance (1.8.1)
82
83
  rubocop (>= 0.87.0)
83
84
  rubocop-ast (>= 0.4.0)
@@ -86,7 +87,8 @@ GEM
86
87
  tzinfo (1.2.7)
87
88
  thread_safe (~> 0.1)
88
89
  unicode-display_width (1.7.0)
89
- zeitwerk (2.4.0)
90
+ yard (0.9.25)
91
+ zeitwerk (2.4.1)
90
92
 
91
93
  PLATFORMS
92
94
  ruby
@@ -98,6 +100,7 @@ DEPENDENCIES
98
100
  rspec (~> 3.9)
99
101
  rubocop
100
102
  rubocop-performance
103
+ yard (~> 0.9)
101
104
 
102
105
  BUNDLED WITH
103
106
  2.1.4
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # camper ![CI](https://github.com/renehernandez/camper/workflows/CI/badge.svg) [![Gem Version](https://badge.fury.io/rb/Camper.svg)](https://badge.fury.io/rb/camper)
1
+ # camper ![CI](https://github.com/renehernandez/camper/workflows/CI/badge.svg) [![Gem Version](https://badge.fury.io/rb/camper.svg)](https://badge.fury.io/rb/camper)
2
2
 
3
3
  Camper is a Ruby wrapper for the [Basecamp 3 API](https://github.com/basecamp/bc3-api).
4
4
 
5
+ You can check out the gem documentation at [https://www.rubydoc.org/gems/camper](https://www.rubydoc.org/gems/camper)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -22,9 +24,24 @@ Or install it yourself as:
22
24
  $ gem install camper
23
25
  ```
24
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) (Partial)
37
+ * [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) (Almost complete, only missing todolist trashing)
38
+ * [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) (Almost complete, only missing todo trashing)
39
+
25
40
  ## Usage
26
41
 
27
- Getting a client and configuring it:
42
+ ### Configuration
43
+
44
+ Getting a `client` and configuring it:
28
45
 
29
46
  ```ruby
30
47
  require 'camper'
@@ -32,44 +49,58 @@ require 'camper'
32
49
  client = Camper.client
33
50
 
34
51
  client.configure do |config|
35
- config.client_id = ENV['BASEcamper_CLIENT_ID']
36
- config.client_secret = ENV['BASEcamper_CLIENT_SECRET']
37
- config.account_number = ENV['BASEcamper_ACCOUNT_NUMBER']
38
- config.refresh_token = ENV['BASEcamper_REFRESH_TOKEN']
39
- config.access_token = ENV['BASEcamper_ACCESS_TOKEN']
52
+ config.client_id = 'client_id'
53
+ config.client_secret = 'client_secret'
54
+ config.account_number = 'account_number'
55
+ config.refresh_token = 'refresh_token'
56
+ config.access_token = 'access_token'
40
57
  end
41
-
42
- projects = client.projects
43
58
  ```
44
59
 
45
- Alternatively, it is possible to invoke the top-level `#configure` method to get a client:
60
+ Alternatively, it is possible to invoke the top-level `#configure` method to get a `client`:
46
61
 
47
62
  ```ruby
48
63
  require 'camper'
49
64
 
50
65
  client = Camper.configure do |config|
51
- config.client_id = ENV['BASEcamper_CLIENT_ID']
52
- config.client_secret = ENV['BASEcamper_CLIENT_SECRET']
53
- config.account_number = ENV['BASEcamper_ACCOUNT_NUMBER']
54
- config.refresh_token = ENV['BASEcamper_REFRESH_TOKEN']
55
- config.access_token = ENV['BASEcamper_ACCESS_TOKEN']
66
+ config.client_id = 'client_id'
67
+ config.client_secret = 'client_secret'
68
+ config.account_number = 'account_number'
69
+ config.refresh_token = 'refresh_token'
70
+ config.access_token = 'access_token'
56
71
  end
72
+ ```
57
73
 
58
- # gets a paginated response
59
- projects = client.projects
74
+ Also, the `client` can read directly the following environment variables:
75
+
76
+ * `BASECAMP_CLIENT_ID`
77
+ * `BASECAMP_CLIENT_SECRET`
78
+ * `BASECAMP_ACCOUNT_NUMBER`
79
+ * `BASECAMP_REFRESH_TOKEN`
80
+ * `BASECAMP_ACCESS_TOKEN`
81
+
82
+ then the code would look like:
83
+
84
+ ```ruby
85
+ require 'camper'
86
+
87
+ client = Camper.client
60
88
  ```
61
89
 
90
+
91
+ ### Examples
92
+
62
93
  Example getting list of TODOs:
63
94
 
64
95
  ```ruby
65
96
  require 'camper'
66
97
 
67
98
  client = Camper.configure do |config|
68
- config.client_id = ENV['BASEcamper_CLIENT_ID']
69
- config.client_secret = ENV['BASEcamper_CLIENT_SECRET']
70
- config.account_number = ENV['BASEcamper_ACCOUNT_NUMBER']
71
- config.refresh_token = ENV['BASEcamper_REFRESH_TOKEN']
72
- config.access_token = ENV['BASEcamper_ACCESS_TOKEN']
99
+ config.client_id = ENV['BASECAMP_CLIENT_ID']
100
+ config.client_secret = ENV['BASECAMP_CLIENT_SECRET']
101
+ config.account_number = ENV['BASECAMP_ACCOUNT_NUMBER']
102
+ config.refresh_token = ENV['BASECAMP_REFRESH_TOKEN']
103
+ config.access_token = ENV['BASECAMP_ACCESS_TOKEN']
73
104
  end
74
105
 
75
106
  # gets a paginated response
@@ -28,7 +28,9 @@ 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'
35
+ spec.add_development_dependency 'yard', '~> 0.9'
34
36
  end
@@ -25,7 +25,7 @@ projects.auto_paginate do |p|
25
25
  # Adds a comment on the first todolist
26
26
  list = client.todolists(todoset).first
27
27
  puts "Todolist: #{list.title}, can be commented on: #{list.can_be_commented?}"
28
- client.add_comment(list, 'New <b>comment</b> with <i>HTML support</i>')
28
+ client.create_comment(list, 'New <b>comment</b> with <i>HTML support</i>')
29
29
  comments = client.comments(list)
30
30
  idx = 0
31
31
  comments.auto_paginate do |c|
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'camper'
4
+
5
+ # It will configure the client using the basecamp environment variables
6
+ client = Camper.client
7
+
8
+ project = client.project(ENV['PROJECT_ID'])
9
+
10
+ todoset = client.todoset(project)
11
+
12
+ todolist = client.todolist(todoset, ENV['TODOLIST_ID'])
13
+
14
+ puts todolist.title
15
+
16
+ client.todos(todolist).auto_paginate do |todo|
17
+ puts todo.title
18
+ end
19
+
20
+ todo = client.create_todo(todolist, 'TODO from camper', description: 'This is a todo created with camper')
21
+
22
+ puts todo.title
23
+
24
+ client.complete_todo(todo)
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'camper'
4
+
5
+ client = Camper.client
6
+
7
+ current_user = client.profile
8
+
9
+ puts "Current User:\n#{current_user.inspect}"
10
+
11
+ puts "People:\n#{client.people.inspect}"
@@ -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,32 @@
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
+ client.todolists(todoset).auto_paginate(5) do |list|
17
+ puts "Todolist: #{list.title}"
18
+
19
+ client.todos(list).auto_paginate do |todo|
20
+ puts "Todo: #{todo.title}"
21
+ puts "Get Todo using project id: #{client.todo(p.id, todo.id).title}"
22
+ puts "Get Todo using project resource: #{client.todo(p, todo.id).title}"
23
+ puts "Get Todo using todolist resource: #{client.todo(list, todo.id).title}"
24
+ end
25
+ end
26
+
27
+ begin
28
+ client.todolists(p)
29
+ rescue Camper::Error::InvalidParameter
30
+ puts 'Cannot use a project p to get the todolists'
31
+ end
32
+ end
@@ -11,17 +11,20 @@ end
11
11
  projects = client.projects
12
12
 
13
13
  projects.auto_paginate do |p|
14
- puts "Project: #{p.inspect}"
15
-
16
- puts "Todo set: #{p.todoset.inspect}"
14
+ puts "Project: #{p.name}"
17
15
 
18
16
  todoset = client.todoset(p)
19
17
 
18
+ puts "Ratio of completed Todos in Todoset: #{todoset.completed_ratio}"
19
+
20
20
  client.todolists(todoset).auto_paginate(5) do |list|
21
21
  puts "Todolist: #{list.title}"
22
22
 
23
- client.todos(list).auto_paginate do |todo|
24
- puts todo.inspect
23
+ client.todos(list).auto_paginate(1) do |todo|
24
+ puts "Todo: #{todo.title}"
25
+ puts "Get Todo using project id: #{client.todo(p.id, todo.id).title}"
26
+ puts "Get Todo using project resource: #{client.todo(p, todo.id).title}"
27
+ puts "Get Todo using todolist resource: #{client.todo(list, todo.id).title}"
25
28
  end
26
29
  end
27
30
  end
@@ -7,6 +7,7 @@ require 'camper/version'
7
7
  require 'camper/logging'
8
8
  require 'camper/error'
9
9
  require 'camper/configuration'
10
+ require 'camper/url_utils'
10
11
  require 'camper/authorization'
11
12
  require 'camper/resource'
12
13
  require 'camper/pagination_data'
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Camper::Client
4
- module CommentAPI
5
- def add_comment(resource, content)
6
- post(resource.comments_url, override_path: true, body: { content: content }.to_json)
4
+ module CommentsAPI
5
+ def create_comment(resource, content)
6
+ raise Error::ResourceCannotBeCommented, resource unless resource.can_be_commented?
7
+
8
+ post(resource.comments_url, override_path: true, body: { content: content })
7
9
  end
8
10
 
9
11
  def comments(resource)