Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

dronn1k-org/base_repository

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TODO: Put a short description of the package here that helps potential users know whether this package might be useful for them.

Features

TODO: List what your package can do. Maybe include images, gifs, or videos.

Getting started

base_repository:
  version: ^0.1.1
  git: git@github.com:dronn1k-org/base_repository.git

Usage

Specify your own ApiUrls

enum ProjectApiUrl implements ApiUrl {
  prod('https://prod.template.com',),
  dev('https://dev.template.com');

  const ProjectApiUrl(this.url);

  @override
  final String url;
}

Specify your response body (if needed)

class GeneralResponseBody<T extends DTO> extends BaseResponseBody {
  String? success;
  T? data;
  String? message;
}

Specify your Callback result

class GeneralCbResult<T> extends BaseCallbackResult<T, String> {
  const GeneralCbResult({
    required super.callbackStatus,
    super.statusCode,
    super.data,
    super.errors,
  });
}

Setting up your General Repository

class GeneralRepository extends BaseRepository<GeneralResponseBody<DTO>, String,
    GeneralCbResult<DTO>> {
  @override
  Future<GeneralCbResult<T>> request<T extends DTO>(
      ClientCallback<GeneralResponseBody<DTO>> callback) async {
    return GeneralCbResult<T>(callbackStatus: ApiCallbackStatus.success);
  }

  @override
  ProjectApiUrl currentUrl = ProjectApiUrl.prod;

  @override
  HeadersType headers = {
    'accept': 'application/json',
    'content': 'application/json',
  };

  @override
  OnErrorDioInterceptor onError = (error, handler) {
    return handler.next(error);
  };

  @override
  OnRequestDioInterceptor onRequest = (request, handler) {
    return handler.next(request);
  };

  @override
  OnResponseDioInterceptor onResponse = (response, handler) {
    return handler.next(response);
  };
}

Additional information

TODO: Tell users more about the package: where to find more information, how to contribute to the package, how to file issues, what response they can expect from the package authors, and more.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages