Permalink
Browse files

implemented contact->create()

  • Loading branch information...
1 parent 9bba030 commit b66cd6dbafcc4173f7463eb2d89953eb1dd183c2 @caseysoftware committed Mar 2, 2013
Showing with 10 additions and 13 deletions.
  1. +3 −1 README.md
  2. +3 −7 Services/Contactually/Contact.php
  3. +4 −5 examples/contacts-create.php
View
4 README.md
@@ -38,7 +38,7 @@ While the functional difference between these approaches is negligible, the key-
* ~~Implement search (GET) for Contacts~~
* ~~Implement current (GET) for Users~~
* Implement destroy (DELETE) for Accounts, ~~Buckets, ContactHistories, Contacts, Notes, Tasks~~
-* Implement create (POST) for Accounts, ~~Buckets~~, Contacts, ContactHistories, Followups, ~~Notes~~, Signup, Tasks
+* Implement create (POST) for Accounts, ~~Buckets~~, ~~Contacts~~, ContactHistories, Followups, ~~Notes~~, Signup, Tasks
* ~~Implement complete (POST) for Tasks~~
* ~~Implement bucket (POST) for Contacts~~
* Implement ignore (POST) for ~~Contacts~~, Tasks
@@ -54,6 +54,8 @@ These oddities are related to the API:
* When you authenticate, you get back a 201 response code instead of 200 as you'd expect
* When you ignore a contact, you get back a 404 response code no matter what.. whether if it was successfully created or the contact didn't exist
* There doesn't seem to be a way to remove the results of a Contact->ignore()
+ * After you create a resource, you don't get a reference back to it in the response body or the Location header as you'd expect. In order to find the resource, you must search for it
+ * Sometimes when you create a resource, you get back a 201 (Buckets) and sometimes you get back a 200 (Contacts)
These oddities are related to my implementation of the helper library:
View
10 Services/Contactually/Contact.php
@@ -5,6 +5,7 @@ class Services_Contactually_Contact extends Services_Contactually_Resources_Base
public $id = '';
public $first_name = '';
public $last_name = '';
+ public $email = '';
public $title = '';
public $company = '';
public $visible = '';
@@ -13,20 +14,15 @@ class Services_Contactually_Contact extends Services_Contactually_Resources_Base
public $last_contacted = '';
public $hits = '';
public $user_bucket_id = '';
- public $address = '';
- public $phone = '';
protected $_show_uri = 'https://www.contactually.com/api/v1/contacts/<id>.json';
+
+ protected $_resource = 'contact';
protected $_create_uri = 'https://www.contactually.com/api/v1/contacts.json';
protected $_delete_uri = 'https://www.contactually.com/api/v1/contacts/<id>.json';
protected $_bucket_uri = 'https://www.contactually.com/api/v1/contacts/<id>/bucket.json';
protected $_ignore_uri = 'https://www.contactually.com/api/v1/contacts/<id>/ignore.json';
- public function create(array $params)
- {
- throw new Services_Contactually_Exception_NotImplemented("This method is not implemented");
- }
-
public function bucket($contact_id, $bucket_id)
{
$this->bucket = str_replace('<id>', $contact_id, $this->_bucket_uri);
View
9 examples/contacts-create.php
@@ -8,19 +8,18 @@
$contact = new Services_Contactually_Contact($client);
$params = array(
- 'first_name' => 'aaFirstName',
- 'last_name' => 'astName',
+ 'first_name' => 'Bruce',
+ 'last_name' => 'Wayne',
+ 'email' => 'definitely.not.batman@example.com',
'title' => 'Sir',
'company' => 'Wayne Enterprises',
'visible' => 1,
'first_contacted' => '2012-10-21T00:22:24Z',
'last_contacted' => '2012-10-21T00:22:24Z',
'hits' => 1,
'user_bucket_id' => '53000',
- //'address' => '123 Fake Street Gotham City',
- //'phone' => '5125551212',
);
$result = $contact->create($params);
-print_r($result);
+print_r($client);

0 comments on commit b66cd6d

Please sign in to comment.