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

Commit

Permalink
Merge pull request #85 from constantcontact/development
Browse files Browse the repository at this point in the history
Promote dev to master
  • Loading branch information
WoogieNoogie committed Jan 14, 2015
2 parents 1b8f6af + 98fb72f commit e35be1c
Show file tree
Hide file tree
Showing 19 changed files with 618 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -17,7 +17,7 @@ Composer is a dependency management tool for PHP that allows you to declare the
```javascript
{
"require": {
"constantcontact/constantcontact": "1.1.*"
"constantcontact/constantcontact": "1.3.*"
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions examples/addOrUpdateContact.php
Expand Up @@ -62,7 +62,7 @@
*
* See: http://developer.constantcontact.com/docs/contacts-api/contacts-index.html#opt_in
*/
$returnContact = $cc->addContact(ACCESS_TOKEN, $contact, false);
$returnContact = $cc->addContact(ACCESS_TOKEN, $contact, true);

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

// catch any exceptions thrown during the process and print the errors to screen
Expand Down Expand Up @@ -150,4 +150,4 @@
} ?>

</body>
</html>
</html>
4 changes: 2 additions & 2 deletions src/Ctct/Auth/CtctOAuth2.php
Expand Up @@ -47,7 +47,7 @@ public function getAuthorizationUrl($server = true, $state = null)
}

$url = Config::get('auth.base_url') . Config::get('auth.authorization_endpoint');
return $url . '?' . http_build_query($params);
return $url . '?' . http_build_query($params, '', '&');
}

/**
Expand All @@ -66,7 +66,7 @@ public function getAccessToken($code)
'redirect_uri' => $this->redirectUri
);

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

$response = $this->restClient->post($url);
$responseBody = json_decode($response->body, true);
Expand Down
16 changes: 13 additions & 3 deletions src/Ctct/Components/Account/AccountInfo.php
Expand Up @@ -45,16 +45,21 @@ class AccountInfo extends Component
/**
* Email address associated with the account
* @var string
* NOTE: the API returns 'email' field instead of 'email_address', but 'email_address' is used elsewhere
*/
public $email_address;
public $email;

/**
* Phone number associated with the account
* @var string
*/
public $phone;

/**
* URL of the company logo associated with the account
* @var string
*/
public $company_logo;

/**
* Country code associated with the account
* @var string
Expand Down Expand Up @@ -86,12 +91,17 @@ public static function create(array $props)
$accountInfo->time_zone = parent::getValue($props, "time_zone");
$accountInfo->first_name = parent::getValue($props, "first_name");
$accountInfo->last_name = parent::getValue($props, "last_name");
$accountInfo->email_address = parent::getValue($props, "email");
$accountInfo->email = parent::getValue($props, "email");
$accountInfo->phone = parent::getValue($props, "phone");
$accountInfo->company_logo = parent::getValue($props, "company_logo");
$accountInfo->country_code = parent::getValue($props, "country_code");
$accountInfo->state_code = parent::getValue($props, "state_code");
$accountInfo->organization_addresses = parent::getValue($props, "organization_addresses");

return $accountInfo;
}

public function toJson() {
return json_encode($this);
}
}
4 changes: 4 additions & 0 deletions src/Ctct/Components/Account/VerifiedEmailAddress.php
Expand Up @@ -36,4 +36,8 @@ public static function create(array $props)
$verifiedAddress->status = parent::getValue($props, "status");
return $verifiedAddress;
}

public function toJson() {
return json_encode($this);
}
}
2 changes: 2 additions & 0 deletions src/Ctct/Components/Activities/AddContacts.php
Expand Up @@ -99,6 +99,8 @@ public function __construct(Array $contacts, Array $lists, Array $columnNames =
}
}
$this->column_names = $usedColumns;
} else {
$this->column_names = $columnNames;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ctct/Components/Contacts/Address.php
Expand Up @@ -81,7 +81,7 @@ class Address extends Component

/**
* Factory method to create an Address object from an array
* @array $props - Associative array of initial properties to set
* @param array $props - Associative array of initial properties to set
* @return Address
*/
public static function create(array $props)
Expand Down
145 changes: 145 additions & 0 deletions src/Ctct/Components/Library/File.php
@@ -0,0 +1,145 @@
<?php
namespace Ctct\Components\Library;

use Ctct\Components\Component;

/**
* Represents a single File in a Constant Contact Library
*
* @package Components
* @subpackage Library
* @author Constant Contact
*/
class File extends Component {
/**
* The ID of the file
* @var String
*/
public $id;

/**
* The name of the file
* @var String
*/
public $name;

/**
* The file's description
* @var String
*/
public $description;

/**
* The name of the folder that the file is in
* @var String
*/
public $folder;

/**
* The ID of the folder that the file is in
* @var String
*/
public $folder_id;

/**
* Is this file an image?
* @var Boolean
*/
public $is_image;

/**
* Type of the file, must be one of "JPG", "GIF", "PDF", "PNG", "DOC", "XLS", "PPT", "DOCX", "XLSX", "PPTX"
* @var String
*/
public $type;

/**
* File's height in pixels, if File is an image
* @var int
*/
public $height;

/**
* File's width in pixels, if File is an image
* @var int
*/
public $width;

/**
* File's size in bytes
* @var int
*/
public $size;

/**
* URL of the image hosted by Constant Contact
* @var String
*/
public $url;

/**
* Source of the image, must be one of "ALL", "MY_COMPUTER", "STOCK_IMAGE", "FACEBOOK", "INSTAGRAM", "SHUTTERSTOCK", "MOBILE"
* @var String
*/
public $source;

/**
* Status of the file, must be one of "ACTIVE", "PROCESSING", "UPLOADED", "VIRUS_FOUND", "FAILED", "DELETED"
* @var String
*/
public $status;

/**
* Thumbnail of the file, if File is an image
* @var Thumbnail
*/
public $thumbnail;

/**
* Date the file was created, in ISO-8601 format
* @var String
*/
public $created_date;

/**
* Date the file was last modified, in ISO-8601 format
* @var String
*/
public $modified_date;

public static function create(array $props) {
$file = new File();

$file->id = parent::getValue($props, "id");
$file->name = parent::getValue($props, "name");
$file->description = parent::getValue($props, "description");
$file->folder = parent::getValue($props, "folder");
$file->folder_id = parent::getValue($props, "folder_id");
$file->is_image = parent::getValue($props, "is_image");
$file->type = parent::getValue($props, "file_type");
$file->height = parent::getValue($props, "height");
$file->width = parent::getValue($props, "width");
$file->size = parent::getValue($props, "size");
$file->url = parent::getValue($props, "url");
$file->source = parent::getValue($props, "source");
$file->status = parent::getValue($props, "status");
if (array_key_exists("thumbnail", $props)) {
$file->thumbnail = Thumbnail::create($props['thumbnail']);
}
$file->created_date = parent::getValue($props, "created_date");
$file->modified_date = parent::getValue($props, "modified_date");

return $file;
}

/**
* Create json used for a POST/PUT request, also handles removing attributes that will cause errors if sent
* @return String
*/
public function toJson() {
unset($this->created_date);
unset($this->modified_date);
unset($this->status);
return json_encode($this);
}
}
61 changes: 61 additions & 0 deletions src/Ctct/Components/Library/Folder.php
@@ -0,0 +1,61 @@
<?php
namespace Ctct\Components\Library;

use Ctct\Components\Component;

class Folder extends Component {
/**
* ID of the Folder
* @var String
*/
public $id;

/**
* Name of the Folder
* @var String
*/
public $name;

/**
* Array of Folders that are children of this folder
* @var Folder[]
*/
public $children;

/**
* Number of items in this folder
* @var int
*/
public $item_count;

/**
* ID of this folder's parent, if there is one
* @var String
*/
public $parent_id;

/**
* Depth that this folder is in the hierarchy, must be 1, 2, or 3
* @var int
*/
public $level;

public static function create(array $props) {
$folder = new Folder();

$folder->id = parent::getValue($props, "id");
$folder->name = parent::getValue($props, "name");
foreach ($props['children'] as $child) {
$folder->children[] = Folder::create($child);
}
$folder->item_count = parent::getValue($props, "item_count");
$folder->parent_id = parent::getValue($props, "parent_id");
$folder->level = parent::getValue($props, "level");

return $folder;
}

public function toJson() {
return json_encode($this);
}
}
41 changes: 41 additions & 0 deletions src/Ctct/Components/Library/Thumbnail.php
@@ -0,0 +1,41 @@
<?php
namespace Ctct\Components\Library;

use Ctct\Components\Component;

/**
* Represents a Thumbnail of a File
*
* @package Components
* @subpackage Library
* @author Constant Contact
*/
class Thumbnail extends Component {
/**
* URL to the thumbnail hosted by Constant Contact
* @var String
*/
public $url;

/**
* Width of the thumbnail, in pixels
* @var int
*/
public $width;

/**
* Height of the thumbnail, in pixels
* @var int
*/
public $height;

public static function create(array $props) {
$thumbnail = new Thumbnail();

$thumbnail->url = parent::getValue($props, "url");
$thumbnail->width = parent::getValue($props, "width");
$thumbnail->height = parent::getValue($props, "height");

return $thumbnail;
}
}

0 comments on commit e35be1c

Please sign in to comment.