-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote client package #241
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
70a03c0
Add remote congif package
aidaiym 362adcf
format yaml packages path
aidaiym e3bfbdc
format yaml packages path
aidaiym 54d6d6b
mq_remote_client fix
Eldar2021 2685cf5
Added documantations
Eldar2021 3247f2a
Fix MqCrashlytics setCrashlyticsCollectionEnabled
Eldar2021 256b545
Try fix MqCrashlytics android error
Eldar2021 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
4 changes: 2 additions & 2 deletions
4
app/lib/modules/home/data/source/remote/home_remote_data_source_impl.dart
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
4 changes: 2 additions & 2 deletions
4
app/lib/modules/read/data/source/remote/read_remote_data_source_impl.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# MqRemoteClient | ||
|
||
MqRemoteClient is a Dart package that simplifies HTTP requests using the Dio library, providing a convenient and consistent way to handle network operations with error handling and custom token management. | ||
|
||
## Features | ||
|
||
- HTTP GET, POST, PUT, PATCH methods | ||
- Custom headers including token and language | ||
- Error handling using custom exceptions | ||
- Easily mockable for testing | ||
|
||
## Installation | ||
|
||
Add `mq_remote_client` to your `pubspec.yaml`: | ||
|
||
## Usage | ||
|
||
### Initialization | ||
|
||
Create an instance of `MqRemoteClient` and initialize it: | ||
|
||
```dart | ||
import 'package:dio/dio.dart'; | ||
import 'package:mq_remote_client/mq_remote_client.dart'; | ||
|
||
final dio = Dio(); | ||
final networkClient = NetworkClient(); | ||
|
||
final mqRemoteClient = MqRemoteClient( | ||
dio: dio, | ||
network: networkClient, | ||
language: () => 'en', | ||
token: () => 'your_token', | ||
oldToken: () => 'your_old_token', | ||
); | ||
|
||
mqRemoteClient.initilize(); | ||
``` | ||
|
||
## Making Requests | ||
|
||
### GET Request | ||
|
||
```dart | ||
final result = await mqRemoteClient.get<Map<String, dynamic>>( | ||
'https://example.com/api/resource', | ||
fromJson: (json) => json, | ||
); | ||
|
||
result.fold( | ||
(left) => print('Error: $left'), | ||
(right) => print('Data: $right'), | ||
); | ||
``` | ||
|
||
### POST Request | ||
|
||
```dart | ||
final result = await mqRemoteClient.post<Map<String, dynamic>>( | ||
'https://example.com/api/resource', | ||
fromJson: (json) => json, | ||
body: {'key': 'value'}, | ||
); | ||
|
||
result.fold( | ||
(left) => print('Error: $left'), | ||
(right) => print('Data: $right'), | ||
); | ||
``` | ||
### PUT Request | ||
|
||
```dart | ||
final result = await mqRemoteClient.put<Map<String, dynamic>>( | ||
'https://example.com/api/resource', | ||
fromJson: (json) => json, | ||
body: {'key': 'value'}, | ||
); | ||
|
||
result.fold( | ||
(left) => print('Error: $left'), | ||
(right) => print('Data: $right'), | ||
); | ||
``` | ||
|
||
### PATCH Request | ||
|
||
```dart | ||
final result = await mqRemoteClient.patch<Map<String, dynamic>>( | ||
'https://example.com/api/resource', | ||
fromJson: (json) => json, | ||
body: {'key': 'value'}, | ||
); | ||
|
||
result.fold( | ||
(left) => print('Error: $left'), | ||
(right) => print('Data: $right'), | ||
); | ||
``` |
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,7 @@ | ||
include: package:very_good_analysis/analysis_options.yaml | ||
|
||
linter: | ||
rules: | ||
public_member_api_docs: false | ||
lines_longer_than_80_chars: false | ||
sort_pub_dependencies: false |
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,6 @@ | ||
/// MQ remote client package | ||
library; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add |
||
|
||
export 'src/http_exception.dart'; | ||
export 'src/mq_remote_client.dart'; | ||
export 'src/network_client.dart'; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add documantation |
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
fromJson: (json) => json,
not need toawait mqRemoteClient.get