This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-basecamp-api.php
277 lines (214 loc) · 5.06 KB
/
wp-basecamp-api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<?php
/**
* WP Basecamp API (https://github.com/basecamp/bc3-api)
*
* @package WP-Basecamp-API
*/
/*
* Plugin Name: WP Basecamp API
* Plugin URI: https://github.com/wp-api-libraries/wp-basecamp-api
* Description: Perform API requests to Basecamp in WordPress.
* Author: WP API Libraries
* Version: 1.0.0
* Author URI: https://wp-api-libraries.com
* GitHub Plugin URI: https://github.com/wp-api-libraries/wp-basecamp-api
* GitHub Branch: master
*/
/* Exit if accessed directly. */
if ( ! defined( 'ABSPATH' ) ) { exit; }
include_once( 'wp-api-libraries-base.php' );
/* Check if class exists. */
if ( ! class_exists( 'BasecampAPI' ) ) {
/**
* BasecampAPI class.
*/
class BasecampAPI extends BasecampAPIBase {
/**
* Access Token.
*
* @var string
*/
private $access_token;
/**
* Account ID.
*
* @var string
*/
private $account_id;
/**
* BaseAPI Endpoint
*
* @var string
* @access protected
*/
protected $base_uri = 'https://3.basecampapi.com/';
/**
* __construct function.
*
* @access public
* @param mixed $account_id
* @param mixed $access_token
* @return void
*/
public function __construct( $account_id, $access_token ){
$this->account_id = $account_id;
$this->base_uri .= $account_id . '/';
$this->access_token = $access_token;
}
/**
* set_headers function.
*
* @access protected
* @return void
*/
protected function set_headers(){
$this->args['headers'] = array(
'Authorization' => 'Bearer ' . $this->access_token,
'Content-Type' => 'application/json',
);
}
/**
* Private wrapper function (for simpler coding), prepares the request then fetches it.
*
* @param [type] $route [description]
* @param array $body [description]
* @param bool $method The method of the request.
* @return [type] [description]
*/
private function run( $route, $body = array(), $method = 'GET' ){
return $this->build_request( $route . '.json', $body, $method )->fetch();
}
/**
* Returns a list of currently authenticated users.
*
* @return object The response.
*/
public function check_authentication(){
$this->base_uri = 'https://launchpad.37signals.com/';
$response = $this->run( 'authorization' );
$this->base_uri = 'https://3.basecampapi.com/';
return $response;
}
/* ATTACHMENTS. */
/* CAMPFIRES. */
/* CHATBOTS. */
/* CLIENT APPROVALS. */
/* CLIENT CORRESPONDENCES. */
/* CLIENT REPLIES. */
/* COMMENTS. */
/* DOCUMENTS. */
/* EVENTS. */
/* FORWARDS. */
/* INBOXES. */
/* MESSAGE BOARDS. */
/**
* get_message_board function.
*
* @access public
* @param mixed $project_id
* @param mixed $message_board_id
* @return void
*/
public function get_message_board( $project_id, $message_board_id ) {
return $this->run( 'buckets/'.$project_id.'/message_boards/' . $message_board_id );
}
/* MESSAGE TYPES. */
/* MESSAGES. */
/**
* get_messages function.
*
* @access public
* @param mixed $project_id
* @param mixed $message_board
* @return void
*/
public function get_messages( $project_id, $message_board ) {
return $this->run( 'buckets/'.$project_id.'/message_boards/'.$message_board.'/messages' );
}
/**
* get_message function.
*
* @access public
* @param mixed $message_id
* @param mixed $project_id
* @return void
*/
public function get_message( $message_id, $project_id ) {
return $this->run( 'buckets/'.$project_id.'/messages/' . $message_id );
}
public function create_message() {
}
/* PEOPLE. */
/**
* get_people function.
*
* @access public
* @return void
*/
public function get_people() {
return $this->run( 'people' );
}
/* PROJECTS. */
/**
* get_all_projects function.
*
* @access public
* @return void
*/
public function get_all_projects() {
return $this->run( 'projects' );
}
/**
* get_project function.
*
* @access public
* @param mixed $project_id
* @return void
*/
public function get_project( $project_id ) {
return $this->run( 'projects/' . $project_id );
}
/* QUESTION ANSWERS. */
/* QUESTIONNAIRES. */
/* QUESTIONS. */
/* RECORDINGS. */
/* SCHEDULE ENTRIES. */
/* SCHEDULES. */
/* SUBSCRIPTIONS. */
/* TEMPLATES. */
/* TODO LIST GROUPS. */
/* TODO LISTS. */
/* TODO SETS. */
/* TODOS. */
/* UPLOADS. */
public function get_uploads( $project_id, $vault_id ) {
return $this->run( '/buckets/'.$project_id.'/vaults/'.$vault_id.'/uploads' );
}
/* VAULTS. */
/**
* get_vaults function.
*
* @access public
* @return void
*/
public function get_vaults() {
return $this->run( 'vaults' );
}
/**
* get_vault function.
*
* @access public
* @param mixed $vault_id
* @param mixed $project_id
* @return void
*/
public function get_vault( $vault_id, $project_id ) {
return $this->run( '/buckets/'. $project_id .'/vaults/' . $vault_id );
}
public function create_vault() {
}
public function update_vault() {
}
/* WEBHOOKS. */
}
}