Class: Hachi::Clients::User

Inherits:
Base
  • Object
show all
Defined in:
lib/hachi/clients/user.rb

Instance Attribute Summary

Attributes inherited from Base

#api_endpoint, #api_key

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Hachi::Clients::Base

Instance Method Details

#create(login:, name:, roles:, password:) ⇒ Hash

Create a user

Parameters:

  • login (String)
  • name (String)
  • roles (Array<String>)
  • password (String)

Returns:

  • (Hash)


47
48
49
50
51
52
53
54
55
56
# File 'lib/hachi/clients/user.rb', line 47

def create(login:, name:, roles:, password:)
  user = Models::User.new(
    login: ,
    name: name,
    roles: roles,
    password: password
  )

  post("/api/user", user.payload) { |json| json }
end

#currentHash

Get current user

Returns:

  • (Hash)


11
12
13
# File 'lib/hachi/clients/user.rb', line 11

def current
  get("/api/user/current") { |json| json }
end

#delete_by_id(id) ⇒ String

Delete a user

Parameters:

  • id (String)

    User ID

Returns:

  • (String)


33
34
35
# File 'lib/hachi/clients/user.rb', line 33

def delete_by_id(id)
  delete("/api/user/#{id}") { |json| json }
end

#get_by_id(id) ⇒ Hash

Get a user

Parameters:

  • id (String)

    User ID

Returns:

  • (Hash)


22
23
24
# File 'lib/hachi/clients/user.rb', line 22

def get_by_id(id)
  get("/api/user/#{id}") { |json| json }
end