-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from RatakondalaArun/21-add-documentation
#21 add documentation
- Loading branch information
Showing
24 changed files
with
362 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.dart_tool | ||
.packages | ||
.env | ||
doc | ||
.markdownlint.yaml | ||
.todo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## [0.0.1] | ||
|
||
- Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
# Gitter API Dart Warpper | ||
|
||
A simple warpper class around Gitter API | ||
A Dart client library for accessing [Gitter API](https://developer.gitter.im/docs/welcome). | ||
|
||
[![Gitter](https://badges.gitter.im/RatakondalaArun/gitterapi.svg)](https://gitter.im/RatakondalaArun/gitterapi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) | ||
|
||
## Getting Started | ||
|
||
1) Add this to your `pubspec.yaml` | ||
|
||
```text | ||
dependencies: | ||
tmdb_api: recent_version. | ||
``` | ||
2) Import the package in your code. | ||
```dart | ||
import 'package:gitterapi/gitterapi.dart' | ||
``` | ||
3) Create instance of `GitterApi`. | ||
```dart | ||
final gitterApi = GitterApi(ApiKeys('ACCESS_TOKEN')); | ||
``` | ||
|
||
### Example | ||
|
||
Now use that instance to make api requests. | ||
|
||
```dart | ||
final Result<Map> result = await gitterApi.v1.userResource.me(); | ||
print(result.data); | ||
// you can use models from gitterapi/models.dart to parse this data | ||
final User me = User.fromMap(result.data); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:gitterapi/gitter_api.dart'; | ||
import 'package:gitterapi/models.dart'; | ||
|
||
Future<void> main() async { | ||
// Create a instance of GitterApi. | ||
// In this case ApiKeys are being grabed from env. | ||
final gitterApi = GitterApi(ApiKeys.fromEnv()); | ||
// Fetches current user. | ||
final Result<Map> result = await gitterApi.v1.userResource.me(); | ||
// check if result is success. | ||
if (result.isError) { | ||
print('Some error occured error: ${result.error}'); | ||
return; | ||
} | ||
print(result.data); | ||
// parse User from Map object. | ||
final User me = User.fromMap(result.data); | ||
print(me); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
part of gitterapi; | ||
|
||
/// | ||
class ApiKeys { | ||
/// Authorization token required to connect to Gitter API. | ||
final String authToken; | ||
|
||
/// Creates a instance of [this]. | ||
const ApiKeys(this.authToken); | ||
|
||
/// Returns a instance of [ApiKeys] | ||
/// by fetching `authToken` from Environment. | ||
/// | ||
/// This looksup for `AUTH_TOKEN` env variable. | ||
/// | ||
factory ApiKeys.fromEnv() { | ||
return ApiKeys(String.fromEnvironment('AUTH_TOKEN')); | ||
/// ### Parameters: | ||
/// | ||
/// - `tokenVar`: Specifies which env variable to look for token. | ||
/// By default it looks for AUTH_TOKEN. | ||
/// | ||
factory ApiKeys.fromEnv({String tokenVar = 'AUTH_TOKEN'}) { | ||
return ApiKeys(String.fromEnvironment(tokenVar)); | ||
} | ||
} |
Oops, something went wrong.