Class: Hanko::Api::Admin::Passwords

Inherits:
Object
  • Object
show all
Defined in:
lib/hanko/api/admin/passwords.rb

Overview

Admin resource for managing a user's password.

Instance Method Summary collapse

Constructor Details

#initialize(connection, user_base_path) ⇒ Passwords

Initialize the passwords resource scoped to a user.

Parameters:

  • connection (Hanko::Connection) —

    the HTTP connection to use

  • user_base_path (String) —

    the base path for the parent user (e.g. "/users/:id")



13
14
15
16
# File 'lib/hanko/api/admin/passwords.rb', line 13

def initialize(connection, user_base_path)
  @connection = connection
  @base_path = "#{user_base_path}/password"
end

Instance Method Details

#create(**params) ⇒ Resource

Create a password for the user.

Parameters:

  • params (Hash) —

    the password attributes

Returns:

  • (Resource) —

    the created password resource



22
23
24
25
# File 'lib/hanko/api/admin/passwords.rb', line 22

def create(**params)
  response = @connection.post(@base_path, params)
  Resource.new(JSON.parse(response.body))
end

#delete ⇒ void

This method returns an undefined value.

Delete the user's password.



47
48
49
50
# File 'lib/hanko/api/admin/passwords.rb', line 47

def delete
  @connection.delete(@base_path)
  nil
end

#get ⇒ Resource

Fetch the user's password resource.

Returns:



30
31
32
33
# File 'lib/hanko/api/admin/passwords.rb', line 30

def get
  response = @connection.get(@base_path)
  Resource.new(JSON.parse(response.body))
end

#update(**params) ⇒ Resource

Update the user's password.

Parameters:

  • params (Hash) —

    the password attributes to update

Returns:

  • (Resource) —

    the updated password resource



39
40
41
42
# File 'lib/hanko/api/admin/passwords.rb', line 39

def update(**params)
  response = @connection.put(@base_path, params)
  Resource.new(JSON.parse(response.body))
end