Skip to content
This repository was archived by the owner on Dec 16, 2021. It is now read-only.

Commit e35be1c

Browse files
committed
Merge pull request #85 from constantcontact/development
Promote dev to master
2 parents 1b8f6af + 98fb72f commit e35be1c

File tree

19 files changed

+618
-22
lines changed

19 files changed

+618
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Composer is a dependency management tool for PHP that allows you to declare the
1717
```javascript
1818
{
1919
"require": {
20-
"constantcontact/constantcontact": "1.1.*"
20+
"constantcontact/constantcontact": "1.3.*"
2121
}
2222
}
2323
```

examples/addOrUpdateContact.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
*
6363
* See: http://developer.constantcontact.com/docs/contacts-api/contacts-index.html#opt_in
6464
*/
65-
$returnContact = $cc->addContact(ACCESS_TOKEN, $contact, false);
65+
$returnContact = $cc->addContact(ACCESS_TOKEN, $contact, true);
6666

6767
// update the existing contact if address already existed
6868
} else {
@@ -80,7 +80,7 @@
8080
*
8181
* See: http://developer.constantcontact.com/docs/contacts-api/contacts-index.html#opt_in
8282
*/
83-
$returnContact = $cc->updateContact(ACCESS_TOKEN, $contact, false);
83+
$returnContact = $cc->updateContact(ACCESS_TOKEN, $contact, true);
8484
}
8585

8686
// catch any exceptions thrown during the process and print the errors to screen
@@ -150,4 +150,4 @@
150150
} ?>
151151

152152
</body>
153-
</html>
153+
</html>

src/Ctct/Auth/CtctOAuth2.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function getAuthorizationUrl($server = true, $state = null)
4747
}
4848

4949
$url = Config::get('auth.base_url') . Config::get('auth.authorization_endpoint');
50-
return $url . '?' . http_build_query($params);
50+
return $url . '?' . http_build_query($params, '', '&');
5151
}
5252

5353
/**
@@ -66,7 +66,7 @@ public function getAccessToken($code)
6666
'redirect_uri' => $this->redirectUri
6767
);
6868

69-
$url = Config::get('auth.base_url') . Config::get('auth.token_endpoint') . '?' . http_build_query($params);
69+
$url = Config::get('auth.base_url') . Config::get('auth.token_endpoint') . '?' . http_build_query($params, '', '&');
7070

7171
$response = $this->restClient->post($url);
7272
$responseBody = json_decode($response->body, true);

src/Ctct/Components/Account/AccountInfo.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,21 @@ class AccountInfo extends Component
4545
/**
4646
* Email address associated with the account
4747
* @var string
48-
* NOTE: the API returns 'email' field instead of 'email_address', but 'email_address' is used elsewhere
4948
*/
50-
public $email_address;
49+
public $email;
5150

5251
/**
5352
* Phone number associated with the account
5453
* @var string
5554
*/
5655
public $phone;
5756

