Skip to content
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

Merge v2.1.2 to master #19

Merged
merged 7 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/network_requests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
library network_requests;

import 'dart:async';
import 'dart:io';
import 'dart:typed_data';

/// 3rd party libraries
Expand All @@ -27,7 +26,7 @@ export 'src/http_interceptor/http_interceptor.dart'
Request,
BaseResponse;
export 'src/interceptors/network_request_interceptor.dart';
export 'src/utils/utils.dart' hide Logger;
export 'src/utils/utils.dart' hide Logger, TryCatcher;

/// The models
part 'src/models/response_model.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/functions/network_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ResponseMessage extractMessage(int status) {
message = ResponseMessage.internalServerError;
break;
case 502:
message = ResponseMessage.internalServerError;
message = ResponseMessage.badGateway;
break;
default:
message = ResponseMessage.somethingWentWrong;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/http_interceptor/http/intercepted_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef TimeoutCallback = FutureOr<StreamedResponse> Function();
///
/// Don't forget to close the client once you are done, as a client keeps
/// the connection alive with the server by default.
class InterceptedClient extends BaseClient {
final class InterceptedClient extends BaseClient {
/// List of interceptors that will be applied to the requests and responses.
final List<InterceptorContract> interceptors;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/http_interceptor/http/intercepted_http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import '../http_interceptor.dart';
/// http.read(...);
/// http.readBytes(...);
/// ```
class InterceptedHttp {
final class InterceptedHttp {
/// List of interceptors that will be applied to the requests and responses.
final List<InterceptorContract> interceptors;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/http_interceptor/models/request_data_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:convert';

import 'package:http/http.dart';

class RequestData extends BaseRequest {
final class RequestData extends BaseRequest {
@override
// ignore: overridden_fields
Map<String, String> headers;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/http_interceptor/models/response_data_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'dart:typed_data';

import '../http_interceptor.dart';

class ResponseData extends BaseResponse {
final class ResponseData extends BaseResponse {
@override
int statusCode;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/interceptors/logging_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:network_requests/network_requests.dart';
import '../utils/utils.dart';

@protected
class LoggingInterceptor implements NetworkRequestInterceptor {
final class LoggingInterceptor implements NetworkRequestInterceptor {
@override
Future<BaseRequest> interceptRequest(BaseRequest request) async {
final logInfo = 'REQ -> method: ${request.method}, url: ${request.url}';
Expand Down
13 changes: 7 additions & 6 deletions lib/src/interceptors/network_request_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@ import '../http_interceptor/http_interceptor.dart';

/// An interceptor that can be used on [NetworkRequest] api calls.
///
/// This interceptor uses the technique in `package: http_interceptor`.
/// _`NOTE: You can only implement this class (cannot be etended).`_
///
/// > * Example:
/// ```
/// class LoggingInterceptor implements InterceptorContract {
/// class LoggingInterceptor implements NetworkRequestInterceptor {
/// @override
/// Future<RequestData> interceptRequest({required RequestData request}) async {
/// Future<BaseRequest> interceptRequest(BaseRequest request) async {
/// debugPrint(request.toString());
///
/// return request;
/// }
///
/// @override
/// Future<ResponseData> interceptResponse({required ResponseData reponse}) async {
/// Future<ResponseData> interceptResponse(ResponseData reponse) async {
/// debugPrint(response.toString());
///
/// return response;
/// }
///
/// }
/// ```
abstract class NetworkRequestInterceptor extends InterceptorContract {}
abstract interface class NetworkRequestInterceptor
extends InterceptorContract {}

/// A retry interceptor that can be used to retry a request.
///
/// A good use-case could be when a token is expired.
abstract class RetryInterceptor extends RetryPolicy {}
abstract interface class RetryInterceptor extends RetryPolicy {}
2 changes: 1 addition & 1 deletion lib/src/models/network_request_exception.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
part of '../../network_requests.dart';

class NetworkRequestException implements Exception {
final class NetworkRequestException implements Exception {
final dynamic message;

final int errorCode;
Expand Down
16 changes: 10 additions & 6 deletions lib/src/models/response_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ part of '../../network_requests.dart';
///
/// >`message` [string] - The message of the status code returned
///
class ApiResponse {
final class ApiResponse {
dynamic _data;
Uint8List bytes = Uint8List.fromList([]);

Expand All @@ -39,16 +39,20 @@ class ApiResponse {
}
}

///`
/// The Status-Code received from the RestAPI Request
///`
///
/// The Status-Code received from the RestAPI Request or error-code from the package.
///
/// Below are the error-codes and their representations:
/// > - 8001 - General Error
/// > - 8005 - No Internet Error
///
int get statusCode => _status;

///`
/// Set The Status-Code received from the RestAPI Request
///`
set statusCode(int value) {
if (true) _status = value;
set statusCode(int? value) {
if (value != null) _status = value;
}

///`
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/upload_file_model.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../../network_requests.dart';

/// The upload structure of files
class UploadFile {
final class UploadFile {
/// The field name/key that will be used to append the file while uploading.
final String field;

Expand Down
Loading