Class: ZendeskAPI::User

Inherits:
Resource show all
Extended by:
CreateMany, CreateOrUpdate, CreateOrUpdateMany, DestroyMany, UpdateMany
Defined in:
lib/zendesk_api/resources.rb,
lib/zendesk_api/resources.rb

Defined Under Namespace

Classes: CurrentSession, GroupMembership, Identity, Session

Instance Attribute Summary

Attributes inherited from DataResource

#error, #error_message

Attributes inherited from Data

#association, #attributes, #errors, #response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CreateMany

create_many!

Methods included from UpdateMany

update_many!

Methods included from CreateOrUpdate

create_or_update!

Methods included from CreateOrUpdateMany

create_or_update_many!

Methods included from DestroyMany

destroy_many!

Methods included from Destroy

#destroy, #destroy!, #destroyed?, included

Methods included from Update

included

Methods included from Save

#clear_associations, #save, #save!, #save_associations

Methods included from Create

included

Methods included from Read

included, #reload!

Methods included from Sideloading

included, #set_includes

Methods included from Verbs

#any, #delete, #post, #put

Methods inherited from Data

#==, #account_data, #id, inherited, #initialize, #inspect, #loaded_associations, #method_missing, namespace, new_from_response, #new_record?, #path, #refresh_custom_fields_metadata, resource_name, resource_path, #respond_to_missing?, singular_resource_name, subclasses, #to_json, #to_s

Methods included from Associations

included, #wrap_resource

Constructor Details

This class inherits a constructor from ZendeskAPI::Data

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ZendeskAPI::Data

Class Method Details

.cbp_path_regexesObject



846
847
848
# File 'lib/zendesk_api/resources.rb', line 846

def self.cbp_path_regexes
  [/^users$/, %r{^organizations/\d+/users$}]
end

.incremental_export(client, start_time) ⇒ Collection

Gets a incremental export of users from the start_time until now.

Parameters:

  • client (Client)

    The Client object to be used

  • start_time (Integer)

    The start_time parameter

Returns:



876
877
878
# File 'lib/zendesk_api/resources.rb', line 876

def self.incremental_export(client, start_time)
  ZendeskAPI::Collection.new(client, self, path: "incremental/users?start_time=#{start_time.to_i}")
end

Instance Method Details

#attributes_for_saveObject



935
936
937
938
939
940
941
942
943
944
# File 'lib/zendesk_api/resources.rb', line 935

def attributes_for_save
  # Don't send role_id, it's necessary
  # for side-loading, but causes problems on save
  # see #initialize
  attrs = attributes.changes.delete_if do |k, _|
    k == "role_id"
  end

  {self.class.singular_resource_name => attrs}
end

#change_password(opts = {}) ⇒ Object

Change a user's password



858
859
860
# File 'lib/zendesk_api/resources.rb', line 858

def change_password(opts = {})
  password(opts.merge(verb: :put))
end

#change_password!(opts = {}) ⇒ Object

Change a user's password



868
869
870
# File 'lib/zendesk_api/resources.rb', line 868

def change_password!(opts = {})
  password!(opts.merge(verb: :put))
end

#clear_sessionsObject



907
908
909
910
911
# File 'lib/zendesk_api/resources.rb', line 907

def clear_sessions
  clear_sessions!
rescue ZendeskAPI::Error::ClientError
  false
end

#clear_sessions!Object



903
904
905
# File 'lib/zendesk_api/resources.rb', line 903

def clear_sessions!
  @client.connection.delete("#{path}/sessions")
end

#current_sessionObject



897
898
899
# File 'lib/zendesk_api/resources.rb', line 897

def current_session
  ZendeskAPI::User::CurrentSession.find(@client, user_id: "me")
end

#handle_responseObject



946
947
948
949
950
951
# File 'lib/zendesk_api/resources.rb', line 946

def handle_response(*)
  super

  # Needed for proper Role sideloading
  self.role_id = role.name if key?(:role)
end

#set_password(opts = {}) ⇒ Object

Set a user's password



853
854
855
# File 'lib/zendesk_api/resources.rb', line 853

def set_password(opts = {})
  password(opts.merge(verb: :post))
end

#set_password!(opts = {}) ⇒ Object

Set a user's password



863
864
865
# File 'lib/zendesk_api/resources.rb', line 863

def set_password!(opts = {})
  password!(opts.merge(verb: :post))
end