Skip to content

Commit 5efb7ed

Browse files
authored
Merge pull request #47 from resand/master
Added note for creation and list & updated README.md
2 parents 880971b + b4adb44 commit 5efb7ed

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ $contact = rapidweb\googlecontacts\factories\ContactFactory::getBySelfURL($selfU
6363
echo $contact->name;
6464
echo $contact->phoneNumber;
6565
echo $contact->email;
66+
echo $contact->content;
6667
```
6768

6869
### Updating existing Google Contacts
@@ -83,6 +84,7 @@ var_dump($contact);
8384
$contact->name = 'Test';
8485
$contact->phoneNumber = '07812363789';
8586
$contact->email = '[email protected]';
87+
$contact->content = 'Note for example';
8688

8789
$contactAfterUpdate = rapidweb\googlecontacts\factories\ContactFactory::submitUpdates($contact);
8890

@@ -97,8 +99,9 @@ Creating a new Google Contact is very easy. Simply call the `ContactFactory::cre
9799
$name = "Frodo Baggins";
98100
$phoneNumber = "06439111222";
99101
$emailAddress = "[email protected]";
102+
$note = "Note for example";
100103

101-
$newContact = rapidweb\googlecontacts\factories\ContactFactory::create($name, $phoneNumber, $emailAddress);
104+
$newContact = rapidweb\googlecontacts\factories\ContactFactory::create($name, $phoneNumber, $emailAddress, $note);
102105
```
103106

104107
### Config file override

factories/ContactFactory.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static function getAll($customConfig = NULL)
2727

2828
$contactDetails['id'] = (string) $xmlContactsEntry->id;
2929
$contactDetails['name'] = (string) $xmlContactsEntry->title;
30+
$contactDetails['content'] = (string) $xmlContactsEntry->content;
3031

3132
foreach ($xmlContactsEntry->children() as $key => $value) {
3233
$attributes = $value->attributes();
@@ -93,6 +94,7 @@ public static function getBySelfURL($selfURL, $customConfig = NULL)
9394

9495
$contactDetails['id'] = (string) $xmlContactsEntry->id;
9596
$contactDetails['name'] = (string) $xmlContactsEntry->title;
97+
$contactDetails['content'] = (string) $xmlContactsEntry->content;
9698

9799
foreach ($xmlContactsEntry->children() as $key => $value) {
98100
$attributes = $value->attributes();
@@ -187,6 +189,7 @@ public static function submitUpdates(Contact $updatedContact, $customConfig = NU
187189

188190
$contactDetails['id'] = (string) $xmlContactsEntry->id;
189191
$contactDetails['name'] = (string) $xmlContactsEntry->title;
192+
$contactDetails['content'] = (string) $xmlContactsEntry->content;
190193

191194
foreach ($xmlContactsEntry->children() as $key => $value) {
192195
$attributes = $value->attributes();
@@ -215,7 +218,7 @@ public static function submitUpdates(Contact $updatedContact, $customConfig = NU
215218
return new Contact($contactDetails);
216219
}
217220

218-
public static function create($name, $phoneNumber, $emailAddress, $customConfig = NULL)
221+
public static function create($name, $phoneNumber, $emailAddress, $note, $customConfig = NULL)
219222
{
220223
$doc = new \DOMDocument();
221224
$doc->formatOutput = true;
@@ -237,6 +240,10 @@ public static function create($name, $phoneNumber, $emailAddress, $customConfig
237240
$contact->setAttribute('rel', 'http://schemas.google.com/g/2005#work');
238241
$entry->appendChild($contact);
239242

243+
$note = $doc->createElement('atom:content', $note);
244+
$note->setAttribute('rel', 'http://schemas.google.com/g/2005#kind');
245+
$entry->appendChild($note);
246+
240247
$xmlToSend = $doc->saveXML();
241248

242249
$client = GoogleHelper::getClient($customConfig);

test_individual.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
$contact->name = 'Test';
1616
$contact->phoneNumber = '07812363789';
1717
$contact->email = '[email protected]';
18+
$contact->content = 'Note for example';
1819

1920
$contactAfterUpdate = ContactFactory::submitUpdates($contact);
2021

0 commit comments

Comments
 (0)