parse method

  1. @override
Integration parse(
  1. Map<String, Object?> raw
)
override

Parse the raw data received from the API into an instance of the type of this manager.

Implementation

@override
Integration parse(Map<String, Object?> raw) {
  return Integration(
    id: Snowflake.parse(raw['id']!),
    manager: this,
    name: raw['name'] as String,
    type: raw['type'] as String,
    isEnabled: raw['enabled'] as bool,
    isSyncing: raw['syncing'] as bool?,
    roleId: maybeParse(raw['role_id'], Snowflake.parse),
    enableEmoticons: raw['enable_emoticons'] as bool?,
    expireBehavior: maybeParse(raw['expire_behavior'], IntegrationExpireBehavior.parse),
    expireGracePeriod: maybeParse(raw['expire_grace_period'], (int value) => Duration(days: value)),
    user: maybeParse(raw['user'], client.users.parse),
    account: parseIntegrationAccount(raw['account'] as Map<String, Object?>),
    syncedAt: maybeParse(raw['synced_at'], DateTime.parse),
    subscriberCount: raw['subscriber_count'] as int?,
    isRevoked: raw['revoked'] as bool?,
    application: maybeParse(raw['application'], parseIntegrationApplication),
    scopes: maybeParseMany(raw['scopes']),
  );
}