1 <?php
2 namespace MailChimp\AuthorizedApps;
3
4 use MailChimp\MailChimp as MailChimp;
5
6 class AuthorizedApps extends MailChimp
7 {
8
9 /**
10 * Get a list of Authorized Apps for the account
11 *
12 * Available query fields:
13 * array["fields"] array list of strings of response fields to return
14 * array["exclude_fields"] array list of strings of response fields to exclude (not to be used with "fields")
15 * array["count"] int number of records to return
16 * array["offset"] int number of records from a collection to skip.
17 */
18 public function getApps(array $query = [])
19 {
20 return self::execute("GET", "authorized-apps", $query);
21 }
22
23 /**
24 * Get a list of Authorized Apps for the account
25 *
26 * Available query fields:
27 * array["fields"] array list of strings of response fields to return
28 * array["exclude_fields"] array list of strings of response fields to exclude (not to be used with "fields")
29 */
30 public function getApp($app_id, array $query = [])
31 {
32 return self::execute("GET", "authorized-apps/{$app_id}", $query);
33 }
34
35 /**
36 * Retrieve OAuth2-based credentials to associate API calls with your application.
37 *
38 * @param string $client_id
39 * @param string $client_secret
40 * @return object with access_token and viewer_token
41 */
42 public function manageApp($client_id, $client_secret)
43 {
44 $data = [
45 "client_id" => $client_id,
46 "client_secret" => $client_secret
47 ];
48 return self::execute("POST", "authorized-apps", $data);
49 }
50
51 }
52