IntraApi class

Base class for intra-service API communication.

This class extends BaseApi functionality with URL joining capabilities. Each service extends IntraApi with a configured baseUrl for making API calls to specific microservice endpoints.

Usage

class VouchersService extends IntraApi {
  static final VouchersService instance = VouchersService();
  VouchersService() : super('https://vouchers.tsdtech.com');

  Future<ValueResult<List<Voucher>>> getVouchers() async { ... }
}

URL Handling

The joinUrl method ensures proper URL construction by:

  • Removing trailing slashes from baseUrl
  • Adding leading slash to path if missing
  • Concatenating without duplicate slashes
Implementers

Constructors

IntraApi([String _baseUrl = ''])
Creates an IntraApi instance with the specified baseUrl.

Properties

baseUrl String
Returns the base URL of this service.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

delete(String path, {Object? data, Map<String, dynamic>? headers}) Future<Response>
Performs a DELETE request to the specified path on this service's base URL.
get(String path, {Map<String, dynamic>? queryParameters, Map<String, dynamic>? headers}) Future<Response>
Performs a GET request to the specified path on this service's base URL.
joinUrl(String baseUrl, String path) String
Joins a baseUrl and path into a single URL string.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch(String path, {Object? data, Map<String, dynamic>? headers}) Future<Response>
Performs a PATCH request to the specified path on this service's base URL.
post(String path, {Object? data, Map<String, dynamic>? headers}) Future<Response>
Performs a POST request to the specified path on this service's base URL.
put(String path, {Object? data, Map<String, dynamic>? headers}) Future<Response>
Performs a PUT request to the specified path on this service's base URL.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited