Class: Gitter::API::User
- Includes:
- Collectable
- Defined in:
- lib/gitter/api/user.rb
Overview
Model representation of the /user/* REST endpoints in the gitter API
Defined Under Namespace
Modules: ClientMethods
Instance Attribute Summary collapse
-
#display_name ⇒ Object
readonly
Name of the user.
-
#id ⇒ Object
readonly
ID (from the API).
-
#url ⇒ Object
readonly
The relative path the the user’s page in the gitter webapp.
-
#username ⇒ Object
readonly
Username (minus the ‘@’).
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(client, data) ⇒ User
constructor
INTERNAL METHOD.
-
#rooms ⇒ Object
Fetch the all of the room records for a given user.
Methods included from Collectable
Methods inherited from Base
Constructor Details
#initialize(client, data) ⇒ User
INTERNAL METHOD
Initialize a new Gitter::API::User
Gitter::API::Client#user will return on of these objects, as well as some methods on Gitter::API::Room and when instanciating a Gitter::API::Message, so favor instanciating that way.
Parameters
- client (Gitter::API::Client)
-
Configured client object
- data (Hash)
-
Initialization data
Options
(string keys only)
- id (String)
-
User id
- display_name (String)
-
Gitter/GitHub user real name
- username (String)
-
Gitter/GitHub username (without ‘@’)
- url (String)
-
Path to the user on Gitter
42 43 44 45 46 47 48 49 |
# File 'lib/gitter/api/user.rb', line 42 def initialize client, data super @id = data["id"] || data["userId"] @display_name = data["displayName"] @username = data["username"] || data["screenName"] @url = data["url"] end |
Instance Attribute Details
#display_name ⇒ Object (readonly)
Name of the user
12 13 14 |
# File 'lib/gitter/api/user.rb', line 12 def display_name @display_name end |
#id ⇒ Object (readonly)
ID (from the API)
9 10 11 |
# File 'lib/gitter/api/user.rb', line 9 def id @id end |
#url ⇒ Object (readonly)
The relative path the the user’s page in the gitter webapp
18 19 20 |
# File 'lib/gitter/api/user.rb', line 18 def url @url end |
#username ⇒ Object (readonly)
Username (minus the ‘@’)
15 16 17 |
# File 'lib/gitter/api/user.rb', line 15 def username @username end |
Instance Method Details
#rooms ⇒ Object
Fetch the all of the room records for a given user
Includes one on one conversations, since those are considered “rooms” as well (based on their schema)
Returns a Gitter::API::Room::Collection
57 58 59 60 61 |
# File 'lib/gitter/api/user.rb', line 57 def rooms data = client.get "#{api_prefix}/rooms" Room::Collection.new self, data end |