-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5302bab
commit 6fb5de7
Showing
12 changed files
with
226 additions
and
72 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'dart:convert'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
Future<String?> putUserUpdateName(String name) async { | ||
final baseUrl = dotenv.get('BASE_URL'); | ||
final token = dotenv.get('TEST_TOKEN'); | ||
var url = Uri.parse('$baseUrl/user/update/name?name=$name'); | ||
var headers = { | ||
"Authorization": 'Bearer $token', | ||
}; | ||
var response = await http.put( | ||
url, | ||
headers: headers | ||
); | ||
|
||
|
||
|
||
if (response.statusCode == 200) { | ||
return response.body; | ||
} else { | ||
final Map<String, dynamic> jsonMap = | ||
jsonDecode(utf8.decode(response.bodyBytes)); | ||
print(utf8.decode(response.bodyBytes)); | ||
throw Exception("Failed to update name"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import 'dart:convert'; | ||
import 'package:damyo/models/stat_region_model.dart'; | ||
import 'package:damyo/models/stat_date_model.dart'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
// [email protected] | ||
|
||
Future<statDateModel> getDateStatics() async { | ||
final baseUrl = dotenv.get('BASE_URL'); | ||
var url = Uri.parse('$baseUrl/data/dateStatics'); | ||
|
@@ -17,14 +16,26 @@ Future<statDateModel> getDateStatics() async { | |
|
||
if (response.statusCode == 200) { | ||
// print(jsonMap); | ||
return statDateModel( | ||
jsonMap['hourlyStatisticsResponse']['time'], | ||
jsonMap['dailyStatisticsResponse']['days'], | ||
jsonMap['weeklyStatisticsResponse']['weeks'], | ||
jsonMap['monthlyStatisticsResponse']['months'], | ||
jsonMap['dayOfWeekStatisticsResponse']['dayWeek']); | ||
return statDateModel.fromJson(jsonMap); | ||
} else { | ||
print(utf8.decode(response.bodyBytes)); | ||
throw Exception("Failed to date statics"); | ||
} | ||
} | ||
|
||
Future<statRegionModel> getRegionStatics() async { | ||
final baseUrl = dotenv.get('BASE_URL'); | ||
var url = Uri.parse('$baseUrl/data/regionStatics'); | ||
var response = await http.get( | ||
url, | ||
); | ||
|
||
final Map<String, dynamic> jsonMap = | ||
jsonDecode(utf8.decode(response.bodyBytes)); | ||
|
||
if (response.statusCode == 200) { | ||
return statRegionModel.fromJson(jsonMap); | ||
} else { | ||
throw Exception("Failed to region statics"); | ||
} | ||
} |
Oops, something went wrong.