Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:http/http.dart' as http;
  4.  
  5. class Routes {
  6. static const String LOGIN_ROUTE = "/auth/login";
  7. static const String LOGOUT_ROUTE = "/auth/logout";
  8. static const String REGISTER_ROUTE = "/auth/registration";
  9. static const String PROVIDER_REGISTRATION = "/provider_registration";
  10. static const String AUTH_STATUS = "/auth/status";
  11. static const String GENERAL_CATEGORY = "/general";
  12. static const String PROVIDER_CATEGORY = "/provider";
  13. static String CATEGORY_PROVIDERS(id) {
  14. return "/provider/$id";
  15. }
  16.  
  17. static String SERVICE_REVIEWS(id) {
  18. return "/service_reviews/average/$id";
  19. }
  20.  
  21. static String CHARISMA_REVIEWS(id) {
  22. return "/charisma_reviews/average/$id";
  23. }
  24.  
  25. static const String CREATE_ADDRESS = '/add_address';
  26. }
  27.  
  28. class Services {
  29. static const String CHAT = "chat";
  30. static const String USER = "user";
  31. static const String CATEGORY = "category";
  32. static const String REVIEW = "review";
  33. static const String REPORT = "report";
  34. }
  35.  
  36. class Api {
  37. Api._privateConstructor();
  38.  
  39. static final Api _instance = Api._privateConstructor();
  40.  
  41. factory Api() {
  42. return _instance;
  43. }
  44.  
  45. final String baseUrl = "https://pax-gateway.herokuapp.com/api/v1/";
  46.  
  47. Future<dynamic> get(String service, String route, {Map headers}) {
  48. debugPrint("baseUrl + service + route: " + baseUrl + service + route);
  49. return http
  50. .get(baseUrl + service + route, headers: headers)
  51. .then((http.Response response) {
  52. return response;
  53. });
  54. }
  55.  
  56. Future<dynamic> post(String service, String route,
  57. {Map headers, body, encoding}) {
  58. return http
  59. .post(baseUrl + service + route,
  60. body: body, headers: headers, encoding: encoding)
  61. .then((http.Response response) {
  62. return response;
  63. });
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement