fromJson static method

Asset? fromJson(
  1. dynamic value
)

Returns a new Asset instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static Asset? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "Asset[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "Asset[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return Asset(
      assetId: mapValueOfType<String>(json, r'asset_id'),
      userId: mapValueOfType<String>(json, r'user_id'),
      companyId: mapValueOfType<String>(json, r'company_id')!,
      connectionId: mapValueOfType<String>(json, r'connection_id'),
      llmConnectionId: mapValueOfType<String>(json, r'llm_connection_id'),
      snippetId: mapValueOfType<String>(json, r'snippet_id'),
      industryId: mapValueOfType<String>(json, r'industry_id'),
      aiJobId: mapValueOfType<String>(json, r'ai_job_id'),
      approvalStatus: mapValueOfType<String>(json, r'approval_status'),
      approvedByUserId: mapValueOfType<String>(json, r'approved_by_user_id'),
      approvedAt: mapValueOfType<String>(json, r'approved_at'),
      name: mapValueOfType<String>(json, r'name')!,
      slug: mapValueOfType<String>(json, r'slug'),
      description: mapValueOfType<String>(json, r'description'),
      source_: mapValueOfType<String>(json, r'source')!,
      assetType: mapValueOfType<String>(json, r'asset_type'),
      assetSchema: mapValueOfType<String>(json, r'asset_schema'),
      visibility: mapValueOfType<String>(json, r'visibility'),
      tags: mapValueOfType<String>(json, r'tags'),
      sqlLogic: mapValueOfType<String>(json, r'sql_logic'),
      sourceSchemaName: mapValueOfType<String>(json, r'source_schema_name'),
      sourceTableName: mapValueOfType<String>(json, r'source_table_name'),
      sellInMarketplace: mapValueOfType<String>(json, r'sell_in_marketplace'),
      vizChartLibrary: mapValueOfType<String>(json, r'viz_chart_library'),
      vizChartType: mapValueOfType<String>(json, r'viz_chart_type'),
      vizDepVarColName: mapValueOfType<String>(json, r'viz_dep_var_col_name'),
      vizIndepVarColName: mapValueOfType<String>(json, r'viz_indep_var_col_name'),
      vizSizeColName: mapValueOfType<String>(json, r'viz_size_col_name'),
      vizColorColName: mapValueOfType<String>(json, r'viz_color_col_name'),
      vizDataAggregation: mapValueOfType<String>(json, r'viz_data_aggregation'),
      vizSortDirection: mapValueOfType<String>(json, r'viz_sort_direction'),
      vizDataLimit: mapValueOfType<String>(json, r'viz_data_limit'),
      vizColorScheme: mapValueOfType<String>(json, r'viz_color_scheme'),
      allowParams: mapValueOfType<String>(json, r'allow_params'),
      acceptTerms: mapValueOfType<String>(json, r'accept_terms'),
      cached: mapValueOfType<String>(json, r'cached'),
      schedule: mapValueOfType<String>(json, r'schedule'),
      nextRun: mapValueOfType<String>(json, r'next_run'),
      dataTimePeriodStart: mapValueOfType<String>(json, r'data_time_period_start'),
      dataTimePeriodEnd: mapValueOfType<String>(json, r'data_time_period_end'),
      geographicCoverageType: mapValueOfType<String>(json, r'geographic_coverage_type'),
      geographicCoverageDetails: mapValueOfType<String>(json, r'geographic_coverage_details'),
      dataSourceRefreshFrequency: mapValueOfType<String>(json, r'data_source_refresh_frequency'),
      dataSourceLastRefreshed: mapValueOfType<String>(json, r'data_source_last_refreshed'),
      dateCreated: mapValueOfType<String>(json, r'date_created'),
      lastUpdated: mapValueOfType<String>(json, r'last_updated'),
      active: mapValueOfType<String>(json, r'active'),
    );
  }
  return null;
}