57+
/**
58+
* URL of the company logo associated with the account
59+
* @var string
60+
*/
61+
public $company_logo;
62+
5863
/**
5964
* Country code associated with the account
6065
* @var string
@@ -86,12 +91,17 @@ public static function create(array $props)
8691
$accountInfo->time_zone = parent::getValue($props, "time_zone");
8792
$accountInfo->first_name = parent::getValue($props, "first_name");
8893
$accountInfo->last_name = parent::getValue($props, "last_name");
89-
$accountInfo->email_address = parent::getValue($props, "email");
94+
$accountInfo->email = parent::getValue($props, "email");
9095
$accountInfo->phone = parent::getValue($props, "phone");
96+
$accountInfo->company_logo = parent::getValue($props, "company_logo");
9197
$accountInfo->country_code = parent::getValue($props, "country_code");
9298
$accountInfo->state_code = parent::getValue($props, "state_code");
9399
$accountInfo->organization_addresses = parent::getValue($props, "organization_addresses");
94100

95101
return $accountInfo;
96102
}
103+
104+
public function toJson() {
105+
return json_encode($this);
106+
}
97107
}

src/Ctct/Components/Account/VerifiedEmailAddress.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ public static function create(array $props)
3636
$verifiedAddress->status = parent::getValue($props, "status");
3737
return $verifiedAddress;
3838
}
39+
40+
public function toJson() {
41+
return json_encode($this);
42+
}
3943
}

src/Ctct/Components/Activities/AddContacts.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public function __construct(Array $contacts, Array $lists, Array $columnNames =
9999
}
100100
}
101101
$this->column_names = $usedColumns;
102+
} else {
103+
$this->column_names = $columnNames;
102104
}
103105
}
104106

src/Ctct/Components/Contacts/Address.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Address extends Component
8181

8282
/**
8383
* Factory method to create an Address object from an array
84-
* @array $props - Associative array of initial properties to set
84+
* @param array $props - Associative array of initial properties to set
8585
* @return Address
8686
*/
8787
public static function create(array $props)
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?php
2+
namespace Ctct\Components\Library;
3+
4+
use Ctct\Components\Component;
5+
6+
/**
7+
* Represents a single File in a Constant Contact Library
8+
*
9+
* @package Components
10+
* @subpackage Library
11+
* @author Constant Contact
12+
*/
13+
class File extends Component {
14+
/**
15+
* The ID of the file
16+
* @var String
17+
*/
18+
public $id;
19+
20+
/**
21+
* The name of the file
22+
* @var String
23+
*/
24+
public $name;
25+
26+
/**
27+
* The file's description
28+
* @var String
29+
*/
30+
public $description;
31+
32+
/**
33+
* The name of the folder that the file is in
34+
* @var String
35+
*/
36+
public $folder;
37+
38+
/**
39+
* The ID of the folder that the file is in
40+
* @var String
41+
*/
42+
public $folder_id;
43+
44+
/**
45+
* Is this file an image?
46+
* @var Boolean
47+
*/
48+
public $is_image;
49+
50+
/**
51+
* Type of the file, must be one of "JPG", "GIF", "PDF", "PNG", "DOC", "XLS", "PPT", "DOCX", "XLSX", "PPTX"
52+
* @var String
53+
*/
54+
public $type;
55+
56+
/**
57+
* File's height in pixels, if File is an image
58+
* @var int
59+
*/
60+
public $height;
61+
62+
/**
63+
* File's width in pixels, if File is an image
64+
* @var int
65+
*/
66+
public $width;
67+
68+
/**
69+
* File's size in bytes
70+
* @var int
71+
*/
72+
public $size;
73+
74+
/**
75+
* URL of the image hosted by Constant Contact
76+
* @var String
77+
*/
78+
public $url;
79+
80+
/**
81+
* Source of the image, must be one of "ALL", "MY_COMPUTER", "STOCK_IMAGE", "FACEBOOK", "INSTAGRAM", "SHUTTERSTOCK", "MOBILE"
82+
* @var String
83+
*/
84+
public $source;
85+
86+
/**
87+
* Status of the file, must be one of "ACTIVE", "PROCESSING", "UPLOADED", "VIRUS_FOUND", "FAILED", "DELETED"
88+
* @var String
89+
*/
90+
public $status;
91+
92+
/**
93+
* Thumbnail of the file, if File is an image
94+
* @var Thumbnail
95+
*/
96+
public $thumbnail;
97+
98+
/**
99+
* Date the file was created, in ISO-8601 format
100+
* @var String
101+
*/
102+
public $created_date;
103+
104+
/**
105+
* Date the file was last modified, in ISO-8601 format
106+
* @var String
107+
*/
108+
public $modified_date;
109+
110+
public static function create(array $props) {
111+
$file = new File();
112+
113+
$file->id = parent::getValue($props, "id");
114+
$file->name = parent::getValue($props, "name");
115+
$file->description = parent::getValue($props, "description");
116+
$file->folder = parent::getValue($props, "folder");
117+
$file->folder_id = parent::getValue($props, "folder_id");
118+
$file->is_image = parent::getValue($props, "is_image");
119+
$file->type = parent::getValue($props, "file_type");
120+
$file->height = parent::getValue($props, "height");
121+
$file->width = parent::getValue($props, "width");
122+
$file->size = parent::getValue($props, "size");
123+
$file->url = parent::getValue($props, "url");
124+
$file->source = parent::getValue($props, "source");
125+
$file->status = parent::getValue($props, "status");
126+
if (array_key_exists("thumbnail", $props)) {
127+
$file->thumbnail = Thumbnail::create($props['thumbnail']);
128+
}
129+
$file->created_date = parent::getValue($props, "created_date");
130+
$file->modified_date = parent::getValue($props, "modified_date");
131+
132+
return $file;
133+
}
134+
135+
/**
136+
* Create json used for a POST/PUT request, also handles removing attributes that will cause errors if sent
137+
* @return String
138+
*/
139+
public function toJson() {
140+
unset($this->created_date);
141+
unset($this->modified_date);
142+
unset($this->status);
143+
return json_encode($this);
144+
}
145+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
namespace Ctct\Components\Library;
3+
4+
use Ctct\Components\Component;
5+
6+
class Folder extends Component {
7+
/**
8+
* ID of the Folder
9+
* @var String
10+
*/
11+
public $id;
12+
13+
/**
14+
* Name of the Folder
15+
* @var String
16+
*/
17+
public $name;
18+
19+
/**
20+
* Array of Folders that are children of this folder
21+
* @var Folder[]
22+
*/
23+
public $children;
24+
25+
/**
26+
* Number of items in this folder
27+
* @var int
28+
*/
29+
public $item_count;
30+
31+
/**
32+
* ID of this folder's parent, if there is one
33+
* @var String
34+
*/
35+
public $parent_id;
36+
37+
/**
38+
* Depth that this folder is in the hierarchy, must be 1, 2, or 3
39+
* @var int
40+
*/
41+
public $level;
42+
43+
public static function create(array $props) {
44+
$folder = new Folder();
45+
46+
$folder->id = parent::getValue($props, "id");
47+
$folder->name = parent::getValue($props, "name");
48+
foreach ($props['children'] as $child) {
49+
$folder->children[] = Folder::create($child);
50+
}
51+
$folder->item_count = parent::getValue($props, "item_count");
52+
$folder->parent_id = parent::getValue($props, "parent_id");
53+
$folder->level = parent::getValue($props, "level");
54+
55+
return $folder;
56+
}
57+
58+
public function toJson() {
59+
return json_encode($this);
60+
}
61+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
namespace Ctct\Components\Library;
3+
4+
use Ctct\Components\Component;
5+
6+
/**
7+
* Represents a Thumbnail of a File
8+
*
9+
* @package Components
10+
* @subpackage Library
11+
* @author Constant Contact
12+
*/
13+
class Thumbnail extends Component {
14+
/**
15+
* URL to the thumbnail hosted by Constant Contact
16+
* @var String
17+
*/
18+
public $url;
19+
20+
/**
21+
* Width of the thumbnail, in pixels
22+
* @var int
23+
*/
24+
public $width;
25+
26+
/**
27+
* Height of the thumbnail, in pixels
28+
* @var int
29+
*/
30+
public $height;
31+
32+
public static function create(array $props) {
33+
$thumbnail = new Thumbnail();
34+
35+
$thumbnail->url = parent::getValue($props, "url");
36+
$thumbnail->width = parent::getValue($props, "width");
37+
$thumbnail->height = parent::getValue($props, "height");
38+
39+
return $thumbnail;
40+
}
41+
}

0 commit comments

Comments
 (0)