basecamp3 0.1.3

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.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +2 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +65 -0
  8. data/Rakefile +6 -0
  9. data/basecamp3.gemspec +38 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/docs/Basecamp3.html +367 -0
  13. data/docs/Basecamp3/Campfire.html +901 -0
  14. data/docs/Basecamp3/CampfireLine.html +1025 -0
  15. data/docs/Basecamp3/Comment.html +1284 -0
  16. data/docs/Basecamp3/Concerns.html +117 -0
  17. data/docs/Basecamp3/Concerns/Bucketable.html +211 -0
  18. data/docs/Basecamp3/Concerns/Commentable.html +285 -0
  19. data/docs/Basecamp3/Concerns/Creatorable.html +209 -0
  20. data/docs/Basecamp3/Concerns/Parentable.html +211 -0
  21. data/docs/Basecamp3/Concerns/Recordingable.html +189 -0
  22. data/docs/Basecamp3/Concerns/Recordingable/ClassMethods.html +236 -0
  23. data/docs/Basecamp3/Document.html +1262 -0
  24. data/docs/Basecamp3/Forward.html +1070 -0
  25. data/docs/Basecamp3/Inbox.html +840 -0
  26. data/docs/Basecamp3/Message.html +1262 -0
  27. data/docs/Basecamp3/MessageBoard.html +840 -0
  28. data/docs/Basecamp3/MessageType.html +1160 -0
  29. data/docs/Basecamp3/Model.html +236 -0
  30. data/docs/Basecamp3/Person.html +1288 -0
  31. data/docs/Basecamp3/Project.html +1280 -0
  32. data/docs/Basecamp3/Question.html +1050 -0
  33. data/docs/Basecamp3/QuestionAnswer.html +887 -0
  34. data/docs/Basecamp3/Questionnaire.html +840 -0
  35. data/docs/Basecamp3/Request.html +933 -0
  36. data/docs/Basecamp3/ResponseParser.html +303 -0
  37. data/docs/Basecamp3/Schedule.html +840 -0
  38. data/docs/Basecamp3/ScheduleEntry.html +1560 -0
  39. data/docs/Basecamp3/Todo.html +1726 -0
  40. data/docs/Basecamp3/TodoList.html +1480 -0
  41. data/docs/Basecamp3/TodoSet.html +980 -0
  42. data/docs/Basecamp3/TypeMapper.html +329 -0
  43. data/docs/Basecamp3/Vault.html +1514 -0
  44. data/docs/_index.html +415 -0
  45. data/docs/class_list.html +51 -0
  46. data/docs/css/common.css +1 -0
  47. data/docs/css/full_list.css +58 -0
  48. data/docs/css/style.css +492 -0
  49. data/docs/file.README.html +157 -0
  50. data/docs/file_list.html +56 -0
  51. data/docs/frames.html +17 -0
  52. data/docs/index.html +157 -0
  53. data/docs/js/app.js +248 -0
  54. data/docs/js/full_list.js +216 -0
  55. data/docs/js/jquery.js +4 -0
  56. data/docs/method_list.html +1875 -0
  57. data/docs/top-level-namespace.html +110 -0
  58. data/lib/basecamp3.rb +61 -0
  59. data/lib/basecamp3/concerns/bucketable.rb +17 -0
  60. data/lib/basecamp3/concerns/commentable.rb +15 -0
  61. data/lib/basecamp3/concerns/creatorable.rb +16 -0
  62. data/lib/basecamp3/concerns/parentable.rb +17 -0
  63. data/lib/basecamp3/concerns/recordingable.rb +22 -0
  64. data/lib/basecamp3/model.rb +23 -0
  65. data/lib/basecamp3/models/campfire.rb +42 -0
  66. data/lib/basecamp3/models/campfire_line.rb +52 -0
  67. data/lib/basecamp3/models/comment.rb +65 -0
  68. data/lib/basecamp3/models/document.rb +71 -0
  69. data/lib/basecamp3/models/forward.rb +40 -0
  70. data/lib/basecamp3/models/inbox.rb +31 -0
  71. data/lib/basecamp3/models/message.rb +73 -0
  72. data/lib/basecamp3/models/message_board.rb +31 -0
  73. data/lib/basecamp3/models/message_type.rb +68 -0
  74. data/lib/basecamp3/models/person.rb +46 -0
  75. data/lib/basecamp3/models/project.rb +70 -0
  76. data/lib/basecamp3/models/question.rb +43 -0
  77. data/lib/basecamp3/models/question_answer.rb +35 -0
  78. data/lib/basecamp3/models/questionnaire.rb +31 -0
  79. data/lib/basecamp3/models/schedule.rb +31 -0
  80. data/lib/basecamp3/models/schedule_entry.rb +93 -0
  81. data/lib/basecamp3/models/todo.rb +108 -0
  82. data/lib/basecamp3/models/todo_list.rb +77 -0
  83. data/lib/basecamp3/models/todo_set.rb +33 -0
  84. data/lib/basecamp3/models/vault.rb +79 -0
  85. data/lib/basecamp3/request.rb +163 -0
  86. data/lib/basecamp3/response_parser.rb +44 -0
  87. data/lib/basecamp3/type_mapper.rb +53 -0
  88. data/lib/basecamp3/version.rb +3 -0
  89. metadata +202 -0
