Skip to content

Commit

Permalink
feat: Update CGU to match server changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementGld authored and taorepoara committed Sep 29, 2023
1 parent ff7e910 commit f14286c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/api/cgu_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:client_common/api/response_models/user_accepted_latest_cgu_respo
class CguApi {
static Future<CguResponse> getLatestCgu() => LenraApi.instance.get(
"/cgu/latest",
responseMapper: (json, header) => CguResponse.fromJson(json["latest_cgu"]),
responseMapper: (json, header) => CguResponse.fromJson(json),
);

static Future<UserAcceptCguVersionResponse> acceptCgu(int cguId) => LenraApi.instance.post(
Expand Down
6 changes: 3 additions & 3 deletions lib/api/response_models/cgu_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import 'package:client_common/api/response_models/api_response.dart';

class CguResponse extends ApiResponse {
int id;
String link;
String path;
String hash;
String version;
int version;

CguResponse.fromJson(Map<String, dynamic> json)
: id = json["id"],
link = json["link"],
path = json["path"],
hash = json["hash"],
version = json["version"];
}
2 changes: 1 addition & 1 deletion lib/models/cgu_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CguModel extends ChangeNotifier {

Future<Response> getLatestCguAsMd(language) async {
var res = await getLatestCgu().then((cgu) {
return http.get(Uri.parse("${Config.instance.httpEndpoint}/web/cgu/${cgu.link}_$language.md"));
return http.get(Uri.parse("${Config.instance.httpEndpoint}/web/cgu/CGU_${language}_${cgu.version}.md"));
});
notifyListeners();
return res;
Expand Down
6 changes: 3 additions & 3 deletions test/api/response_models/cgu_response_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import 'package:test/test.dart';

void main() {
test('from json', () {
Map<String, dynamic> json = {"id": 1, "hash": "1234", "link": "/cgu/cgu-1.0.0.html", "version": "1.0.0"};
Map<String, dynamic> json = {"id": 1, "hash": "1234", "path": "/cgu/CGU_fr_1.html", "version": 1};
CguResponse cguResponse = CguResponse.fromJson(json);
expect(cguResponse.id, 1);
expect(cguResponse.hash, "1234");
expect(cguResponse.link, "/cgu/cgu-1.0.0.html");
expect(cguResponse.version, "1.0.0");
expect(cguResponse.path, "/cgu/CGU_fr_1.html");
expect(cguResponse.version, 1);
});
}

0 comments on commit f14286c

Please sign in to comment.