Sha256: 109cf1071bf2707f9c1c2b007ea1ba7c12402049c2d9566ed84c1bf2a275e792

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

module Solusvm
  # Solusvm::Client is the class for working with clients.
  class Client < Base
    # Creates a client.
    #
    # Options:
    #
    # * <tt>:username</tt>
    # * <tt>:password</tt>
    # * <tt>:email</tt>
    # * <tt>:firstname</tt>
    # * <tt>:lastname</tt>
    # * <tt>:company</tt>
    def create(options ={})
      perform_request(options.merge(action: 'client-create')) && returned_parameters
    end

    # Change client password for the solus admin.
    def change_password(username, new_password)
      perform_request({action: "client-updatepassword", username: username, password: new_password})
    end

    # Checks wether a specific client exists.
    def exists?(username)
      perform_request({action: 'client-checkexists', username: username})
    end

    # Verify a clients login. Returns true when the specified login is correct.
    def authenticate(username, password)
      perform_request({action: 'client-authenticate', username: username, password: password})
    end

    # Deletes an existing client.
    def delete(username)
      perform_request({action: "client-delete", username: username})
    end

    # Lists existing clients.
    def list
      perform_request({action: "client-list"}, "client")

      if returned_parameters["clients"] && returned_parameters["clients"]["client"]
        returned_parameters["clients"]["client"]
      elsif returned_parameters["clients"]
        []
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solusvm-1.4.0 lib/solusvm/client.rb
solusvm-1.3.1 lib/solusvm/client.rb
solusvm-1.3.0 lib/solusvm/client.rb