From b4adb449b339d981e0f3894bcc5e95a217a1fdd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Sandoval?= Date: Thu, 12 Oct 2017 19:42:44 -0500 Subject: [PATCH] Added note for creation and list & updated README.md --- README.md | 5 ++++- factories/ContactFactory.php | 9 ++++++++- test_individual.php | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 24133bc..3e6f29d 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ $contact = rapidweb\googlecontacts\factories\ContactFactory::getBySelfURL($selfU echo $contact->name; echo $contact->phoneNumber; echo $contact->email; +echo $contact->content; ``` ### Updating existing Google Contacts @@ -83,6 +84,7 @@ var_dump($contact); $contact->name = 'Test'; $contact->phoneNumber = '07812363789'; $contact->email = 'test@example.com'; +$contact->content = 'Note for example'; $contactAfterUpdate = rapidweb\googlecontacts\factories\ContactFactory::submitUpdates($contact); @@ -97,8 +99,9 @@ Creating a new Google Contact is very easy. Simply call the `ContactFactory::cre $name = "Frodo Baggins"; $phoneNumber = "06439111222"; $emailAddress = "frodo@example.com"; +$note = "Note for example"; -$newContact = rapidweb\googlecontacts\factories\ContactFactory::create($name, $phoneNumber, $emailAddress); +$newContact = rapidweb\googlecontacts\factories\ContactFactory::create($name, $phoneNumber, $emailAddress, $note); ``` ### Config file override diff --git a/factories/ContactFactory.php b/factories/ContactFactory.php index ecef94b..b0c8481 100644 --- a/factories/ContactFactory.php +++ b/factories/ContactFactory.php @@ -27,6 +27,7 @@ public static function getAll($customConfig = NULL) $contactDetails['id'] = (string) $xmlContactsEntry->id; $contactDetails['name'] = (string) $xmlContactsEntry->title; + $contactDetails['content'] = (string) $xmlContactsEntry->content; foreach ($xmlContactsEntry->children() as $key => $value) { $attributes = $value->attributes(); @@ -93,6 +94,7 @@ public static function getBySelfURL($selfURL, $customConfig = NULL) $contactDetails['id'] = (string) $xmlContactsEntry->id; $contactDetails['name'] = (string) $xmlContactsEntry->title; + $contactDetails['content'] = (string) $xmlContactsEntry->content; foreach ($xmlContactsEntry->children() as $key => $value) { $attributes = $value->attributes(); @@ -187,6 +189,7 @@ public static function submitUpdates(Contact $updatedContact, $customConfig = NU $contactDetails['id'] = (string) $xmlContactsEntry->id; $contactDetails['name'] = (string) $xmlContactsEntry->title; + $contactDetails['content'] = (string) $xmlContactsEntry->content; foreach ($xmlContactsEntry->children() as $key => $value) { $attributes = $value->attributes(); @@ -215,7 +218,7 @@ public static function submitUpdates(Contact $updatedContact, $customConfig = NU return new Contact($contactDetails); } - public static function create($name, $phoneNumber, $emailAddress, $customConfig = NULL) + public static function create($name, $phoneNumber, $emailAddress, $note, $customConfig = NULL) { $doc = new \DOMDocument(); $doc->formatOutput = true; @@ -237,6 +240,10 @@ public static function create($name, $phoneNumber, $emailAddress, $customConfig $contact->setAttribute('rel', 'http://schemas.google.com/g/2005#work'); $entry->appendChild($contact); + $note = $doc->createElement('atom:content', $note); + $note->setAttribute('rel', 'http://schemas.google.com/g/2005#kind'); + $entry->appendChild($note); + $xmlToSend = $doc->saveXML(); $client = GoogleHelper::getClient($customConfig); diff --git a/test_individual.php b/test_individual.php index ce94d96..59cf746 100644 --- a/test_individual.php +++ b/test_individual.php @@ -15,6 +15,7 @@ $contact->name = 'Test'; $contact->phoneNumber = '07812363789'; $contact->email = 'test@example.com'; +$contact->content = 'Note for example'; $contactAfterUpdate = ContactFactory::submitUpdates($contact);