camp3 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,102 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ camp3 (0.1.0)
5
+ httparty (~> 0.18)
6
+ rack-oauth2 (~> 1.14)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (6.0.3.2)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2, >= 2.2.2)
17
+ aes_key_wrap (1.0.1)
18
+ ast (2.4.1)
19
+ attr_required (1.0.1)
20
+ bindata (2.4.7)
21
+ coderay (1.1.3)
22
+ concurrent-ruby (1.1.6)
23
+ diff-lcs (1.3)
24
+ httparty (0.18.1)
25
+ mime-types (~> 3.0)
26
+ multi_xml (>= 0.5.2)
27
+ httpclient (2.8.3)
28
+ i18n (1.8.3)
29
+ concurrent-ruby (~> 1.0)
30
+ json-jwt (1.13.0)
31
+ activesupport (>= 4.2)
32
+ aes_key_wrap
33
+ bindata
34
+ method_source (1.0.0)
35
+ mime-types (3.3.1)
36
+ mime-types-data (~> 3.2015)
37
+ mime-types-data (3.2020.0512)
38
+ minitest (5.14.1)
39
+ multi_xml (0.6.0)
40
+ parallel (1.19.2)
41
+ parser (2.7.1.4)
42
+ ast (~> 2.4.1)
43
+ pry (0.13.1)
44
+ coderay (~> 1.1)
45
+ method_source (~> 1.0)
46
+ rack (2.2.3)
47
+ rack-oauth2 (1.14.0)
48
+ activesupport
49
+ attr_required
50
+ httpclient
51
+ json-jwt (>= 1.11.0)
52
+ rack (>= 2.1.0)
53
+ rainbow (3.0.0)
54
+ rake (13.0.1)
55
+ regexp_parser (1.7.1)
56
+ rexml (3.2.4)
57
+ rspec (3.9.0)
58
+ rspec-core (~> 3.9.0)
59
+ rspec-expectations (~> 3.9.0)
60
+ rspec-mocks (~> 3.9.0)
61
+ rspec-core (3.9.2)
62
+ rspec-support (~> 3.9.3)
63
+ rspec-expectations (3.9.2)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.9.0)
66
+ rspec-mocks (3.9.1)
67
+ diff-lcs (>= 1.2.0, < 2.0)
68
+ rspec-support (~> 3.9.0)
69
+ rspec-support (3.9.3)
70
+ rubocop (0.86.0)
71
+ parallel (~> 1.10)
72
+ parser (>= 2.7.0.1)
73
+ rainbow (>= 2.2.2, < 4.0)
74
+ regexp_parser (>= 1.7)
75
+ rexml
76
+ rubocop-ast (>= 0.0.3, < 1.0)
77
+ ruby-progressbar (~> 1.7)
78
+ unicode-display_width (>= 1.4.0, < 2.0)
79
+ rubocop-ast (0.1.0)
80
+ parser (>= 2.7.0.1)
81
+ rubocop-performance (1.6.1)
82
+ rubocop (>= 0.71.0)
83
+ ruby-progressbar (1.10.1)
84
+ thread_safe (0.3.6)
85
+ tzinfo (1.2.7)
86
+ thread_safe (~> 0.1)
87
+ unicode-display_width (1.7.0)
88
+ zeitwerk (2.3.0)
89
+
90
+ PLATFORMS
91
+ ruby
92
+
93
+ DEPENDENCIES
94
+ camp3!
95
+ pry
96
+ rake (~> 13.0)
97
+ rspec (~> 3.9)
98
+ rubocop
99
+ rubocop-performance
100
+
101
+ BUNDLED WITH
102
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Rene Hernandez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # camp3 ![CI](https://github.com/renehernandez/camp3/workflows/CI/badge.svg)
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/camp3`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'camp3'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install camp3
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/camp3.
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ require 'rubocop/rake_task'
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.options = ['-D', '--parallel']
11
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "camp3"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,33 @@
1
+ require_relative 'lib/camp3/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "camp3"
5
+ spec.version = Camp3::VERSION
6
+ spec.authors = ["renehernandez"]
7
+ spec.email = ["renehr9102@gmail.com"]
8
+
9
+ spec.summary = "Ruby client for Basecamp 3 API"
10
+ spec.homepage = "https://github.com/renehernandez/camp3"
11
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
12
+ spec.license = 'MIT'
13
+
14
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency 'httparty', '~> 0.18'
29
+ spec.add_dependency 'rack-oauth2', '~> 1.14'
30
+
31
+ spec.add_development_dependency "rake", "~> 13.0"
32
+ spec.add_development_dependency "rspec", "~> 3.9"
33
+ end
@@ -0,0 +1,24 @@
1
+ require 'camp3'
2
+
3
+ Camp3.configure do |config|
4
+ config.client_id = ENV['BASECAMP3_CLIENT_ID']
5
+ config.client_secret = ENV['BASECAMP3_CLIENT_SECRET']
6
+ config.account_number = ENV['BASECAMP3_ACCOUNT_NUMBER']
7
+ config.refresh_token = ENV['BASECAMP3_REFRESH_TOKEN']
8
+ config.access_token = ENV['BASECAMP3_ACCESS_TOKEN']
9
+ end
10
+
11
+ projects = Camp3.projects
12
+
13
+ projects.each do |p|
14
+ puts "Project: #{p.name}"
15
+
16
+ message_board = Camp3.message_board(p)
17
+ puts "Message Board: #{message_board.title}"
18
+
19
+ messages = Camp3.messages(message_board)
20
+
21
+ messages.each do |msg|
22
+ puts msg.inspect
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ require 'camp3'
2
+
3
+ Camp3.configure do |config|
4
+ config.client_id = ENV['BASECAMP3_CLIENT_ID']
5
+ config.client_secret = ENV['BASECAMP3_CLIENT_SECRET']
6
+ config.redirect_uri = ENV['BASECAMP3_REDIRECT_URI']
7
+ end
8
+
9
+ # Get the authorization uri
10
+ puts Camp3.authorization_uri
11
+
12
+ # Once you have received the auth code from basecamp, you can proceed with the following step
13
+ # This will update the configuration with the corresponding tokens
14
+ # Store the tokens in a safe place
15
+ token = Camp3.authorize! ENV['BASECAMP3_ACCESS_CODE']
16
+
17
+ # Print refresh token
18
+ puts token.refresh_token
19
+
20
+ # Print access token
21
+ puts token.access_token
22
+
@@ -0,0 +1,13 @@
1
+ require 'camp3'
2
+
3
+ Camp3.configure do |config|
4
+ config.client_id = ENV['BASECAMP3_CLIENT_ID']
5
+ config.client_secret = ENV['BASECAMP3_CLIENT_SECRET']
6
+ config.account_number = ENV['BASECAMP3_ACCOUNT_NUMBER']
7
+ config.refresh_token = ENV['BASECAMP3_REFRESH_TOKEN']
8
+ end
9
+
10
+ tokens = Camp3.update_access_token!
11
+
12
+ # Prints the new access token
13
+ puts tokens.access_token
@@ -0,0 +1,27 @@
1
+ require 'camp3'
2
+
3
+ Camp3.configure do |config|
4
+ config.client_id = ENV['BASECAMP3_CLIENT_ID']
5
+ config.client_secret = ENV['BASECAMP3_CLIENT_SECRET']
6
+ config.account_number = ENV['BASECAMP3_ACCOUNT_NUMBER']
7
+ config.refresh_token = ENV['BASECAMP3_REFRESH_TOKEN']
8
+ config.access_token = ENV['BASECAMP3_ACCESS_TOKEN']
9
+ end
10
+
11
+ projects = Camp3.projects
12
+
13
+ projects.each do |p|
14
+ puts "Project: #{p.inspect}"
15
+
16
+ puts "Todo set: #{p.todoset.inspect}"
17
+
18
+ todoset = Camp3.todoset(p)
19
+
20
+ Camp3.todolists(todoset).each do |list|
21
+ puts "Todolist: #{list.title}"
22
+
23
+ Camp3.todos(list).each do |todo|
24
+ puts todo.inspect
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rack/oauth2'
4
+
5
+ require "camp3/version"
6
+ require "camp3/logging"
7
+ require "camp3/error"
8
+ require "camp3/configuration"
9
+ require "camp3/authorization"
10
+ require "camp3/objectified_hash"
11
+ require "camp3/resource"
12
+ require "camp3/paginated_response"
13
+ require "camp3/page_links"
14
+ require "camp3/request"
15
+ require "camp3/client"
16
+
17
+ module Camp3
18
+ extend Logging
19
+ extend Configuration
20
+
21
+ # def self.authorize!(auth_code)
22
+ # tokens = client.authorize!(auth_code)
23
+
24
+ # Resource.configure(Camp3.access_token)
25
+
26
+ # tokens
27
+ # end
28
+
29
+ # def self.update_access_token!(refresh_token = nil)
30
+ # refresh_token = Camp3.refresh_token unless refresh_token
31
+
32
+ # tokens = client.update_access_token!(refresh_token)
33
+
34
+ # Resource.configure(Camp3.access_token)
35
+
36
+ # tokens
37
+ # end
38
+
39
+ # def self.configure
40
+ # yield self
41
+
42
+ # Resource.configure(Camp3.access_token) if Camp3.access_token
43
+ # end
44
+
45
+ # Alias for Camp3::Client.new
46
+ #
47
+ # @return [Camp3::Client]
48
+ def self.client(options = {})
49
+ Camp3::Client.new(options)
50
+ end
51
+
52
+ # Delegate to Camp3::Client
53
+ def self.method_missing(method, *args, &block)
54
+ return super unless client.respond_to?(method)
55
+
56
+ client.send(method, *args, &block)
57
+ end
58
+
59
+ # Delegate to Camp3::Client
60
+ def self.respond_to_missing?(method_name, include_private = false)
61
+ client.respond_to?(method_name) || super
62
+ end
63
+
64
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Camp3::Client
4
+ module MessageAPI
5
+ def messages(message_board)
6
+ get(message_board.messages_url, override_path: true)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Camp3::Client
4
+ module ProjectAPI
5
+
6
+ def projects(options = {})
7
+ get("/projects", options)
8
+ end
9
+
10
+ def message_board(project)
11
+ board = project.message_board
12
+ get(board.url, override_path: true)
13
+ end
14
+
15
+ def todoset(project)
16
+ todoset = project.todoset
17
+ get(todoset.url, override_path: true)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Camp3::Client
4
+ module ResourceAPI
5
+
6
+ def resource(url)
7
+ get(url, override_path: true)
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Camp3::Client
4
+ module TodoAPI
5
+
6
+ def todolists(todoset)
7
+ get(todoset.todolists_url, override_path: true)
8
+ end
9
+
10
+ def todos(todolist, options={})
11
+ get(todolist.todos_url, options.merge(override_path: true))
12
+ end
13
+ end
14
+ end