Sha256: 0d75a178529965ff0ca9612d972ac27ac5f38533cf22b8c88fa80f5b953eb1be

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Hachi
  module Clients
    class User < Base
      #
      # Get current user
      #
      # @return [Hash]
      #
      def current
        get("/api/user/current") { |json| json }
      end

      #
      # Get a user
      #
      # @param [String] id User ID
      #
      # @return [Hash]
      #
      def get_by_id(id)
        get("/api/user/#{id}") { |json| json }
      end

      #
      # Delete a user
      #
      # @param [String] id User ID
      #
      # @return [String]
      #
      def delete_by_id(id)
        delete("/api/user/#{id}") { |json| json }
      end

      #
      # Create a user
      #
      # @param [String] login
      # @param [String] name
      # @param [Array<String>] roles
      # @param [String] password
      #
      # @return [Hash]
      #
      def create(login:, name:, roles:, password:)
        user = Models::User.new(
          login: login,
          name: name,
          roles: roles,
          password: password
        )

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hachi-0.3.2 lib/hachi/clients/user.rb
hachi-0.3.1 lib/hachi/clients/user.rb
hachi-0.3.0 lib/hachi/clients/user.rb