Sha256: a0300a781213d8305e44de87a3bc140373e494bc847bce1a588f2bbf4f0e2c29

Contents?: true

Size: 935 Bytes

Versions: 2

Compression:

Stored size: 935 Bytes

Contents

module Masheri
  class Member < ApiObjectBase
    def self.create(username, display_name, email, fields = {})
      fields ||= {}
      our_fields = fields.merge('username' => username, 'display_name' => display_name, 'email' => email)
      super(our_fields)
    end

    def self.fetch_all
      Masheri::RpcClient.new.call_remote("object.query", params: "SELECT * FROM members")
    end

    def self.fetch_by_username(username)
      Masheri::RpcClient.new.call_remote("member.fetch", params: username)
    end

    def add_role(role_or_id)
      role_id = role_or_id.is_a?(Role) ? role_or_id.id : role_or_id
      Masheri.client.call_remote('member.addRole', {'username' => username}, {'id' => role_id})
    end

    def remove_role(role_or_id)
      role_id = role_or_id.is_a?(Role) ? role_or_id.id : role_or_id
      Masheri.client.call_remote('member.removeRole', {'username' => username}, {'id' => role_id})
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
masheri-0.3.5 lib/masheri/member.rb
masheri-0.3.4 lib/masheri/member.rb