Sha256: 213325f4af25bdf10e3c945efdf395e65bdaf2231ef122f8a8164dec11946781

Contents?: true

Size: 990 Bytes

Versions: 4

Compression:

Stored size: 990 Bytes

Contents

module Mashery
  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
      Mashery.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
      Mashery.client.call_remote('member.removeRole', {'username' => username}, {'id' => role_id})
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mashery-0.1.1 lib/mashery/member.rb
mashery-0.1.0 lib/mashery/member.rb
mashery-0.0.11 lib/mashery/member.rb
mashery-0.0.10 lib/mashery/member.rb