Skip to content

Commit 0cab0b1

Browse files
committed
#16: documentation for new contact info updates for users
1 parent e4a4c1e commit 0cab0b1

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ foreach ($bib->representations as $rep) {
329329

330330
## Users, loans, fees and requests
331331

332-
**Note**: Editing is not yet implemented.
332+
**Note**: Editing is not fully implemented.
333333

334334
### Search
335335

@@ -341,6 +341,54 @@ foreach ($alma->users->search('last_name~Heggø AND first_name~Dan') as $user) {
341341
}
342342
```
343343

344+
### Contact Info Updates
345+
346+
#### Update an address
347+
348+
Example:
349+
350+
```php
351+
$uerr = $alma->users->get('EXTID_123456');
352+
$user->contactInfo->unsetPreferredAddress();
353+
$addresses = $user->contactInfo->getAddresses();
354+
$campusBox = 'Box 876';
355+
$changed = false;
356+
foreach ($addresses as $address) {
357+
if ($address->address_type[0]->value === 'school') {
358+
$address->line1 = $campusBox;
359+
$address->preferred = true;
360+
$changed = true;
361+
break;
362+
}
363+
}
364+
if (!$changed) {
365+
$new = json_decode('{ "preferred": true, "segment_type": "Internal", "line1": "My University", "line2": ".$campusBox.", "city": "Scottsdale", "state_province": "AZ", "postal_code": "85054", "country": { "value": "USA" }, "address_note": "string", "start_date": "2020-07-20", "end_date": "2021-07-20", "address_type": [ { "value": "school" } ] }');
366+
$user->contactInfo->addAddress($new);
367+
}
368+
$user->save();
369+
```
370+
371+
#### Add an SMS number
372+
373+
Example:
374+
375+
```php
376+
$user = $alma->users->get('EXTID_123456');
377+
$user->contactInfo->setSmsSNumber('18005882300');
378+
$user->save();
379+
```
380+
381+
#### Change an email
382+
383+
Example:
384+
385+
```php
386+
$user = $alma->users->get('EXTID_123456');
387+
$user->contactInfo->removeEmail('[email protected]');
388+
$user->contactInfo->addEmail('[email protected]');
389+
$user->save();
390+
```
391+
344392
### Loans
345393

346394
Example:

0 commit comments

Comments
 (0)