mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
28 lines
No EOL
1,019 B
Dart
28 lines
No EOL
1,019 B
Dart
import 'dart:convert';
|
|
import 'package:intl/intl.dart' show toBeginningOfSentenceCase;
|
|
|
|
class IoniaGiftCardInstruction {
|
|
IoniaGiftCardInstruction(this.header, this.body);
|
|
|
|
factory IoniaGiftCardInstruction.fromJsonMap(Map<String, dynamic> element) {
|
|
return IoniaGiftCardInstruction(
|
|
toBeginningOfSentenceCase(element['title'] as String? ?? '') ?? '',
|
|
element['description'] as String);
|
|
}
|
|
|
|
static List<IoniaGiftCardInstruction> parseListOfInstructions(String instructionsJSON) {
|
|
List<IoniaGiftCardInstruction> instructions = <IoniaGiftCardInstruction>[];
|
|
|
|
if (instructionsJSON.isNotEmpty) {
|
|
final decodedInstructions = json.decode(instructionsJSON) as List<dynamic>;
|
|
instructions = decodedInstructions
|
|
.map((dynamic e) =>IoniaGiftCardInstruction.fromJsonMap(e as Map<String, dynamic>))
|
|
.toList();
|
|
}
|
|
|
|
return instructions;
|
|
}
|
|
|
|
final String header;
|
|
final String body;
|
|
} |