opj static method
Implementation
static Token? opj(Map<String, dynamic> json) {
String ?tokenId = optString(json, FIELD_ID);
int ?createdTimeStamp = optInteger(json, FIELD_CREATED);
bool? liveMode = optBoolean(json, FIELD_LIVEMODE);
String? tokenType = asTokenType(optString(json, FIELD_TYPE));
bool ?used = optBoolean(json, FIELD_USED);
if (tokenId == null || createdTimeStamp == null || liveMode == null) {
return null;
}
DateTime date = DateTime.fromMillisecondsSinceEpoch(2000);
late Token token;
if (Token.TYPE_BANK_ACCOUNT == tokenType) {
final bankAccountObject = json[FIELD_BANK_ACCOUNT];
if (bankAccountObject == null) {
return null;
}
//BankAccount bankAccount = BankAccount.fromJson(bankAccountObject);
//token = new Token(tokenId, liveMode, date, used, bankAccount);
} else if (Token.TYPE_CARD == tokenType) {
final cardObject = json[FIELD_CARD];
if (cardObject == null) {
return null;
}
StripeCard card = StripeCard.fromJson(cardObject.cast<String, dynamic>());
token = Token._internal(tokenId, liveMode, date, tokenType, used,
card: card);
} else if (Token.TYPE_PII == tokenType || Token.TYPE_ACCOUNT == tokenType) {
token = Token._internal(tokenId, liveMode, date, tokenType, used);
}
return token;
}