Class: Zendesk2::UserIdentity

Inherits:
Object
  • Object
show all
Extended by:
Attributes
Includes:
Model
Defined in:
lib/zendesk2/user_identity.rb

Instance Attribute Summary

Attributes included from Model

#errors

Instance Method Summary collapse

Methods included from Attributes

assoc_accessor, assoc_reader, assoc_writer

Methods included from Model

#destroy, #destroyed?, #missing_attributes, #save, #update!

Instance Method Details

#created_atTime

Returns The time the identity got created.

Returns:

  • (Time)

    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

#idInteger

Returns Automatically assigned upon creation.

Returns:

  • (Integer)

    Automatically assigned upon creation



8
# File 'lib/zendesk2/user_identity.rb', line 8

identity :id, type: :integer

#primaryBoolean

Returns Is true of the primary identity of the user.

Returns:

  • (Boolean)

    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

#reloadObject



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

#typeString

Returns One of “email”, “twitter”, “facebook”, “google”, or “phone_number”.

Returns:

  • (String)

    One of “email”, “twitter”, “facebook”, “google”, or “phone_number”



15
# File 'lib/zendesk2/user_identity.rb', line 15

attribute :type, type: :string

#updated_atTime

Returns The time the identity got updated.

Returns:

  • (Time)

    The time the identity got updated



17
# File 'lib/zendesk2/user_identity.rb', line 17

attribute :updated_at, type: :time

#urlString

Returns The API url of this identity.

Returns:

  • (String)

    The API url of this identity



19
# File 'lib/zendesk2/user_identity.rb', line 19

attribute :url, type: :string

#user_idInteger

Returns The id of the user.

Returns:

  • (Integer)

    The id of the user



21
# File 'lib/zendesk2/user_identity.rb', line 21

attribute :user_id, type: :integer

#valueString

Returns The identifier for this identity, e.g. an email address.

Returns:

  • (String)

    The identifier for this identity, e.g. an email address



23
# File 'lib/zendesk2/user_identity.rb', line 23

attribute :value, type: :string

#verifiedBoolean

Returns Is true of the identity has gone through verification.

Returns:

  • (Boolean)

    Is true of the identity has gone through verification



25
# File 'lib/zendesk2/user_identity.rb', line 25

attribute :verified, type: :boolean