Skip to content

Commit 911ff90

Browse files
committed
Adds docs for user identities
1 parent 840bde9 commit 911ff90

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,79 @@ owner.blocks.find(blocked).destroy
293293
# => true
294294
```
295295

296+
#### Creating a User Identity
297+
298+
```ruby
299+
identity = {
300+
display_name: "Frodo the Dodo",
301+
avatar_url: "http://sillylordoftheringspictures.com/frodo-riding-a-dodo.png",
302+
first_name: "Frodo",
303+
last_name: "Baggins",
304+
phone_number: "13791379137",
305+
email_address: "frodo@sillylordoftheringspictures.com",
306+
metadata: {
307+
level: "35",
308+
race: "Dodo"
309+
}
310+
}
311+
312+
user = platform.users.find("user_id")
313+
user.create_identity(identity)
314+
# => true
315+
316+
```
317+
318+
#### Retrieving a User's Identity
319+
320+
```ruby
321+
user = platform.users.find("user_id")
322+
user.identity
323+
# => {"first_name"=>"Frodo", "phone_number"=>"13791379137", "email_address"=>"frodo@sillylordoftheringspictures.com", "display_name"=>"Frodo the Dodo", "user_id"=>"jake", "last_name"=>"Baggins", "metadata"=>{"race"=>"Dodo", "level"=>"35"}, "avatar_url"=>"http://sillylordoftheringspictures.com/frodo-riding-a-dodo.png"}
324+
```
325+
326+
#### Updating an Identity
327+
328+
```ruby
329+
operations = [
330+
{ operation: "set", property: "last_name", value: "Dodo" },
331+
{ operation: "set", property: "phone_number", value: "" },
332+
{ operation: "set", property: "metadata.level", value: "2" }
333+
]
334+
335+
user.update_identity(operations)
336+
# => true
337+
```
338+
339+
#### Replacing an identity
340+
341+
```ruby
342+
identity = {
343+
display_name: "Frodo the Dodo",
344+
avatar_url: "http://sillylordoftheringspictures.com/frodo-riding-a-dodo.png",
345+
first_name: "Frodo",
346+
last_name: "Baggins",
347+
phone_number: "13791379137",
348+
email_address: "frodo@sillylordoftheringspictures.com",
349+
metadata: {
350+
level: "35",
351+
race: "Dodo"
352+
}
353+
}
354+
355+
user.replace_identity(identity)
356+
# => true
357+
358+
```
359+
360+
#### Deleting a User's Identity
361+
362+
```ruby
363+
user = platform.users.find("user_id")
364+
user.destroy_identity
365+
# => true
366+
```
367+
368+
296369
#### Generating Identity Tokens ####
297370
See: [the official authentication guide](https://developer.layer.com/docs/android/guides#authentication)
298371

0 commit comments

Comments
 (0)