Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
feat: use new template.js for api generation
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman committed Dec 8, 2023
1 parent 360cee3 commit bdac18b
Show file tree
Hide file tree
Showing 28 changed files with 351 additions and 669 deletions.
1 change: 1 addition & 0 deletions bin/hermit.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sources = ["https://github.com/TBD54566975/hermit-ftl.git", "https://github.com/cashapp/hermit-packages.git"]
18 changes: 9 additions & 9 deletions frontend/mobile/lib/api/ad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import 'ftl_client.dart';
class AdRequest {
List<String> contextKeys;

AdRequest({ required this.contextKeys, });
AdRequest({ required this.contextKeys, });

Map<String, dynamic> toMap() {
return {
'contextKeys': ((dynamic v) =>v.map((v) => v).cast<String>().toList())(contextKeys),
'contextKeys': ((dynamic v) => v.map((v) => v).cast<String>().toList())(contextKeys),
};
}

Expand All @@ -31,12 +31,12 @@ class Ad {
String redirectURL;
String text;

Ad({ required this.redirectURL, required this.text, });
Ad({ required this.redirectURL, required this.text, });

Map<String, dynamic> toMap() {
return {
'redirectURL': ((dynamic v) =>v)(redirectURL),
'text': ((dynamic v) =>v)(text),
'redirectURL': ((dynamic v) => v)(redirectURL),
'text': ((dynamic v) => v)(text),
};
}

Expand All @@ -56,12 +56,12 @@ class AdResponse {
String name;
List<Ad> ads;

AdResponse({ required this.name, required this.ads, });
AdResponse({ required this.name, required this.ads, });

Map<String, dynamic> toMap() {
return {
'name': ((dynamic v) =>v)(name),
'ads': ((dynamic v) =>v.map((v) => Ad.fromMap(v)).cast<Ad>().toList())(ads),
'name': ((dynamic v) => v)(name),
'ads': ((dynamic v) => v.map((v) => Ad.fromMap(v)).cast<Ad>().toList())(ads),
};
}

Expand All @@ -85,7 +85,7 @@ class AdClient {


Future<AdResponse> get(AdRequest request) async {
final response = await ftlClient.get('/ad', request: request.toMap());
final response = await ftlClient.get('/ad', requestJson: request.toJson());
if (response.statusCode == 200) {
return AdResponse.fromJson(response.body);
} else {
Expand Down
28 changes: 14 additions & 14 deletions frontend/mobile/lib/api/cart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class Item {
String productID;
int quantity;

Item({ required this.productID, required this.quantity, });
Item({ required this.productID, required this.quantity, });

Map<String, dynamic> toMap() {
return {
'productID': ((dynamic v) =>v)(productID),
'quantity': ((dynamic v) =>v)(quantity),
'productID': ((dynamic v) => v)(productID),
'quantity': ((dynamic v) => v)(quantity),
};
}

Expand All @@ -34,12 +34,12 @@ class AddItemRequest {
String userID;
Item item;

AddItemRequest({ required this.userID, required this.item, });
AddItemRequest({ required this.userID, required this.item, });

Map<String, dynamic> toMap() {
return {
'userID': ((dynamic v) =>v)(userID),
'item': ((dynamic v) =>v.toMap())(item),
'userID': ((dynamic v) => v)(userID),
'item': ((dynamic v) => v.toMap())(item),
};
}

Expand Down Expand Up @@ -77,11 +77,11 @@ class AddItemResponse {
class GetCartRequest {
String userID;

GetCartRequest({ required this.userID, });
GetCartRequest({ required this.userID, });

Map<String, dynamic> toMap() {
return {
'userID': ((dynamic v) =>v)(userID),
'userID': ((dynamic v) => v)(userID),
};
}

Expand All @@ -100,12 +100,12 @@ class Cart {
String userID;
List<Item> items;

Cart({ required this.userID, required this.items, });
Cart({ required this.userID, required this.items, });

Map<String, dynamic> toMap() {
return {
'userID': ((dynamic v) =>v)(userID),
'items': ((dynamic v) =>v.map((v) => Item.fromMap(v)).cast<Item>().toList())(items),
'userID': ((dynamic v) => v)(userID),
'items': ((dynamic v) => v.map((v) => Item.fromMap(v)).cast<Item>().toList())(items),
};
}

Expand All @@ -124,11 +124,11 @@ class Cart {
class EmptyCartRequest {
String userID;

EmptyCartRequest({ required this.userID, });
EmptyCartRequest({ required this.userID, });

Map<String, dynamic> toMap() {
return {
'userID': ((dynamic v) =>v)(userID),
'userID': ((dynamic v) => v)(userID),
};
}

Expand Down Expand Up @@ -179,7 +179,7 @@ class CartClient {
}

Future<Cart> getCart(GetCartRequest request) async {
final response = await ftlClient.get('/cart', request: request.toMap());
final response = await ftlClient.get('/cart', requestJson: request.toJson());
if (response.statusCode == 200) {
return Cart.fromJson(response.body);
} else {
Expand Down
240 changes: 0 additions & 240 deletions frontend/mobile/lib/api/checkout.dart

This file was deleted.

Loading

0 comments on commit bdac18b

Please sign in to comment.