Sha256: e58570608483abf61ca13f5310bf9213cc08cad69b2936043b22772b1725c525

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

module DesignHuddle
  class User
    attr_accessor :user_id, :account_user_id, :user_code, :test, :email_address, :first_name, :last_name,
                  :user_properties, :date_created, :date_updated, :last_activity, :project_count, :account, :user_roles, :user_status, :user_type

    def initialize(user)
      @user_id = user["user_id"]
      @account_user_id = user["account_user_id"]
      @user_code = user["user_code"]
      @test = user["test"]
      @email_address = user["email_address"]
      @first_name = user["first_name"]
      @last_name = user["last_name"]
      @user_properties = user["user_properties"]
      @date_created = user["date_created"]
      @date_updated = user["date_updated"]
      @last_activity = user["last_activity"]
      @project_count = user["project_count"]
      @account = user["account"]
      @user_roles = user["user_roles"]
      @user_status = user["user_status"]
      @user_type = user["user_type"]
      self
    end

    def reload
      initialize(User.fetch(user_id))
    end

    def self.create(**args)
      DesignHuddle.client.call(
        method: :post,
        path: "/partners/api/account/users",
        payload: args.to_json
      )
    end

    def self.list
      DesignHuddle.client.call(path: "/partners/api/account/users")["data"]["items"].map { |user| User.new(user) }
    end

    def self.retrieve(user_id)
      User.new(User.fetch(user_id))
    end

    def self.fetch(user_id)
      DesignHuddle.client.call(path: "/partners/api/account/users/#{user_id}")["data"]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
design_huddle-0.1.0 lib/design_huddle/user.rb