mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-01 01:47:41 +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;
|
|
} |