NetworkServiceBuilder class
Builder class for creating and configuring network services with interceptors.
This class is responsible for setting up the network layer with all necessary interceptors for authentication, security, logging, and mocking. It provides a centralized way to configure network services with consistent interceptor setup across the SDK.
Features
- Interceptor Management: Configures authentication, security, and logging interceptors
- Language Support: Handles Arabic and English language configurations
- Mock Support: Enables mock responses for testing and development
- Security: Implements secure hash validation and token injection
- Flexible Configuration: Supports custom HTTP clients and error handling
Usage Example
final networkService = NetworkServiceBuilder.instance.setupNetworkService(
isMocked: false,
secureHashValue: 'your_secure_hash',
token: 'your_auth_token',
language: 'en',
onError: (error, stackTrace) => print('Network error: $error'),
onTokenExpired: () async => 'new_token',
);
Interceptors Included
- TokenInterceptor: Handles authentication token injection
- SecureHashInterceptor: Validates secure hash for security
- MockupInterceptor: Provides mock responses when enabled
- CustomLogInterceptor: Handles language-specific logging
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setupNetworkService(
bool isMocked, String? secureHashValue, String token, String language, {void onError(Object e, StackTrace stack)?, Future< String?> onTokenExpired()?, HttpClient? client}) → NetworkService - Sets up a complete network service with all necessary configurations.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → NetworkServiceBuilder
-
Returns the singleton instance of NetworkServiceBuilder.
no setter