created_paynym object

This commit is contained in:
julian 2022-12-20 16:58:25 -06:00
parent f897b67714
commit bbd04f46bb
2 changed files with 39 additions and 2 deletions

View file

@ -0,0 +1,35 @@
class CreatedPaynym {
final bool claimed;
final String nymAvatar;
final String? nymId;
final String? nymName;
final String? token;
CreatedPaynym(
this.claimed,
this.nymAvatar,
this.nymId,
this.nymName,
this.token,
);
CreatedPaynym.fromMap(Map<String, dynamic> map)
: claimed = map["claimed"] as bool,
nymAvatar = map["nymAvatar"] as String,
nymId = map["nymId"] as String?,
nymName = map["nymName"] as String?,
token = map["token"] as String?;
Map<String, dynamic> toMap() => {
"claimed": claimed,
"nymAvatar": nymAvatar,
"nymId": nymId,
"nymName": nymName,
"token": token,
};
@override
String toString() {
return toMap().toString();
}
}

View file

@ -1,6 +1,7 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:stackwallet/models/paynym/created_paynym.dart';
class PaynymAPI {
static const String baseURL = "https://paynym.is/api";
@ -73,8 +74,9 @@ class PaynymAPI {
//
//
// ------
Future<Map<String, dynamic>> create(String code) async {
return _post("/create", {"code": code});
Future<CreatedPaynym> create(String code) async {
final map = await _post("/create", {"code": code});
return CreatedPaynym.fromMap(map);
}
// ### `/api/v1/token`