Class: Zendesk2::User
- Inherits:
-
Object
- Object
- Zendesk2::User
- Extended by:
- Attributes
- Includes:
- Model
- Defined in:
- lib/zendesk2/user.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
Instance Method Summary collapse
-
#active ⇒ Boolean
Users that have been deleted will have the value false here.
-
#alias ⇒ String
Agents can have an alias that is displayed to end-users.
-
#ccd_tickets ⇒ Zendesk2::Tickets
Tickets this user is CC’d.
-
#created_at ⇒ Time
The time the user was created.
-
#custom_role_id ⇒ Integer
A custom role on the user if the user is an agent on the entreprise plan.
- #destroy! ⇒ Object
- #destroyed? ⇒ Boolean
-
#details ⇒ String
In this field you can store any details obout the user.
-
#email ⇒ String
The primary email address of this user.
-
#external_id ⇒ String
A unique id you can set on a user.
-
#id ⇒ Integer
Automatically assigned when creating users.
-
#identities ⇒ Zendesk2::UserIdentities
The identities of this user.
-
#jwt_login_url(options = {}) ⇒ String
Cargo-culted from: github.com/zendesk/zendesk_jwt_sso_examples/blob/master/ruby_on_rails_jwt.rb.
-
#last_login_at ⇒ Time
A time-stamp of the last time this user logged in to Zendesk.
-
#locale_id ⇒ Integer
The language identifier for this user.
-
#login_url(timestamp, options = {}) ⇒ String
Using this method requires you to implement the additional (user-defined) /handshake endpoint.
-
#memberships ⇒ Zendesk2::Memberships
The organization memberships of this user.
-
#moderator ⇒ Boolean
Designates whether this user has forum moderation capabilities.
-
#name ⇒ String
The name of the user.
-
#notes ⇒ String
In this field you can store any notes you have about the user.
-
#only_private_comments ⇒ Boolean
True if this user only can create private comments.
-
#organization_id ⇒ Integer
The id of the organization this user is associated with.
-
#organizations ⇒ Zendesk2::Organizations
The organizations of this user through memberships.
-
#phone ⇒ String
The primary phone number of this user.
-
#photo ⇒ Attachment
The user’s profile picture represented as an Attachment object.
-
#posts ⇒ Zendesk2::HelpCenter::Post
Authored posts.
-
#role ⇒ String
The role of the user.
- #save! ⇒ Object
-
#shared ⇒ Boolean
If this user is shared from a different Zendesk, ticket sharing accounts only.
-
#signature ⇒ String
The signature of this user.
-
#subscriptions ⇒ Zendesk2::HelpCenter::Subscriptions
Subscriptions.
-
#suspended ⇒ Boolean
Tickets from suspended users are also suspended, and these users cannot log in to the end-user portal.
-
#tags ⇒ Array
The tags of the user.
-
#ticket_restriction ⇒ String
Specified which tickets this user has access to.
-
#tickets ⇒ Zendesk2::Tickets
(also: #requested_tickets)
Tickets this user requested.
-
#time_zone ⇒ String
The time-zone of this user.
-
#updated_at ⇒ Time
The time of the last update of the user.
-
#url ⇒ String
The API url of this user.
-
#user_fields ⇒ Hash
Custom fields for the user.
-
#verified ⇒ Boolean
Zendesk has verified that this user is who he says he is.
Methods included from Attributes
assoc_accessor, assoc_reader, assoc_writer
Methods included from Model
#destroy, #missing_attributes, #save, #update!
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
69 70 71 |
# File 'lib/zendesk2/user.rb', line 69 def errors @errors end |
Instance Method Details
#active ⇒ Boolean
Returns Users that have been deleted will have the value false here.
11 |
# File 'lib/zendesk2/user.rb', line 11 attribute :active, type: :boolean |
#alias ⇒ String
Returns Agents can have an alias that is displayed to end-users.
13 |
# File 'lib/zendesk2/user.rb', line 13 attribute :alias, type: :string |
#ccd_tickets ⇒ Zendesk2::Tickets
Returns tickets this user is CC’d.
172 173 174 175 176 |
# File 'lib/zendesk2/user.rb', line 172 def ccd_tickets requires :identity cistern.tickets(collaborator_id: identity) end |
#created_at ⇒ Time
Returns The time the user was created.
15 |
# File 'lib/zendesk2/user.rb', line 15 attribute :created_at, type: :time |
#custom_role_id ⇒ Integer
Returns A custom role on the user if the user is an agent on the entreprise plan.
17 |
# File 'lib/zendesk2/user.rb', line 17 attribute :custom_role_id, type: :integer |
#destroy! ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/zendesk2/user.rb', line 86 def destroy! requires :identity raise "don't nuke yourself" if email == cistern.username merge_attributes( cistern.destroy_user('user' => { 'id' => identity }).body['user'] ) end |
#destroyed? ⇒ Boolean
96 97 98 |
# File 'lib/zendesk2/user.rb', line 96 def destroyed? !reload || !active end |
#details ⇒ String
Returns In this field you can store any details obout the user. e.g. the address.
19 |
# File 'lib/zendesk2/user.rb', line 19 attribute :details, type: :string |
#email ⇒ String
Returns The primary email address of this user.
21 |
# File 'lib/zendesk2/user.rb', line 21 attribute :email, type: :string |
#external_id ⇒ String
Returns A unique id you can set on a user.
23 |
# File 'lib/zendesk2/user.rb', line 23 attribute :external_id, type: :string |
#id ⇒ Integer
Returns Automatically assigned when creating users.
8 |
# File 'lib/zendesk2/user.rb', line 8 identity :id, type: :integer |
#identities ⇒ Zendesk2::UserIdentities
Returns the identities of this user.
25 |
# File 'lib/zendesk2/user.rb', line 25 attribute :identities, type: :array |
#jwt_login_url(options = {}) ⇒ String
Cargo-culted from: github.com/zendesk/zendesk_jwt_sso_examples/blob/master/ruby_on_rails_jwt.rb
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/zendesk2/user.rb', line 135 def jwt_login_url( = {}) requires :name, :email return_to = [:return_to] jwt_token = cistern.jwt_token || [:jwt_token] uri = URI.parse(cistern.url) uri.path = '/access/jwt' iat = Time.now.to_i jti = "#{iat}/#{rand(36**64).to_s(36)}" payload = JWT.encode({ iat: iat, # Seconds since epoch, determine when this token is stale jti: jti, # Unique token id, helps prevent replay attacks name: name, email: email, }, jwt_token) query_values = { 'jwt' => payload, } query_values['return_to'] = return_to unless Zendesk2.blank?(return_to) uri.query = Faraday::NestedParamsEncoder.encode(query_values) uri.to_s end |
#last_login_at ⇒ Time
Returns A time-stamp of the last time this user logged in to Zendesk.
27 |
# File 'lib/zendesk2/user.rb', line 27 attribute :last_login_at, type: :time |
#locale_id ⇒ Integer
Returns The language identifier for this user.
29 |
# File 'lib/zendesk2/user.rb', line 29 attribute :locale_id, type: :integer |
#login_url(timestamp, options = {}) ⇒ String
Using this method requires you to implement the additional (user-defined) /handshake endpoint
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/zendesk2/user.rb', line 105 def login_url(, = {}) requires :name, :email return_to = [:return_to] token = cistern.token || [:token] uri = URI.parse(cistern.url) uri.path = '/access/remote' raise 'timestamp cannot be nil' unless hash_str = "#{name}#{email}#{token}#{timestamp}" query_values = { 'name' => name, 'email' => email, 'timestamp' => , 'hash' => Digest::MD5.hexdigest(hash_str), } query_values['return_to'] = return_to unless Zendesk2.blank?(return_to) uri.query = Faraday::NestedParamsEncoder.encode(query_values) uri.to_s end |
#memberships ⇒ Zendesk2::Memberships
Returns the organization memberships of this user.
184 185 186 |
# File 'lib/zendesk2/user.rb', line 184 def memberships cistern.memberships(user: self) end |
#moderator ⇒ Boolean
Returns Designates whether this user has forum moderation capabilities.
31 |
# File 'lib/zendesk2/user.rb', line 31 attribute :moderator, type: :boolean |
#name ⇒ String
Returns The name of the user.
33 |
# File 'lib/zendesk2/user.rb', line 33 attribute :name, type: :string |
#notes ⇒ String
Returns In this field you can store any notes you have about the user.
35 |
# File 'lib/zendesk2/user.rb', line 35 attribute :notes, type: :string |
#only_private_comments ⇒ Boolean
Returns true if this user only can create private comments.
37 |
# File 'lib/zendesk2/user.rb', line 37 attribute :only_private_comments, type: :boolean |
#organization_id ⇒ Integer
Returns The id of the organization this user is associated with.
39 |
# File 'lib/zendesk2/user.rb', line 39 attribute :organization_id, type: :integer |
#organizations ⇒ Zendesk2::Organizations
Returns the organizations of this user through memberships.
189 190 191 |
# File 'lib/zendesk2/user.rb', line 189 def organizations cistern.organizations(user: self) end |
#phone ⇒ String
Returns The primary phone number of this user.
41 |
# File 'lib/zendesk2/user.rb', line 41 attribute :phone, type: :string |
#photo ⇒ Attachment
Returns The user’s profile picture represented as an Attachment object.
43 |
# File 'lib/zendesk2/user.rb', line 43 attribute :photo, type: :Attachment |
#posts ⇒ Zendesk2::HelpCenter::Post
Returns authored posts.
201 202 203 204 205 |
# File 'lib/zendesk2/user.rb', line 201 def posts requires :identity cistern.help_center_posts(user_id: identity) end |
#role ⇒ String
Returns The role of the user. Possible values: “end-user”, “agent”, “admin”.
45 |
# File 'lib/zendesk2/user.rb', line 45 attribute :role, type: :string |
#save! ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/zendesk2/user.rb', line 72 def save! data = if new_record? requires :name, :email cistern.create_user('user' => attributes) else requires :identity cistern.update_user('user' => attributes) end.body['user'] merge_attributes(data) end |
#shared ⇒ Boolean
Returns If this user is shared from a different Zendesk, ticket sharing accounts only.
47 |
# File 'lib/zendesk2/user.rb', line 47 attribute :shared, type: :boolean |
#signature ⇒ String
Returns The signature of this user. Only agents and admins can have signatures.
49 |
# File 'lib/zendesk2/user.rb', line 49 attribute :signature, type: :string |
#subscriptions ⇒ Zendesk2::HelpCenter::Subscriptions
Returns subscriptions.
194 195 196 197 198 |
# File 'lib/zendesk2/user.rb', line 194 def subscriptions requires :identity cistern.help_center_subscriptions(user_id: identity) end |
#suspended ⇒ Boolean
Returns Tickets from suspended users are also suspended, and these users cannot log in to the end-user portal.
52 |
# File 'lib/zendesk2/user.rb', line 52 attribute :suspended, type: :boolean |
#tags ⇒ Array
Returns The tags of the user. Only present if your account has user tagging enabled.
54 |
# File 'lib/zendesk2/user.rb', line 54 attribute :tags, type: :array |
#ticket_restriction ⇒ String
Returns Specified which tickets this user has access to. Possible values are: “organization”, “groups”, “assigned”, “requested”, null.
57 |
# File 'lib/zendesk2/user.rb', line 57 attribute :ticket_restriction, type: :string |
#tickets ⇒ Zendesk2::Tickets Also known as: requested_tickets
Returns tickets this user requested.
164 165 166 167 168 |
# File 'lib/zendesk2/user.rb', line 164 def tickets requires :identity cistern.tickets(requester_id: identity) end |
#time_zone ⇒ String
Returns The time-zone of this user.
59 |
# File 'lib/zendesk2/user.rb', line 59 attribute :time_zone, type: :string |
#updated_at ⇒ Time
Returns The time of the last update of the user.
61 |
# File 'lib/zendesk2/user.rb', line 61 attribute :updated_at, type: :time |
#url ⇒ String
Returns The API url of this user.
63 |
# File 'lib/zendesk2/user.rb', line 63 attribute :url, type: :string |
#user_fields ⇒ Hash
Returns Custom fields for the user.
65 |
# File 'lib/zendesk2/user.rb', line 65 attribute :user_fields |
#verified ⇒ Boolean
Returns Zendesk has verified that this user is who he says he is.
67 |
# File 'lib/zendesk2/user.rb', line 67 attribute :verified, type: :boolean |