Sha256: 1b6d5404beadfdced54b59ed032935499ab2f0f0881379ba71ff1db753f48a3e

Contents?: true

Size: 1015 Bytes

Versions: 2

Compression:

Stored size: 1015 Bytes

Contents

module Masheri
  class Member < ApiObjectBase
    attr_reader :created, :updated
    attr_accessor(:username, :email, :display_name, :uri, :blog, :im, :imsvc, :phone,
                  :company, :address1, :address2, :locality, :region, :postal_code, :country_code, :first_name, :last_name,
                  :registration_ipaddr, :area_status, :external_id, :passwd_new)

    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 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.1.1 lib/masheri/member.rb
masheri-0.1.0 lib/masheri/member.rb