mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-24 19:25:52 +00:00
created_paynym object
This commit is contained in:
parent
f897b67714
commit
bbd04f46bb
2 changed files with 39 additions and 2 deletions
35
lib/models/paynym/created_paynym.dart
Normal file
35
lib/models/paynym/created_paynym.dart
Normal 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();
|
||||
}
|
||||
}
|
|
@ -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`
|
||||
|
|
Loading…
Reference in a new issue