fromJson static method

Assets? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static Assets? 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 "Assets[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "Assets[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return Assets(
      dateCreated: mapDateTime(json, r'date_created', r''),
      lastUpdated: mapDateTime(json, r'last_updated', r''),
      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<int>(json, r'snippet_id'),
      industryId: mapValueOfType<int>(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: mapDateTime(json, r'approved_at', r''),
      name: mapValueOfType<String>(json, r'name')!,
      slug: mapValueOfType<String>(json, r'slug'),
      description: mapValueOfType<String>(json, r'description'),
      source_: AssetsSource_Enum.fromJson(json[r'source'])!,
      assetType: AssetsAssetTypeEnum.fromJson(json[r'asset_type']),
      assetSchema: mapValueOfType<Object>(json, r'asset_schema'),
      visibility: AssetsVisibilityEnum.fromJson(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<bool>(json, r'sell_in_marketplace')!,
      vizChartLibrary: AssetsVizChartLibraryEnum.fromJson(json[r'viz_chart_library']),
      vizChartType: AssetsVizChartTypeEnum.fromJson(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: AssetsVizDataAggregationEnum.fromJson(json[r'viz_data_aggregation']),
      vizSortDirection: AssetsVizSortDirectionEnum.fromJson(json[r'viz_sort_direction']),
      vizDataLimit: mapValueOfType<int>(json, r'viz_data_limit'),
      vizColorScheme: AssetsVizColorSchemeEnum.fromJson(json[r'viz_color_scheme']),
      allowParams: mapValueOfType<bool>(json, r'allow_params')!,
      acceptTerms: mapValueOfType<bool>(json, r'accept_terms')!,
      cached: mapValueOfType<bool>(json, r'cached'),
      schedule: mapValueOfType<String>(json, r'schedule'),
      nextRun: mapDateTime(json, r'next_run', r''),
      dataTimePeriodStart: mapDateTime(json, r'data_time_period_start', r''),
      dataTimePeriodEnd: mapDateTime(json, r'data_time_period_end', r''),
      geographicCoverageType: AssetsGeographicCoverageTypeEnum.fromJson(json[r'geographic_coverage_type']),
      geographicCoverageDetails: mapValueOfType<String>(json, r'geographic_coverage_details'),
      dataSourceRefreshFrequency: AssetsDataSourceRefreshFrequencyEnum.fromJson(json[r'data_source_refresh_frequency']),
      dataSourceLastRefreshed: mapDateTime(json, r'data_source_last_refreshed', r''),
    );
  }
  return null;
}