| 1234567891011121314151617181920212223242526272829303132333435 |
- import 'dart:async';
- import 'package:electronic_assistant/data/api/atmob_api.dart';
- import 'package:flutter/cupertino.dart';
- import '../../utils/http_handler.dart';
- import '../api/request/login_request.dart';
- import '../api/request/verification_code_request.dart';
- import '../api/response/login_response.dart';
- class AccountRepository {
- AccountRepository._() {
- debugPrint('AccountRepository init');
- }
- String? token;
- Future<void> getVerificationCode(String phone) {
- return atmobApi
- .getVerificationCode(VerificationCodeRequest(phone))
- .then(HttpHandler.handle(false));
- }
- Future<LoginResponse> login(String phone, String code) {
- return atmobApi
- .login(LoginRequest(phone, code))
- .then(HttpHandler.handle(true))
- .then((response) {
- token = response.authToken;
- return response;
- });
- }
- }
- final accountRepository = AccountRepository._();
|