SHARE
TWEET

Untitled

a guest May 21st, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'dart:async';
  2. import 'dart:convert';
  3.  
  4. import 'package:chargex_flutter/repository/local_repository.dart';
  5. import 'package:chargex_flutter/repository/models/charging_status_model.dart';
  6. import 'package:chargex_flutter/repository/models/client_model.dart';
  7. import 'package:chargex_flutter/repository/models/feedback_model.dart';
  8. import 'package:chargex_flutter/repository/models/history_model.dart';
  9. import 'package:chargex_flutter/repository/network_utils/custom_http_client.dart';
  10. import 'package:http/http.dart' as http;
  11.  
  12. class ApiRepository {
  13.   CustomHttpClient client;
  14.   String baseUrl = "https://billing.chargex.net/api/";
  15.  
  16.   ApiRepository() {
  17.     client = new CustomHttpClient(LocalRepository.instance, http.Client());
  18.   }
  19.  
  20.   static ApiRepository _instance;
  21.  
  22.   static ApiRepository get instance {
  23.     if (_instance == null) {
  24.       _instance = ApiRepository();
  25.     }
  26.  
  27.     return _instance;
  28.   }
  29.  
  30.   Future<ClientModel> getUserInfo() async {
  31.     var response = await client.get(baseUrl + 'client/current');
  32.     print(response.body);
  33.     print(response.statusCode);
  34.     if (response.statusCode == 200) {
  35.       return ClientModel.fromJson(json.decode(response.body));
  36.     } else {
  37.       return null;
  38.     }
  39.   }
  40.  
  41.   Future<http.Response> sendConfirmationCode(String phone) async {
  42.     var response = await client.post(baseUrl + 'client/send-confirmation-code',
  43.         body: json.encode({"phone": phone}),
  44.         headers: {"Content-Type": "application/json"});
  45.     print(response.body);
  46.     return response;
  47.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top