QuickbooksOauth2Tokens.fromMap constructor
accessTokenExpireDate and refreshTokenExpireDate are generated with DateTime.now() and the expiresIn/xRefreshTokenExpiresIn values.
Implementation
factory QuickbooksOauth2Tokens.fromMap(Map<String, dynamic> map) {
return QuickbooksOauth2Tokens(
xRefreshTokenExpiresIn:
int.parse(map['x_refresh_token_expires_in'].toString()),
expiresIn: int.parse(map['expires_in'].toString()),
refreshTokenExpireDate: map['refresh_token_expire_date'] != null
? DateTime.fromMillisecondsSinceEpoch(
int.parse(map['refresh_token_expire_date'].toString()))
: DateTime.now().add(Duration(
seconds:
int.parse(map['x_refresh_token_expires_in'].toString()))),
accessTokenExpireDate: map['access_token_expire_date'] != null
? DateTime.fromMillisecondsSinceEpoch(
int.parse(map['access_token_expire_date'].toString()))
: DateTime.now()
.add(Duration(seconds: int.parse(map['expires_in'].toString()))),
refreshToken: map['refresh_token'].toString(),
accessToken: map['access_token'].toString(),
tokenType: map['token_type'].toString(),
companyId: map['company_id'],
);
}