Skip to content

Commit

Permalink
Add Documentation closes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratakondala Arun committed Dec 30, 2020
1 parent 2d60dff commit 2430eb0
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 31 deletions.
3 changes: 3 additions & 0 deletions lib/gitter_api.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// This library provides a easy way to intract with [Gitter API](https://developer.gitter.im/docs/welcome).
///
/// This library also provides models to convert responses.
library gitterapi;

import 'dart:convert';
Expand Down
1 change: 0 additions & 1 deletion lib/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ export 'models/issue.dart';
export 'models/mention.dart';
export 'models/message.dart';
export 'models/permission.dart';
export 'models/provider.dart';
export 'models/room.dart';
export 'models/user.dart';
15 changes: 13 additions & 2 deletions lib/models/group.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Represents a group.
class Group {
/// Group ID.
final String id;
Expand All @@ -14,6 +15,7 @@ class Group {
/// Base avatar URL (add s parameter to size)
final String avatarUrl;

/// Creates a instance of [Group].
const Group({
this.id,
this.name,
Expand Down Expand Up @@ -70,9 +72,10 @@ class SecurityDescriptor {
/// [null|'ONE_TO_ONE'|'GH_REPO'|'GH_ORG'|'GH_USER']
final SecurityDescriptorType type;

/// Represents how we find the backing object given the type
/// Represents how we find the backing object given the type.
final String linkPath;

/// Creates a instace of [SecurityDescriptor].
const SecurityDescriptor({
this.type,
this.linkPath,
Expand Down Expand Up @@ -107,8 +110,16 @@ class SecurityDescriptor {
String toString() => 'SecurityDescriptor(type: $type, linkPath: $linkPath)';
}

enum SecurityDescriptorType { oneToOne, ghRepo, ghOrg, ghUser, glGroup }
/// Security descriptorType. Describes the backing object we get permissions from.
enum SecurityDescriptorType {
oneToOne,
ghRepo,
ghOrg,
ghUser,
glGroup,
}

/// This can be used to convert [SecurityDescriptorType] to [String] and back.
extension SecurityDescriptorTypeExtension on SecurityDescriptorType {
Map<SecurityDescriptorType, String> get names {
return {
Expand Down
3 changes: 3 additions & 0 deletions lib/models/issue.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/// Represents a issue.
class Issue {
/// Issues number that was mentioned.
final String number;

/// Creates a instance of [Issue].
const Issue({
this.number,
});
Expand Down
5 changes: 5 additions & 0 deletions lib/models/mention.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/// Represents mention.
class Mention {
/// Id of the user that was mentioned.
final String userId;

/// Screen name of the user that was mentioned.
final String screenName;

/// Creates a instance of [Mention].
const Mention({
this.userId,
this.screenName,
Expand Down
6 changes: 5 additions & 1 deletion lib/models/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'issue.dart';
import 'mention.dart';
import 'user.dart';

/// Represents a Message.
class Message {
/// ID of the message.
final String id;
Expand All @@ -18,7 +19,7 @@ class Message {
/// ISO formatted date of the message if edited.
final String editedAt;

/// (User)[user-resource] that sent the message.
/// (User) that sent the message.
final User fromUser;

/// Boolean that indicates if the current user has read the message.
Expand All @@ -39,14 +40,17 @@ class Message {
/// Metadata. This is currently not used for anything.
final List<dynamic> meta;

/// Converts [sent] to [DateTime].
DateTime get sentAs {
return sent == null ? null : DateTime.tryParse(sent);
}

/// Converts [editedAt] to [DateTime].
DateTime get editedAtAs {
return editedAt == null ? null : DateTime.tryParse(editedAt);
}

/// Creates a instance of [Message].
const Message({
this.id,
this.text,
Expand Down
5 changes: 4 additions & 1 deletion lib/models/permission.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'dart:convert';

/// This class contains user permissions.
class Permissions {
/// Returns true if this person is admin.
final bool admin;

Permissions({
/// Creates a instance of [Permissions].
const Permissions({
this.admin,
});

Expand Down
43 changes: 17 additions & 26 deletions lib/models/room.dart
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
import 'permission.dart';

// {
// "id": "576c4d75c2f0db084a1f99ae",
// "name": "flutter/flutter",
// "topic": "Flutter makes it easy and fast to build beautiful apps for mobile and beyond.\n",
// "avatarUrl": "https://avatars-01.gitter.im/group/iv/4/576c4d75c2f0db084a1f99ad",
// "uri": "flutter/flutter",
// "oneToOne": false,
// "userCount": 12301,
// "unreadItems": 17,
// "mentions": 0,
// "lastAccessTime": "2020-12-16T17:14:05.771Z",
// "lurk": false,
// "url": "/flutter/flutter",
// "githubType": "REPO",
// "security": "PUBLIC",
// "noindex": false,
// "tags": [],
// "permissions": {
// "admin": false
// },
// "roomMember": true,
// "groupId": "576c4d75c2f0db084a1f99ad",
// "public": true,
// "v": 2
// },

/// Represents a room.
class Room {
///Room ID.
final String id;
Expand Down Expand Up @@ -85,6 +60,7 @@ class Room {
/// Wheather be indexed by search engines.
final bool noindex;

/// Permissions user have in this room.
final Permissions permissions;

/// Room version.
Expand All @@ -100,6 +76,7 @@ class Room {
);
}

/// Creates a instance of [Room].
const Room({
this.id,
this.name,
Expand Down Expand Up @@ -232,15 +209,29 @@ class Room {
}
}

/// Type of room.
enum RoomType {
/// This room is belonged to organization.
org,

/// This room is belonged to Repository.
repo,

/// This room is a one to one chat( Direct message ).
oneToOne,

/// This is a Organization channel
orgChannel,

/// This is a Repository channel
repoChannel,

/// This is a User channel
userChannel,
}

/// Extension on [RoomType]. Used to parse [RoomType] to [String]
/// and back.
extension RoomTypeExtension on RoomType {
/// Returns [Map<RoomType,String>] with respect to there string.
static const names = {
Expand Down
3 changes: 3 additions & 0 deletions lib/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ class User {
/// Auth Provider
final List<String> providers;

/// Version
final int v;

/// Gavavatar version
final String gv;

/// Creates a instance of [User]
const User({
this.id,
this.username,
Expand Down

0 comments on commit 2430eb0

Please # to comment.