basecampeverest 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/basecampeverest/connect.rb +116 -0
- data/lib/basecampeverest/convert.rb +27 -0
- data/lib/basecampeverest/recursive.rb +24 -0
- data/lib/basecampeverest/resources/access.rb +62 -0
- data/lib/basecampeverest/resources/attachment.rb +83 -0
- data/lib/basecampeverest/resources/calendar.rb +84 -0
- data/lib/basecampeverest/resources/calendar_event.rb +87 -0
- data/lib/basecampeverest/resources/comment.rb +87 -0
- data/lib/basecampeverest/resources/document.rb +87 -0
- data/lib/basecampeverest/resources/event.rb +87 -0
- data/lib/basecampeverest/resources/message.rb +87 -0
- data/lib/basecampeverest/resources/people.rb +87 -0
- data/lib/basecampeverest/resources/project.rb +136 -0
- data/lib/basecampeverest/resources/todo_item.rb +81 -0
- data/lib/basecampeverest/resources/todo_list.rb +134 -0
- data/lib/basecampeverest/resources/topics.rb +83 -0
- data/lib/basecampeverest/resources/upload.rb +87 -0
- data/lib/basecampeverest.rb +22 -0
- metadata +159 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
module Basecampeverest; class Event
|
2
|
+
|
3
|
+
# find all #### via the Basecamp API
|
4
|
+
#
|
5
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
6
|
+
def self.all
|
7
|
+
url =
|
8
|
+
response = Basecampeverest::Connect.get
|
9
|
+
|
10
|
+
# parse the response to remove HTTParty info
|
11
|
+
response.parsed_response
|
12
|
+
end
|
13
|
+
|
14
|
+
# #### via the Basecamp API
|
15
|
+
#
|
16
|
+
# @param [Basecampeverest::Project] ####
|
17
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
18
|
+
def self.find()
|
19
|
+
url =
|
20
|
+
response = Basecampeverest::Connect.get
|
21
|
+
|
22
|
+
# parse the response to remove HTTParty info
|
23
|
+
response.parsed_response
|
24
|
+
end
|
25
|
+
|
26
|
+
# #### via the Basecamp API
|
27
|
+
#
|
28
|
+
#
|
29
|
+
# @param [Basecampeverest::Project] ####
|
30
|
+
# @param [Basecampeverest::Project] ####
|
31
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
32
|
+
def self.new(options={})
|
33
|
+
post_params = {
|
34
|
+
:body => options.to_json,
|
35
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
36
|
+
}
|
37
|
+
# make the http basecamp call
|
38
|
+
url = "####"
|
39
|
+
response = Basecampeverest::Connect.post url, post_params
|
40
|
+
|
41
|
+
# parse the response to remove HTTParty info
|
42
|
+
response.parsed_response
|
43
|
+
end
|
44
|
+
|
45
|
+
# #### via the Basecamp API
|
46
|
+
#
|
47
|
+
# @param [Basecampeverest::Project] ####
|
48
|
+
# @param [Basecampeverest::Project] ####
|
49
|
+
# @return [Basecampeverest::Project] from the Basecamp API
|
50
|
+
def self.update()
|
51
|
+
post_params = {
|
52
|
+
:body => options.to_json,
|
53
|
+
:headers => Basecampeverest::Connect.merge({'Content-Type' => 'application/json'})
|
54
|
+
}
|
55
|
+
|
56
|
+
# make the http basecamp call
|
57
|
+
url =
|
58
|
+
response = Basecampeverest::Connect.put url, post_params
|
59
|
+
|
60
|
+
# parse the response to remove HTTParty info
|
61
|
+
response.parsed_response
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# #### via the Basecamp API
|
66
|
+
#
|
67
|
+
# @param [Basecampeverest::Project] ####
|
68
|
+
# @return [Basecampeverest::Project] ####
|
69
|
+
def self.delete()
|
70
|
+
url = "####"
|
71
|
+
response = Basecampeverest::Connect.delete url
|
72
|
+
|
73
|
+
# This checks the response code for validity and error checking
|
74
|
+
if response.code == 204
|
75
|
+
message = "#### successfully deleted"
|
76
|
+
elsif response.code == 403
|
77
|
+
message = "You do not have permission to delete this ####"
|
78
|
+
else
|
79
|
+
message = "Invalid project ID or authentication. The #### was not deleted."
|
80
|
+
end
|
81
|
+
|
82
|
+
# return the message
|
83
|
+
message
|
84
|
+
end
|
85
|
+
|
86
|
+
# end module and class
|
87
|
+
end; end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Basecampeverest; class Message
|
2
|
+
|
3
|
+
# find all #### via the Basecamp API
|
4
|
+
#
|
5
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
6
|
+
def self.all
|
7
|
+
url =
|
8
|
+
response = Basecampeverest::Connect.get
|
9
|
+
|
10
|
+
# parse the response to remove HTTParty info
|
11
|
+
response.parsed_response
|
12
|
+
end
|
13
|
+
|
14
|
+
# #### via the Basecamp API
|
15
|
+
#
|
16
|
+
# @param [Basecampeverest::Project] ####
|
17
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
18
|
+
def self.find()
|
19
|
+
url =
|
20
|
+
response = Basecampeverest::Connect.get
|
21
|
+
|
22
|
+
# parse the response to remove HTTParty info
|
23
|
+
response.parsed_response
|
24
|
+
end
|
25
|
+
|
26
|
+
# #### via the Basecamp API
|
27
|
+
#
|
28
|
+
#
|
29
|
+
# @param [Basecampeverest::Project] ####
|
30
|
+
# @param [Basecampeverest::Project] ####
|
31
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
32
|
+
def self.new(options={})
|
33
|
+
post_params = {
|
34
|
+
:body => options.to_json,
|
35
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
36
|
+
}
|
37
|
+
# make the http basecamp call
|
38
|
+
url = "####"
|
39
|
+
response = Basecampeverest::Connect.post url, post_params
|
40
|
+
|
41
|
+
# parse the response to remove HTTParty info
|
42
|
+
response.parsed_response
|
43
|
+
end
|
44
|
+
|
45
|
+
# #### via the Basecamp API
|
46
|
+
#
|
47
|
+
# @param [Basecampeverest::Project] ####
|
48
|
+
# @param [Basecampeverest::Project] ####
|
49
|
+
# @return [Basecampeverest::Project] from the Basecamp API
|
50
|
+
def self.update()
|
51
|
+
post_params = {
|
52
|
+
:body => options.to_json,
|
53
|
+
:headers => Basecampeverest::Connect.merge({'Content-Type' => 'application/json'})
|
54
|
+
}
|
55
|
+
|
56
|
+
# make the http basecamp call
|
57
|
+
url =
|
58
|
+
response = Basecampeverest::Connect.put url, post_params
|
59
|
+
|
60
|
+
# parse the response to remove HTTParty info
|
61
|
+
response.parsed_response
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# #### via the Basecamp API
|
66
|
+
#
|
67
|
+
# @param [Basecampeverest::Project] ####
|
68
|
+
# @return [Basecampeverest::Project] ####
|
69
|
+
def self.delete()
|
70
|
+
url = "####"
|
71
|
+
response = Basecampeverest::Connect.delete url
|
72
|
+
|
73
|
+
# This checks the response code for validity and error checking
|
74
|
+
if response.code == 204
|
75
|
+
message = "#### successfully deleted"
|
76
|
+
elsif response.code == 403
|
77
|
+
message = "You do not have permission to delete this ####"
|
78
|
+
else
|
79
|
+
message = "Invalid project ID or authentication. The #### was not deleted."
|
80
|
+
end
|
81
|
+
|
82
|
+
# return the message
|
83
|
+
message
|
84
|
+
end
|
85
|
+
|
86
|
+
# end module and class
|
87
|
+
end; end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Basecampeverest; class People
|
2
|
+
|
3
|
+
# find all #### via the Basecamp API
|
4
|
+
#
|
5
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
6
|
+
def self.all
|
7
|
+
url =
|
8
|
+
response = Basecampeverest::Connect.get
|
9
|
+
|
10
|
+
# parse the response to remove HTTParty info
|
11
|
+
response.parsed_response
|
12
|
+
end
|
13
|
+
|
14
|
+
# #### via the Basecamp API
|
15
|
+
#
|
16
|
+
# @param [Basecampeverest::Project] ####
|
17
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
18
|
+
def self.find()
|
19
|
+
url =
|
20
|
+
response = Basecampeverest::Connect.get
|
21
|
+
|
22
|
+
# parse the response to remove HTTParty info
|
23
|
+
response.parsed_response
|
24
|
+
end
|
25
|
+
|
26
|
+
# #### via the Basecamp API
|
27
|
+
#
|
28
|
+
#
|
29
|
+
# @param [Basecampeverest::Project] ####
|
30
|
+
# @param [Basecampeverest::Project] ####
|
31
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
32
|
+
def self.new(options={})
|
33
|
+
post_params = {
|
34
|
+
:body => options.to_json,
|
35
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
36
|
+
}
|
37
|
+
# make the http basecamp call
|
38
|
+
url = "####"
|
39
|
+
response = Basecampeverest::Connect.post url, post_params
|
40
|
+
|
41
|
+
# parse the response to remove HTTParty info
|
42
|
+
response.parsed_response
|
43
|
+
end
|
44
|
+
|
45
|
+
# #### via the Basecamp API
|
46
|
+
#
|
47
|
+
# @param [Basecampeverest::Project] ####
|
48
|
+
# @param [Basecampeverest::Project] ####
|
49
|
+
# @return [Basecampeverest::Project] from the Basecamp API
|
50
|
+
def self.update()
|
51
|
+
post_params = {
|
52
|
+
:body => options.to_json,
|
53
|
+
:headers => Basecampeverest::Connect.merge({'Content-Type' => 'application/json'})
|
54
|
+
}
|
55
|
+
|
56
|
+
# make the http basecamp call
|
57
|
+
url =
|
58
|
+
response = Basecampeverest::Connect.put url, post_params
|
59
|
+
|
60
|
+
# parse the response to remove HTTParty info
|
61
|
+
response.parsed_response
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# #### via the Basecamp API
|
66
|
+
#
|
67
|
+
# @param [Basecampeverest::Project] ####
|
68
|
+
# @return [Basecampeverest::Project] ####
|
69
|
+
def self.delete()
|
70
|
+
url = "####"
|
71
|
+
response = Basecampeverest::Connect.delete url
|
72
|
+
|
73
|
+
# This checks the response code for validity and error checking
|
74
|
+
if response.code == 204
|
75
|
+
message = "#### successfully deleted"
|
76
|
+
elsif response.code == 403
|
77
|
+
message = "You do not have permission to delete this ####"
|
78
|
+
else
|
79
|
+
message = "Invalid project ID or authentication. The #### was not deleted."
|
80
|
+
end
|
81
|
+
|
82
|
+
# return the message
|
83
|
+
message
|
84
|
+
end
|
85
|
+
|
86
|
+
# end module and class
|
87
|
+
end; end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
module Basecampeverest; class Project
|
2
|
+
# find all projects via the Basecamp API
|
3
|
+
#
|
4
|
+
# @return [Basecampeverest::Project] all projects from the Basecamp API
|
5
|
+
def self.all
|
6
|
+
response = Basecampeverest::Connect.get "/projects.json"
|
7
|
+
|
8
|
+
# parse the response to remove HTTParty info
|
9
|
+
response.parsed_response
|
10
|
+
end
|
11
|
+
|
12
|
+
# find a project via the Basecamp API
|
13
|
+
#
|
14
|
+
# @param [Basecampeverest::Project] project_id the project id of the basecamp project
|
15
|
+
# @return [Basecampeverest::Project] the found project information from the Basecamp API
|
16
|
+
def self.find(project_id)
|
17
|
+
response = Basecampeverest::Connect.get "/projects/#{project_id}.json"
|
18
|
+
|
19
|
+
# parse the response to remove HTTParty info
|
20
|
+
response.parsed_response
|
21
|
+
end
|
22
|
+
|
23
|
+
# create a project via the Basecamp API
|
24
|
+
# the options hash must have the name and description element.
|
25
|
+
#
|
26
|
+
# @param [Basecampeverest::Project] options the name of the new basecamp project
|
27
|
+
# @param [Basecampeverest::Project] description the details of the new basecamp project
|
28
|
+
# @return [Basecampeverest::Project] the new project information from the Basecamp API
|
29
|
+
def self.new(options={})
|
30
|
+
# if options[:name].nil?
|
31
|
+
# return "You need a project name"
|
32
|
+
# else
|
33
|
+
|
34
|
+
# end
|
35
|
+
post_params = {
|
36
|
+
:body => options.to_json,
|
37
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
38
|
+
}
|
39
|
+
# make the http basecamp call
|
40
|
+
response = Basecampeverest::Connect.post "/projects.json", post_params
|
41
|
+
|
42
|
+
# parse the response to remove HTTParty info
|
43
|
+
response.parsed_response
|
44
|
+
end
|
45
|
+
|
46
|
+
# update a project via the Basecamp API
|
47
|
+
#
|
48
|
+
# @param [Basecampeverest::Project] project_id the project id of the basecamp project to change
|
49
|
+
# @param [Basecampeverest::Project] options the details of the new basecamp project
|
50
|
+
# @return [Basecampeverest::Project] the project information from the Basecamp API
|
51
|
+
def self.update(project_id, options={})
|
52
|
+
post_params = {
|
53
|
+
:body => options.to_json,
|
54
|
+
:headers => Basecampeverest::Connect.merge({'Content-Type' => 'application/json'})
|
55
|
+
}
|
56
|
+
|
57
|
+
# make the http basecamp call
|
58
|
+
response = Basecampeverest::Connect.put "/projects/#{project_id}.json", post_params
|
59
|
+
|
60
|
+
# parse the response to remove HTTParty info
|
61
|
+
response.parsed_response
|
62
|
+
end
|
63
|
+
|
64
|
+
# archive a project via the Basecamp API
|
65
|
+
#
|
66
|
+
# @param [Basecampeverest::Project] project_id the project id of the basecamp project to change
|
67
|
+
# @return [Basecampeverest::Project] the project information from the Basecamp API
|
68
|
+
def self.archive(project_id)
|
69
|
+
post_params = {
|
70
|
+
:body => {:archived => true}.to_json,
|
71
|
+
:headers => Basecampeverest::Connect.merge({'Content-Type' => 'application/json'})
|
72
|
+
}
|
73
|
+
|
74
|
+
url = "/projects/#{project_id}.json"
|
75
|
+
response = Basecampeverest::Connect.put url post_params
|
76
|
+
|
77
|
+
# This checks the response code for validity and error checking
|
78
|
+
if response.code == 200
|
79
|
+
message = "Project successfully archived"
|
80
|
+
elsif response.code == 403
|
81
|
+
message = "You do not have permission to archive this project"
|
82
|
+
else
|
83
|
+
message = "Invalid project ID or authentication. The project was not archived."
|
84
|
+
end
|
85
|
+
|
86
|
+
# return the message
|
87
|
+
message
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.activate(project_id)
|
91
|
+
post_params = {
|
92
|
+
:body => {:archived => false}.to_json,
|
93
|
+
:headers => Basecampeverest::Connect.merge({'Content-Type' => 'application/json'})
|
94
|
+
}
|
95
|
+
|
96
|
+
url = "/projects/#{project_id}.json"
|
97
|
+
response = Basecampeverest::Connect.put url post_params
|
98
|
+
|
99
|
+
# This checks the response code for validity and error checking
|
100
|
+
if response.code == 200
|
101
|
+
message = "Project successfully activated"
|
102
|
+
elsif response.code == 403
|
103
|
+
message = "You do not have permission to activate this project"
|
104
|
+
else
|
105
|
+
message = "Invalid project ID or authentication. The project was not activated."
|
106
|
+
end
|
107
|
+
|
108
|
+
# return the message
|
109
|
+
message
|
110
|
+
end
|
111
|
+
|
112
|
+
# delete a project via the Basecamp API
|
113
|
+
#
|
114
|
+
# @param [Basecampeverest::Project] project_id the project id of the basecamp project to change
|
115
|
+
# @return [Basecampeverest::Project] a message detailing successfull or unsuccessful deletion
|
116
|
+
def self.delete(project_id)
|
117
|
+
# for some reason ruby won't put in the project ID for a delete method. Solved by setting the url
|
118
|
+
# and then calling delete
|
119
|
+
url = "/projects/#{project_id}.json"
|
120
|
+
response = Basecampeverest::Connect.delete url
|
121
|
+
|
122
|
+
# This checks the response code for validity and error checking
|
123
|
+
if response.code == 204
|
124
|
+
message = "Project successfully deleted"
|
125
|
+
elsif response.code == 403
|
126
|
+
message = "You do not have permission to delete this project"
|
127
|
+
else
|
128
|
+
message = "Invalid project ID or authentication. The project was not deleted."
|
129
|
+
end
|
130
|
+
|
131
|
+
# return the message
|
132
|
+
message
|
133
|
+
end
|
134
|
+
|
135
|
+
# end module and class
|
136
|
+
end; end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Basecampeverest; class TodoItem
|
2
|
+
|
3
|
+
# To find all the todo items, use the TodoList class.
|
4
|
+
# Running Basecampeverest::TodoList.find(project_id, todo_list_id)
|
5
|
+
# will return all todo items for a project.
|
6
|
+
|
7
|
+
# find a specific todo via the Basecamp API
|
8
|
+
#
|
9
|
+
# @param [Basecampeverest::TodoItem] project_id
|
10
|
+
# @param [Basecampeverest::TodoItem] todo_id
|
11
|
+
# @return [Basecampeverest::TodoItem] all todo lists for all projects from the Basecamp API
|
12
|
+
def self.find(project_id, todo_id)
|
13
|
+
url = "projects/#{project_id}/todos/#{todo_id}.json"
|
14
|
+
response = Basecampeverest::Connect.get url
|
15
|
+
|
16
|
+
# parse the response to remove HTTParty info
|
17
|
+
response.parsed_response
|
18
|
+
end
|
19
|
+
|
20
|
+
# create a todo via the Basecamp API
|
21
|
+
#
|
22
|
+
# @param [Basecampeverest::TodoItem] project_id the project id of the todo to create
|
23
|
+
# @param [Basecampeverest::TodoItem] todolist_id the todolist_id of the todo to be created
|
24
|
+
# @return [Basecampeverest::TodoItem] all todo lists for all projects from the Basecamp API
|
25
|
+
def self.new(project_id, todolist_id, options={})
|
26
|
+
post_params = {
|
27
|
+
:body => options.to_json,
|
28
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
29
|
+
}
|
30
|
+
url = "/projects/#{project_id}/todolists/#{todolist_id}/todos.json"
|
31
|
+
# make the http basecamp call
|
32
|
+
response = Basecampeverest::Connect.post url, post_params
|
33
|
+
|
34
|
+
# parse the response to remove HTTParty info
|
35
|
+
response.parsed_response
|
36
|
+
end
|
37
|
+
|
38
|
+
# update a specific todo via the Basecamp API
|
39
|
+
#
|
40
|
+
# @param [Basecampeverest::TodoItem] project_id the project id of the todo to update
|
41
|
+
# @param [Basecampeverest::TodoItem] todo_id the id of the todo to update
|
42
|
+
# @param [Basecampeverest::Project] options the details of the updated todo
|
43
|
+
# @return [Basecampeverest::TodoItem] all todo lists for all projects from the Basecamp API
|
44
|
+
def self.update(project_id, todo_id, options={})
|
45
|
+
post_params = {
|
46
|
+
:body => options.to_json,
|
47
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
48
|
+
}
|
49
|
+
url = "/projects/#{project_id}/todos/#{todo_id}.json"
|
50
|
+
# make the http basecamp call
|
51
|
+
response = Basecampeverest::Connect.put url, post_params
|
52
|
+
|
53
|
+
# parse the response to remove HTTParty info
|
54
|
+
response.parsed_response
|
55
|
+
end
|
56
|
+
|
57
|
+
# delete a specific todo via the Basecamp API
|
58
|
+
#
|
59
|
+
# @param [Basecampeverest::TodoItem] project_id the project id of the todo to update
|
60
|
+
# @param [Basecampeverest::TodoItem] todo_id the id of the todo to update
|
61
|
+
# @return [Basecampeverest::TodoItem] a message with the result from the Basecamp API
|
62
|
+
def self.delete(project_id, todo_id)
|
63
|
+
# for some reason ruby won't put in the project ID for a delete method. Solved by setting the url
|
64
|
+
# and then calling delete
|
65
|
+
url = "/projects/#{project_id}/todos/#{todo_id}.json"
|
66
|
+
response = Basecampeverest::Connect.delete url
|
67
|
+
|
68
|
+
# This checks the response code for validity and error checking
|
69
|
+
if response.code == 204
|
70
|
+
message = "Todo successfully deleted"
|
71
|
+
elsif response.code == 403
|
72
|
+
message = "You do not have permission to delete this todo"
|
73
|
+
else
|
74
|
+
message = "Invalid project ID or authentication. The todo was not deleted."
|
75
|
+
end
|
76
|
+
|
77
|
+
# return the message
|
78
|
+
message
|
79
|
+
end
|
80
|
+
|
81
|
+
end; end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Basecampeverest; class TodoList
|
2
|
+
|
3
|
+
# find all todo lists for all projects via the Basecamp API
|
4
|
+
#
|
5
|
+
# @return [Basecampeverest::TodoList] all todo lists for all projects from the Basecamp API
|
6
|
+
def self.all
|
7
|
+
response = Basecampeverest::Connect.get "/todolists.json"
|
8
|
+
|
9
|
+
# parse the response to remove HTTParty info
|
10
|
+
response.parsed_response
|
11
|
+
end
|
12
|
+
|
13
|
+
# find all completed todo lists for all projects via the Basecamp API
|
14
|
+
#
|
15
|
+
# @return [Basecampeverest::TodoList] all completed todo lists for all projects from the Basecamp API
|
16
|
+
def self.all_completed
|
17
|
+
response = Basecampeverest::Connect.get "/todolists/completed.json"
|
18
|
+
|
19
|
+
# parse the response to remove HTTParty info
|
20
|
+
response.parsed_response
|
21
|
+
end
|
22
|
+
|
23
|
+
# find all project specific todo lists via the Basecamp API
|
24
|
+
#
|
25
|
+
# @param [Basecampeverest::TodoList] project_id the project id of the project to get the todo lists from
|
26
|
+
# @return [Basecampeverest::TodoList] all todo lists for a project from the Basecamp API
|
27
|
+
def self.find_completed(project_id)
|
28
|
+
url = "/projects/#{project_id}/todolists/completed.json"
|
29
|
+
response = Basecampeverest::Connect.get url
|
30
|
+
|
31
|
+
# parse the response to remove HTTParty info
|
32
|
+
response.parsed_response
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# find all todo_lists for a specific project via the Basecamp API
|
37
|
+
#
|
38
|
+
# @param [Basecampeverest::TodoList] project_id the project id of the project to get the todo lists from
|
39
|
+
# @param [Basecampeverest::TodoList] todo_list_id the todo list id of the todo list to get the todo items from
|
40
|
+
# @return [Basecampeverest::TodoList] all todo lists for all projects from the Basecamp API
|
41
|
+
def self.find(project_id, todo_list_id)
|
42
|
+
url = "/projects/#{project_id}/todolists/#{todo_list_id}.json"
|
43
|
+
response = Basecampeverest::Connect.get url
|
44
|
+
|
45
|
+
# parse the response to remove HTTParty info
|
46
|
+
response.parsed_response
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.for_project(project_id)
|
50
|
+
url = "/projects/#{project_id}/todolists.json"
|
51
|
+
response = Basecampeverest::Connect.get url
|
52
|
+
|
53
|
+
# parse the response to remove HTTParty info
|
54
|
+
response.parsed_response
|
55
|
+
end
|
56
|
+
|
57
|
+
# find all todo_lists assigned to a specific person via the Basecamp API
|
58
|
+
#
|
59
|
+
# @param [Basecampeverest::TodoList] person_id the person id of the person to get the todo lists for
|
60
|
+
# @return [Basecampeverest::TodoList] all todo_lists assigned to a specific person from the Basecamp API
|
61
|
+
def self.all_assigned(person_id)
|
62
|
+
url = "/people/#{person_id}/assigned_todos.json"
|
63
|
+
response = Basecampeverest::Connect.get url
|
64
|
+
|
65
|
+
# parse the response to remove HTTParty info
|
66
|
+
response.parsed_response
|
67
|
+
end
|
68
|
+
|
69
|
+
# create a todo_list via the Basecamp API
|
70
|
+
#
|
71
|
+
# @param [Basecampeverest::TodoList] project_id the project id for the todo list to update
|
72
|
+
# @param [Basecampeverest::TodoList] options={} a hash containing :name and :description for the new todo list
|
73
|
+
# @return [Basecampeverest::TodoList] the new todo list info from the Basecamp API
|
74
|
+
def self.new(project_id, options={})
|
75
|
+
# if options[:name].nil?
|
76
|
+
# return "You need a project name"
|
77
|
+
# else
|
78
|
+
|
79
|
+
# end
|
80
|
+
post_params = {
|
81
|
+
:body => options.to_json,
|
82
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
83
|
+
}
|
84
|
+
url = "/projects/#{project_id}/todolists.json"
|
85
|
+
# make the http basecamp call
|
86
|
+
response = Basecampeverest::Connect.post url, post_params
|
87
|
+
|
88
|
+
# parse the response to remove HTTParty info
|
89
|
+
response.parsed_response
|
90
|
+
end
|
91
|
+
|
92
|
+
# update a todo_list via the Basecamp API
|
93
|
+
#
|
94
|
+
# @param [Basecampeverest::TodoList] project_id the project id for the todo list to update
|
95
|
+
# @param [Basecampeverest::TodoList] todo_list_id the todo list id for the todo list to update
|
96
|
+
# @param [Basecampeverest::TodoList] options={} a hash containing :name and :description for the todo list
|
97
|
+
# @return [Basecampeverest::TodoList] the new todo list info from the Basecamp API
|
98
|
+
def self.update(project_id, todo_list_id, options={})
|
99
|
+
post_params = {
|
100
|
+
:body => options.to_json,
|
101
|
+
:headers => Basecampeverest::Connect.merge({'Content-Type' => 'application/json'})
|
102
|
+
}
|
103
|
+
url = "/projects/#{project_id}/todolists/#{todo_list_id}.json"
|
104
|
+
# make the http basecamp call
|
105
|
+
response = Basecampeverest::Connect.put url, post_params
|
106
|
+
|
107
|
+
# parse the response to remove HTTParty info
|
108
|
+
response.parsed_response
|
109
|
+
end
|
110
|
+
|
111
|
+
# delete a todo_list via the Basecamp API
|
112
|
+
#
|
113
|
+
# @param [Basecampeverest::TodoList] project_id the project id for the todo list to delete
|
114
|
+
# @param [Basecampeverest::TodoList] todo_list_id the todo list id for the todo list to delete
|
115
|
+
# @return [Basecampeverest::TodoList] a message with the result of the delete from the Basecamp API
|
116
|
+
def self.delete(project_id, todo_list_id)
|
117
|
+
url = "/projects/#{project_id}/todolists/#{todo_list_id}.json"
|
118
|
+
response = Basecampeverest::Connect.delete url
|
119
|
+
|
120
|
+
# This checks the response code for validity and error checking
|
121
|
+
if response.code == 204
|
122
|
+
message = "Todo List successfully deleted"
|
123
|
+
elsif response.code == 403
|
124
|
+
message = "You do not have permission to delete this Todo List"
|
125
|
+
else
|
126
|
+
message = "Invalid project ID, todo list ID or authentication. The todo_list was not deleted."
|
127
|
+
end
|
128
|
+
|
129
|
+
# return the message
|
130
|
+
message
|
131
|
+
end
|
132
|
+
|
133
|
+
# end module and class
|
134
|
+
end; end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Basecampeverest; class Topics
|
2
|
+
|
3
|
+
# find all #### via the Basecamp API
|
4
|
+
#
|
5
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
6
|
+
def self.all
|
7
|
+
response = Basecampeverest::Connect.get
|
8
|
+
|
9
|
+
# parse the response to remove HTTParty info
|
10
|
+
response.parsed_response
|
11
|
+
end
|
12
|
+
|
13
|
+
# #### via the Basecamp API
|
14
|
+
#
|
15
|
+
# @param [Basecampeverest::Project] ####
|
16
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
17
|
+
def self.find(####)
|
18
|
+
response = Basecampeverest::Connect.get
|
19
|
+
|
20
|
+
# parse the response to remove HTTParty info
|
21
|
+
response.parsed_response
|
22
|
+
end
|
23
|
+
|
24
|
+
# #### via the Basecamp API
|
25
|
+
#
|
26
|
+
#
|
27
|
+
# @param [Basecampeverest::Project] ####
|
28
|
+
# @param [Basecampeverest::Project] ####
|
29
|
+
# @return [Basecampeverest::Project] #### from the Basecamp API
|
30
|
+
def self.new(options={})
|
31
|
+
post_params = {
|
32
|
+
:body => options.to_json,
|
33
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
34
|
+
}
|
35
|
+
# make the http basecamp call
|
36
|
+
response = Basecampeverest::Connect.post "####", post_params
|
37
|
+
|
38
|
+
# parse the response to remove HTTParty info
|
39
|
+
response.parsed_response
|
40
|
+
end
|
41
|
+
|
42
|
+
# #### via the Basecamp API
|
43
|
+
#
|
44
|
+
# @param [Basecampeverest::Project] ####
|
45
|
+
# @param [Basecampeverest::Project] ####
|
46
|
+
# @return [Basecampeverest::Project] from the Basecamp API
|
47
|
+
def self.update()
|
48
|
+
post_params = {
|
49
|
+
:body => options.to_json,
|
50
|
+
:headers => Basecampeverest::Connect.merge({'Content-Type' => 'application/json'})
|
51
|
+
}
|
52
|
+
|
53
|
+
# make the http basecamp call
|
54
|
+
response = Basecampeverest::Connect.put "####", post_params
|
55
|
+
|
56
|
+
# parse the response to remove HTTParty info
|
57
|
+
response.parsed_response
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# #### via the Basecamp API
|
62
|
+
#
|
63
|
+
# @param [Basecampeverest::Project] ####
|
64
|
+
# @return [Basecampeverest::Project] ####
|
65
|
+
def self.delete()
|
66
|
+
url = "####"
|
67
|
+
response = Basecampeverest::Connect.delete url
|
68
|
+
|
69
|
+
# This checks the response code for validity and error checking
|
70
|
+
if response.code == 204
|
71
|
+
message = "#### successfully deleted"
|
72
|
+
elsif response.code == 403
|
73
|
+
message = "You do not have permission to delete this ####"
|
74
|
+
else
|
75
|
+
message = "Invalid project ID or authentication. The #### was not deleted."
|
76
|
+
end
|
77
|
+
|
78
|
+
# return the message
|
79
|
+
message
|
80
|
+
end
|
81
|
+
|
82
|
+
# end module and class
|
83
|
+
end; end
|