Class: Zendesk2::UserIdentity
- Inherits:
-
Object
- Object
- Zendesk2::UserIdentity
- Extended by:
- Attributes
- Includes:
- Model
- Defined in:
- lib/zendesk2/user_identity.rb
Instance Attribute Summary
Attributes included from Model
Instance Method Summary collapse
-
#created_at ⇒ Time
The time the identity got created.
- #destroy! ⇒ Object
-
#id ⇒ Integer
Automatically assigned upon creation.
-
#primary ⇒ Boolean
Is true of the primary identity of the user.
- #primary! ⇒ Object
- #reload ⇒ Object
- #save! ⇒ Object
-
#type ⇒ String
One of “email”, “twitter”, “facebook”, “google”, or “phone_number”.
-
#updated_at ⇒ Time
The time the identity got updated.
-
#url ⇒ String
The API url of this identity.
-
#user_id ⇒ Integer
The id of the user.
-
#value ⇒ String
The identifier for this identity, e.g.
-
#verified ⇒ Boolean
Is true of the identity has gone through verification.
Methods included from Attributes
assoc_accessor, assoc_reader, assoc_writer
Methods included from Model
#destroy, #destroyed?, #missing_attributes, #save, #update!
Instance Method Details
#created_at ⇒ Time
Returns The time the identity got created.
11 |
# File 'lib/zendesk2/user_identity.rb', line 11 attribute :created_at, type: :time |
#destroy! ⇒ Object
41 42 43 44 45 |
# File 'lib/zendesk2/user_identity.rb', line 41 def destroy! requires :identity cistern.destroy_user_identity('user_identity' => { 'user_id' => user_id, 'id' => identity }) end |
#id ⇒ Integer
Returns Automatically assigned upon creation.
8 |
# File 'lib/zendesk2/user_identity.rb', line 8 identity :id, type: :integer |
#primary ⇒ Boolean
Returns Is true of the primary identity of the user.
13 |
# File 'lib/zendesk2/user_identity.rb', line 13 attribute :primary, type: :boolean |
#primary! ⇒ Object
58 59 60 61 |
# File 'lib/zendesk2/user_identity.rb', line 58 def primary! cistern.mark_user_identity_primary('user_identity' => { 'user_id' => user_id, 'id' => identity }) self.primary = true end |
#reload ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/zendesk2/user_identity.rb', line 47 def reload requires :identity model = cistern.user_identities('user_id' => user_id).get(identity) return false unless model merge_attributes(model.attributes) self end |
#save! ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/zendesk2/user_identity.rb', line 27 def save! data = if new_record? requires :type, :value, :user_id cistern.create_user_identity('user_identity' => attributes) else requires :identity cistern.update_user_identity('user_identity' => attributes) end.body['identity'] merge_attributes(data) end |
#type ⇒ String
Returns One of “email”, “twitter”, “facebook”, “google”, or “phone_number”.
15 |
# File 'lib/zendesk2/user_identity.rb', line 15 attribute :type, type: :string |
#updated_at ⇒ Time
Returns The time the identity got updated.
17 |
# File 'lib/zendesk2/user_identity.rb', line 17 attribute :updated_at, type: :time |
#url ⇒ String
Returns The API url of this identity.
19 |
# File 'lib/zendesk2/user_identity.rb', line 19 attribute :url, type: :string |
#user_id ⇒ Integer
Returns The id of the user.
21 |
# File 'lib/zendesk2/user_identity.rb', line 21 attribute :user_id, type: :integer |
#value ⇒ String
Returns The identifier for this identity, e.g. an email address.
23 |
# File 'lib/zendesk2/user_identity.rb', line 23 attribute :value, type: :string |
#verified ⇒ Boolean
Returns Is true of the identity has gone through verification.
25 |
# File 'lib/zendesk2/user_identity.rb', line 25 attribute :verified, type: :boolean |