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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9c889239a3ba4c249a55c8fdbc50e4babec6f09d
|
4
|
+
data.tar.gz: 6fc8f2d98f32a9aa5e5a7d0e4d5549fe4d65ba0f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 357b562178ad4ac1f0410c5fceea95b91c8d7afbd0b7e6fad6f7bab0baecb5c5567b7dc27c4af78149ef308e1ba52f84c0a722fdd22b0c7bc54f820251df98b0
|
7
|
+
data.tar.gz: 3851acb5669bc4375fcf6450f3260398f3cb74500652fe835ff4a6d134c4df3e7b929eb62679db0cf306c83ad90b722d1064bc8a3b98d1b3c73e334888369502
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module Basecampeverest
|
2
|
+
class Connect
|
3
|
+
# includes
|
4
|
+
include HTTParty
|
5
|
+
include JSON
|
6
|
+
|
7
|
+
# INTRODUCTION
|
8
|
+
# *******************************************************
|
9
|
+
#
|
10
|
+
# This is a class based off the required format for httparty. When an instance of the class is called,
|
11
|
+
# httparty created the connection using the specific variables base_uri, and headers.
|
12
|
+
#
|
13
|
+
# Once an instance of this class has been created, you can then call on the gem using that stored authorization.
|
14
|
+
#
|
15
|
+
#
|
16
|
+
#
|
17
|
+
#
|
18
|
+
# EXAMPLE
|
19
|
+
# *******************************************************
|
20
|
+
# @authorization = { :username => "first.last@example.com", :password => "IuseSecureP@assw0rd$_" }
|
21
|
+
# @user_agent = "PutAnythingHere (first.last@example.com)"
|
22
|
+
# @basecamp_ID = "123456"
|
23
|
+
# Basecampeverest::Connect.new(@basecamp_ID, @authorization, @user_agent)
|
24
|
+
|
25
|
+
# => #<Basecampeverest::Connect:0x007fc8652eca18>
|
26
|
+
|
27
|
+
# Basecampeverest::Project.all
|
28
|
+
|
29
|
+
# =>[{"id"=>494832908, "name"=>"Cool Basecamp Project", "description"=>"this is a description", "archived"=>false, "is_client_project"=>false,
|
30
|
+
# "created_at"=>"2013-11-06T13:53:17.000-05:00", "updated_at"=>"2013-12-05T13:34:20.000-05:00", "draft"=>false,
|
31
|
+
# "last_event_at"=>"2013-12-05T13:34:20.000-05:00", "starred"=>false,
|
32
|
+
# "url"=>"https://basecamp.com/123456/api/v1/projects/494832908-Cool-Basecamp-Project.json"}]
|
33
|
+
#
|
34
|
+
#
|
35
|
+
#
|
36
|
+
#
|
37
|
+
# LICENSE
|
38
|
+
# *******************************************************
|
39
|
+
#
|
40
|
+
# Copyright (c) 2014 Alex Gordon
|
41
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
42
|
+
# a copy of this software and associated documentation files (the
|
43
|
+
# "Software"), to deal in the Software without restriction, including
|
44
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
45
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
46
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
47
|
+
# the following conditions:
|
48
|
+
#
|
49
|
+
# The above copyright notice and this permission notice shall be
|
50
|
+
# included in all copies or substantial portions of the Software.
|
51
|
+
#
|
52
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
53
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
54
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
55
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
56
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
57
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
58
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
59
|
+
#
|
60
|
+
|
61
|
+
|
62
|
+
# Set a few variables
|
63
|
+
attr_accessor :basecamp_id, :authorization, :user_agent, :base_uri, :headers
|
64
|
+
|
65
|
+
# Initializes the connection to Basecamp using httparty.
|
66
|
+
#
|
67
|
+
# @param basecamp_id [String] the Basecamp company ID
|
68
|
+
# @param authorization [Hash] authorization hash consisting of a username and password combination (:username, :password) or an access_token (:access_token)
|
69
|
+
# @param user_agent [String] the user-agent string to include in header of requests
|
70
|
+
def initialize(basecamp_id, authorization, user_agent)
|
71
|
+
# Set some variables
|
72
|
+
self.class.base_uri "https://basecamp.com/#{basecamp_id}/api/v1"
|
73
|
+
self.class.headers 'User-Agent' => user_agent
|
74
|
+
self.auth = authorization
|
75
|
+
|
76
|
+
# end method
|
77
|
+
end
|
78
|
+
|
79
|
+
# Sets the authorization information.
|
80
|
+
# Need to
|
81
|
+
#
|
82
|
+
# @param authorization [Hash] authorization hash consisting of a username and password combination (:username, :password) or an access_token (:access_token)
|
83
|
+
def auth=(authorization)
|
84
|
+
clensed_auth_hash = {}
|
85
|
+
authorization.each {|k, v|
|
86
|
+
clensed_auth_hash[k.to_sym] = v
|
87
|
+
}
|
88
|
+
|
89
|
+
# nice and pretty now
|
90
|
+
authorization = clensed_auth_hash
|
91
|
+
|
92
|
+
# if the authorization has the correct hash values...
|
93
|
+
if authorization.has_key?(:username) && authorization.has_key?(:password)
|
94
|
+
|
95
|
+
# ... then we pass it off to basic auth
|
96
|
+
self.class.basic_auth authorization[:username], authorization[:password]
|
97
|
+
|
98
|
+
# check if the user tried passing in some other stupid stuff.
|
99
|
+
# this should never be the case if the user follows instructions.
|
100
|
+
self.class.headers.reject!{ |k, v| k == "Authorization" }
|
101
|
+
|
102
|
+
else
|
103
|
+
# something inportant is missing if we get here.
|
104
|
+
raise "Incomplete Authorization hash. Please check the Authentication Hash."
|
105
|
+
|
106
|
+
#end else
|
107
|
+
end
|
108
|
+
|
109
|
+
# end method
|
110
|
+
end
|
111
|
+
|
112
|
+
# end class
|
113
|
+
end
|
114
|
+
|
115
|
+
# end module
|
116
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Basecampeverest; class Convert
|
2
|
+
|
3
|
+
# code originally written by Rebecca Miller-Webster
|
4
|
+
# taken from https://gist.github.com/rmw/2710460
|
5
|
+
|
6
|
+
# convert an array into a nested OpenStruct
|
7
|
+
#
|
8
|
+
# @param [Basecampeverest::Project] object the recursive object to pass in
|
9
|
+
# @return [Basecampeverest::Project] the found project information from the Basecamp API
|
10
|
+
def to_ostruct_recursive(options)
|
11
|
+
convert_to_ostruct_recursive(self, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def convert_to_ostruct_recursive(obj, options)
|
15
|
+
result = obj
|
16
|
+
if result.is_a? Hash
|
17
|
+
result = result.dup.with_sym_keys
|
18
|
+
result.each do |key, val|
|
19
|
+
result[key] = convert_to_ostruct_recursive(val, options) unless options[:exclude].try(:include?, key)
|
20
|
+
end
|
21
|
+
result = OpenStruct.new result
|
22
|
+
elsif result.is_a? Array
|
23
|
+
result = result.map { |r| convert_to_ostruct_recursive(r, options) }
|
24
|
+
end
|
25
|
+
return result
|
26
|
+
end
|
27
|
+
end; end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# taken from http://www.rebeccamiller-webster.com/2012/06/recursively-convert-a-ruby-hash-to-openstruct/
|
2
|
+
|
3
|
+
class Recursive
|
4
|
+
# options:
|
5
|
+
# :exclude => [keys] - keys need to be symbols
|
6
|
+
def self.to_ostruct_recursive(options = {})
|
7
|
+
convert_to_ostruct_recursive(self, options)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
def convert_to_ostruct_recursive(obj, options)
|
12
|
+
result = obj
|
13
|
+
if result.is_a? Hash
|
14
|
+
result = result.dup.with_sym_keys
|
15
|
+
result.each do |key, val|
|
16
|
+
result[key] = convert_to_ostruct_recursive(val, options) unless options[:exclude].try(:include?, key)
|
17
|
+
end
|
18
|
+
result = OpenStruct.new result
|
19
|
+
elsif result.is_a? Array
|
20
|
+
result = result.map { |r| convert_to_ostruct_recursive(r, options) }
|
21
|
+
end
|
22
|
+
return result
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Basecampeverest; class Access
|
2
|
+
|
3
|
+
# find the people that have access to a project via the Basecamp API
|
4
|
+
#
|
5
|
+
# @param [Basecampeverest::Project] project_id the project id from basecamp
|
6
|
+
# @return [Basecampeverest::Project] the parsed response of who has access from the Basecamp API
|
7
|
+
def self.for_project(project_id)
|
8
|
+
url = "/projects/#{project_id}/accesses.json"
|
9
|
+
response = Basecampeverest::Connect.get url
|
10
|
+
|
11
|
+
# parse the response to remove HTTParty info
|
12
|
+
response.parsed_response
|
13
|
+
end
|
14
|
+
|
15
|
+
# find the people that have access to a calendar via the Basecamp API
|
16
|
+
#
|
17
|
+
# @param [Basecampeverest::Project] calendar_id the calendar id to check access
|
18
|
+
# @return [Basecampeverest::Project] the parsed response of who has access from the Basecamp API
|
19
|
+
def self.for_calendar(calendar_id)
|
20
|
+
url = "/calendars/#{calendar_id}/accesses.json"
|
21
|
+
response = Basecampeverest::Connect.get url
|
22
|
+
|
23
|
+
# parse the response to remove HTTParty info
|
24
|
+
response.parsed_response
|
25
|
+
end
|
26
|
+
|
27
|
+
# find the people that have access to a project via the Basecamp API
|
28
|
+
#
|
29
|
+
# @param [Basecampeverest::Project] project_id the project id from basecamp
|
30
|
+
# @param [Basecampeverest::Project] options a hash containing the people to grant access
|
31
|
+
# @return [Basecampeverest::Project] the parsed response of who has access from the Basecamp API
|
32
|
+
def self.grant_project(project_id, options={})
|
33
|
+
post_params = {
|
34
|
+
:body => options.to_json,
|
35
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
36
|
+
}
|
37
|
+
url = "/projects/#{project_id}/accesses.json"
|
38
|
+
response = Basecampeverest::Connect.post url, post_params
|
39
|
+
|
40
|
+
# parse the response to remove HTTParty info
|
41
|
+
response.parsed_response
|
42
|
+
end
|
43
|
+
|
44
|
+
# find the people that have access to a project via the Basecamp API
|
45
|
+
#
|
46
|
+
# @param [Basecampeverest::Project] project_id the project id from basecamp
|
47
|
+
# @param [Basecampeverest::Project] options a hash containing the people to revoke access for
|
48
|
+
# @return [Basecampeverest::Project] the parsed response of who has access from the Basecamp API
|
49
|
+
def self.revoke_project(project_id, user_id)
|
50
|
+
post_params = {
|
51
|
+
:body => options.to_json,
|
52
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
53
|
+
}
|
54
|
+
url = "/projects/#{project_id}/accesses/#{user_id}.json"
|
55
|
+
response = Basecampeverest::Connect.get url, post_params
|
56
|
+
|
57
|
+
# parse the response to remove HTTParty info
|
58
|
+
response.parsed_response
|
59
|
+
end
|
60
|
+
|
61
|
+
# end module and class
|
62
|
+
end; end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Basecampeverest; class Attachments
|
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
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Basecampeverest; class Calendar
|
2
|
+
|
3
|
+
# find all calendars via the Basecamp API
|
4
|
+
#
|
5
|
+
# @return [Basecampeverest::Project] an array of all the calendars from the Basecamp API
|
6
|
+
def self.all
|
7
|
+
url = "/calendars.json"
|
8
|
+
response = Basecampeverest::Connect.get url
|
9
|
+
|
10
|
+
# parse the response to remove HTTParty info
|
11
|
+
response.parsed_response
|
12
|
+
end
|
13
|
+
|
14
|
+
# a specific calendar via the Basecamp API
|
15
|
+
#
|
16
|
+
# @param [Basecampeverest::Project] calendar_id the id of the calendar
|
17
|
+
# @return [Basecampeverest::Project] an array of the calendar information from the Basecamp API
|
18
|
+
def self.find(calendar_id)
|
19
|
+
url = "/calendars/#{calendar_id}.json"
|
20
|
+
response = Basecampeverest::Connect.get url
|
21
|
+
|
22
|
+
# parse the response to remove HTTParty info
|
23
|
+
response.parsed_response
|
24
|
+
end
|
25
|
+
|
26
|
+
# create a calendar via the Basecamp API
|
27
|
+
#
|
28
|
+
#
|
29
|
+
# @param [Basecampeverest::Project] options a hash that contains the array of the name of the calendar to be created
|
30
|
+
# @return [Basecampeverest::Project] the info of the calendar created from the Basecamp API
|
31
|
+
def self.new(options={})
|
32
|
+
post_params = {
|
33
|
+
:body => options.to_json,
|
34
|
+
:headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
|
35
|
+
}
|
36
|
+
# make the http basecamp call
|
37
|
+
url = "/calendars.json"
|
38
|
+
response = Basecampeverest::Connect.post url, post_params
|
39
|
+
|
40
|
+
# parse the response to remove HTTParty info
|
41
|
+
response.parsed_response
|
42
|
+
end
|
43
|
+
|
44
|
+
# update a calendar via the Basecamp API
|
45
|
+
#
|
46
|
+
# @param [Basecampeverest::Project] calendar_id the id of the calendar
|
47
|
+
# @return [Basecampeverest::Project] the created calendar from the Basecamp API
|
48
|
+
def self.update(calendar_id)
|
49
|
+
post_params = {
|
50
|
+
:body => options.to_json,
|
51
|
+
:headers => Basecampeverest::Connect.merge({'Content-Type' => 'application/json'})
|
52
|
+
}
|
53
|
+
|
54
|
+
# make the http basecamp call
|
55
|
+
url = "/calendars/#{calendar_id}.json"
|
56
|
+
response = Basecampeverest::Connect.put url, post_params
|
57
|
+
|
58
|
+
# parse the response to remove HTTParty info
|
59
|
+
response.parsed_response
|
60
|
+
end
|
61
|
+
|
62
|
+
# delete a calendar via the Basecamp API
|
63
|
+
#
|
64
|
+
# @param [Basecampeverest::Project] calendar_id the id of the calendar
|
65
|
+
# @return [Basecampeverest::Project] a message with successful or unsuccessful deletion
|
66
|
+
def self.delete(calendar_id)
|
67
|
+
url = "/calendars/#{calendar_id}.json"
|
68
|
+
response = Basecampeverest::Connect.delete url
|
69
|
+
|
70
|
+
# This checks the response code for validity and error checking
|
71
|
+
if response.code == 204
|
72
|
+
message = "#### successfully deleted"
|
73
|
+
elsif response.code == 403
|
74
|
+
message = "You do not have permission to delete this ####"
|
75
|
+
else
|
76
|
+
message = "Invalid project ID or authentication. The #### was not deleted."
|
77
|
+
end
|
78
|
+
|
79
|
+
# return the message
|
80
|
+
message
|
81
|
+
end
|
82
|
+
|
83
|
+
# end module and class
|
84
|
+
end; end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Basecampeverest; class CalendarEvents
|
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 Comment
|
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 Document
|
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
|