@@ -0,0 +1,110 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+
41
+
42
+ <span class="title">Top Level Namespace</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Top Level Namespace
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <h2>Defined Under Namespace</h2>
82
+ <p class="children">
83
+
84
+
85
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Basecamp3.html" title="Basecamp3 (module)">Basecamp3</a></span>
86
+
87
+
88
+
89
+
90
+ </p>
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ </div>
101
+
102
+ <div id="footer">
103
+ Generated on Tue May 9 15:32:16 2017 by
104
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
+ 0.9.9 (ruby-2.2.2).
106
+ </div>
107
+
108
+ </div>
109
+ </body>
110
+ </html>
@@ -0,0 +1,61 @@
1
+ require 'net/https'
2
+ require 'json'
3
+
4
+ require 'basecamp3/version'
5
+ require 'basecamp3/request'
6
+ require 'basecamp3/response_parser'
7
+ require 'basecamp3/type_mapper'
8
+ require 'basecamp3/model'
9
+
10
+ require 'basecamp3/concerns/creatorable'
11
+ require 'basecamp3/concerns/bucketable'
12
+ require 'basecamp3/concerns/parentable'
13
+ require 'basecamp3/concerns/recordingable'
14
+ require 'basecamp3/concerns/commentable'
15
+
16
+ require 'basecamp3/models/project'
17
+ require 'basecamp3/models/person'
18
+ require 'basecamp3/models/todo_set'
19
+ require 'basecamp3/models/todo_list'
20
+ require 'basecamp3/models/todo'
21
+ require 'basecamp3/models/comment'
22
+ require 'basecamp3/models/vault'
23
+ require 'basecamp3/models/campfire'
24
+ require 'basecamp3/models/campfire_line'
25
+ require 'basecamp3/models/message_board'
26
+ require 'basecamp3/models/message'
27
+ require 'basecamp3/models/message_type'
28
+ require 'basecamp3/models/document'
29
+ require 'basecamp3/models/schedule'
30
+ require 'basecamp3/models/schedule_entry'
31
+ require 'basecamp3/models/question'
32
+ require 'basecamp3/models/question_answer'
33
+ require 'basecamp3/models/questionnaire'
34
+ require 'basecamp3/models/inbox'
35
+ require 'basecamp3/models/forward'
36
+
37
+ module Basecamp3
38
+ class << self
39
+ HOST = 'https://3.basecampapi.com'
40
+
41
+ # Establishes a connection with basecamp
42
+ #
43
+ # @param [Integer] account_id the id of your basecamp account
44
+ # @param [Integer] access_token the oauth2 access token
45
+ def connect(account_id, access_token)
46
+ @account_id = account_id
47
+ @access_token = access_token
48
+ @uri = URI.parse("#{HOST}/#{@account_id}")
49
+
50
+ @request = Basecamp3::Request.new(@access_token, @uri)
51
+ end
52
+
53
+ # Returns the request object
54
+ #
55
+ # @return [Basecamp3::Request]
56
+ # @raise [StandardError] raises an error if a connection is not established
57
+ def request
58
+ @request || raise('You have to call Basecamp.connect method first')
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,17 @@
1
+ # A concern for bucketable models
2
+ module Basecamp3
3
+ module Concerns
4
+ module Bucketable
5
+
6
+ # Returns the related bucket.
7
+ #
8
+ # @return [Basecamp3::Model]
9
+ def bucket
10
+ return nil if @bucket.nil?
11
+
12
+ klass = TypeMapper.map(@bucket['type'])
13
+ @mapped_bucket ||= klass.new(@bucket)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # A concern for commentable models
2
+ module Basecamp3
3
+ module Concerns
4
+ module Commentable
5
+ attr_accessor :comments_count
6
+
7
+ # Returns the related comments.
8
+ #
9
+ # @return [Array<Basecamp3::Comment>]
10
+ def comments
11
+ @mapped_comments ||= Basecamp3::Comment.all(bucket.id, id)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ # A concern for creatorable models
2
+ module Basecamp3
3
+ module Concerns
4
+ module Creatorable
5
+
6
+ # Returns the creator.
7
+ #
8
+ # @return [Basecamp3::Person]
9
+ def creator
10
+ return nil if @creator.nil?
11
+
12
+ @mapped_creator ||= Basecamp3::Person.new(@creator)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ # A concern for parentable models
2
+ module Basecamp3
3
+ module Concerns
4
+ module Parentable
5
+
6
+ # Returns the parent.
7
+ #
8
+ # @return [Basecamp3::Model]
9
+ def parent
10
+ return nil if @parent.nil?
11
+
12
+ klass = TypeMapper.map(@parent['type'])
13
+ @mapped_parent ||= klass.new(@bucket)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ # A concern for recordingable models
2
+ module Basecamp3
3
+ module Concerns
4
+ module Recordingable
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+
9
+ module ClassMethods
10
+ # Deletes the record.
11
+ #
12
+ # @param [Integer] bucket_id the id of the bucket
13
+ # @param [Integer] id the id of the record
14
+ #
15
+ # @return [Boolean]
16
+ def delete(bucket_id, id)
17
+ Basecamp3.request.put("/buckets/#{bucket_id}/recordings/#{id}/status/trashed")
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ # A base class for models
2
+ #
3
+ # @abstract
4
+ class Basecamp3::Model
5
+ REQUIRED_FIELDS = []
6
+
7
+ def initialize(data = {})
8
+ data.each do |attr, value|
9
+ instance_variable_set("@#{attr}", value)
10
+ end
11
+ end
12
+
13
+ protected
14
+
15
+ # Validates if the given data contain the required attributes.
16
+ #
17
+ # @param [Hash] data the data to send in the request
18
+ #
19
+ # @raise [StandardError] raises an error if required parameter is missing
20
+ def self.validate_required(data)
21
+ self::REQUIRED_FIELDS.each { |f| raise "Missing required parameter #{f}" if data[f.to_sym].nil? }
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ # A model for Basecamp's Campfire
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/campfires.md#campfires For more information, see the official Basecamp3 API documentation for Campfires}
4
+ class Basecamp3::Campfire < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+
8
+ attr_accessor :id,
9
+ :status,
10
+ :created_at,
11
+ :updated_at,
12
+ :topic
13
+
14
+ REQUIRED_FIELDS = %w(topic)
15
+
16
+ # Returns a list of related lines.
17
+ #
18
+ # @return [Array<Basecamp3::CampfireLine>]
19
+ def lines
20
+ @mapped_lines ||= Basecamp3::CampfireLine.all(bucket.id, id)
21
+ end
22
+
23
+ # Returns a paginated list of all active campfires visible to the current user.
24
+ #
25
+ # @param [Hash] params additional parameters
26
+ # @option params [Integer] :page (optional) to paginate results
27
+ #
28
+ # @return [Array<Basecamp3::Campfire>]
29
+ def self.all(params = {})
30
+ Basecamp3.request.get("/chats", params, Basecamp3::Campfire)
31
+ end
32
+
33
+ # Returns the campfire.
34
+ #
35
+ # @param [Integer] bucket_id the id of the bucket
36
+ # @param [Integer] id the id of the campfire
37
+ #
38
+ # @return [Basecamp3::Campfire]
39
+ def self.find(bucket_id, id)
40
+ Basecamp3.request.get("/buckets/#{bucket_id}/chats/#{id}", {}, Basecamp3::Campfire)
41
+ end
42
+ end
@@ -0,0 +1,52 @@
1
+ # A model for Basecamp's CampfireLine
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/campfires.md#campfires For more information, see the official Basecamp3 API documentation for Campfires}
4
+ class Basecamp3::CampfireLine < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+ include Basecamp3::Concerns::Parentable
8
+
9
+ attr_accessor :id,
10
+ :status,
11
+ :created_at,
12
+ :updated_at,
13
+ :content
14
+
15
+ REQUIRED_FIELDS = %w(content)
16
+
17
+ # Returns a paginated list of campfire lines.
18
+ #
19
+ # @param [Integer] bucket_id the id of the bucket
20
+ # @param [Integer] parent_id the id of the campfire
21
+ # @param [Hash] params additional parameters
22
+ # @option params [Integer] :page (optional) to paginate results
23
+ #
24
+ # @return [Array<Basecamp3::CampfireLine>]
25
+ def self.all(bucket_id, parent_id, params = {})
26
+ Basecamp3.request.get("/buckets/#{bucket_id}/chats/#{parent_id}/lines", params, Basecamp3::CampfireLine)
27
+ end
28
+
29
+ # Returns the campfire line.
30
+ #
31
+ # @param [Integer] bucket_id the id of the bucket
32
+ # @param [Integer] parent_id the id of the campfire
33
+ # @param [Integer] id the id of the campfire line
34
+ #
35
+ # @return [Basecamp3::CampfireLine]
36
+ def self.find(bucket_id, parent_id, id)
37
+ Basecamp3.request.get("/buckets/#{bucket_id}/chats/#{parent_id}/lines/#{id}", {}, Basecamp3::CampfireLine)
38
+ end
39
+
40
+ # Creates a campfire line.
41
+ #
42
+ # @param [Integer] bucket_id the id of the bucket
43
+ # @param [Integer] parent_id the id of the campfire
44
+ # @param [Hash] data the data to create a campfire line with
45
+ # @option params [Integer] :content (required) the body of the campfire line
46
+ #
47
+ # @return [Basecamp3::CampfireLine]
48
+ def self.create(bucket_id, parent_id, data)
49
+ self.validate_required(data)
50
+ Basecamp3.request.post("/buckets/#{bucket_id}/chats/#{parent_id}/lines", data, Basecamp3::CampfireLine)
51
+ end
52
+ end
@@ -0,0 +1,65 @@
1
+ # A model for Basecamp's Comment
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/comments.md#comments For more information, see the official Basecamp3 API documentation for Comments}
4
+ class Basecamp3::Comment < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+ include Basecamp3::Concerns::Parentable
8
+ include Basecamp3::Concerns::Recordingable
9
+
10
+ attr_accessor :id,
11
+ :status,
12
+ :created_at,
13
+ :updated_at,
14
+ :content,
15
+ :parent_id,
16
+ :bucket_id
17
+
18
+ REQUIRED_FIELDS = %w(content)
19
+
20
+ # Returns a paginated list of active comments.
21
+ #
22
+ # @param [Hash] params additional parameters
23
+ # @option params [Integer] :page (optional) to paginate results
24
+ #
25
+ # @return [Array<Basecamp3::Comment>]
26
+ def self.all(bucket_id, parent_id, params = {})
27
+ Basecamp3.request.get("/buckets/#{bucket_id}/recordings/#{parent_id}/comments", params, Basecamp3::Comment)
28
+ end
29
+
30
+ # Returns the comment.
31
+ #
32
+ # @param [Integer] bucket_id the id of the bucket
33
+ # @param [Integer] id the id of the comment
34
+ #
35
+ # @return [Basecamp3::Comment]
36
+ def self.find(bucket_id, id)
37
+ Basecamp3.request.get("/buckets/#{bucket_id}/comments/#{id}", {}, Basecamp3::Comment)
38
+ end
39
+
40
+ # Creates a comment.
41
+ #
42
+ # @param [Integer] bucket_id the id of the bucket
43
+ # @param [Integer] parent_id the id of the parent
44
+ # @param [Hash] data the data to create a comment with
45
+ # @option params [String] :content (required) the body of the comment
46
+ #
47
+ # @return [Basecamp3::Comment]
48
+ def self.create(bucket_id, parent_id, data)
49
+ self.validate_required(data)
50
+ Basecamp3.request.post("/buckets/#{bucket_id}/recordings/#{parent_id}/comments", data, Basecamp3::Comment)
51
+ end
52
+
53
+ # Updates the comment.
54
+ #
55
+ # @param [Integer] bucket_id the id of the bucket
56
+ # @param [Integer] id the id of the comment
57
+ # @param [Hash] data the data to update the comment with
58
+ # @option params [String] :content (required) the body of the comment
59
+ #
60
+ # @return [Basecamp3::Comment]
61
+ def self.update(bucket_id, id, data)
62
+ self.validate_required(data)
63
+ Basecamp3.request.put("/buckets/#{bucket_id}/comments/#{id}", data, Basecamp3::Comment)
64
+ end
65
+ end