Skip to content

Commit

Permalink
#16: documentation for new contact info updates for users
Browse files Browse the repository at this point in the history
  • Loading branch information
ctgraham committed Nov 16, 2020
1 parent e4a4c1e commit 0cab0b1
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ foreach ($bib->representations as $rep) {

## Users, loans, fees and requests

**Note**: Editing is not yet implemented.
**Note**: Editing is not fully implemented.

### Search

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

### Contact Info Updates

#### Update an address

Example:

```php
$uerr = $alma->users->get('EXTID_123456');
$user->contactInfo->unsetPreferredAddress();
$addresses = $user->contactInfo->getAddresses();
$campusBox = 'Box 876';
$changed = false;
foreach ($addresses as $address) {
if ($address->address_type[0]->value === 'school') {
$address->line1 = $campusBox;
$address->preferred = true;
$changed = true;
break;
}
}
if (!$changed) {
$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" } ] }');
$user->contactInfo->addAddress($new);
}
$user->save();
```

#### Add an SMS number

Example:

```php
$user = $alma->users->get('EXTID_123456');
$user->contactInfo->setSmsSNumber('18005882300');
$user->save();
```

#### Change an email

Example:

```php
$user = $alma->users->get('EXTID_123456');
$user->contactInfo->removeEmail('[email protected]');
$user->contactInfo->addEmail('[email protected]');
$user->save();
```

### Loans

Example:
Expand Down

0 comments on commit 0cab0b1

Please sign in to comment.