fromJson static method

EndpointsInput? fromJson(
  1. dynamic value
)

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

Implementation

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

    return EndpointsInput(
      dateCreated: mapDateTime(json, r'date_created', r''),
      lastUpdated: mapDateTime(json, r'last_updated', r''),
      userId: mapValueOfType<String>(json, r'user_id'),
      companyId: mapValueOfType<String>(json, r'company_id')!,
      connectionId: mapValueOfType<String>(json, r'connection_id')!,
      industryId: mapValueOfType<int>(json, r'industry_id'),
      aucId: mapValueOfType<int>(json, r'auc_id'),
      approvalStatus: EndpointsInputApprovalStatusEnum.fromJson(json[r'approval_status']),
      approvedByUserId: mapValueOfType<String>(json, r'approved_by_user_id'),
      approvedAt: mapDateTime(json, r'approved_at', r''),
      sellInMarketplace: mapValueOfType<bool>(json, r'sell_in_marketplace'),
      name: mapValueOfType<String>(json, r'name')!,
      slug: mapValueOfType<String>(json, r'slug'),
      description: mapValueOfType<String>(json, r'description'),
      detailedDescription: mapValueOfType<String>(json, r'detailed_description'),
      topQuestions: mapValueOfType<String>(json, r'top_questions'),
      sourceSchemaName: mapValueOfType<String>(json, r'source_schema_name'),
      sourceTableName: mapValueOfType<String>(json, r'source_table_name'),
      customerName: mapValueOfType<String>(json, r'customer_name'),
      endpointSchema: mapValueOfType<Object>(json, r'endpoint_schema'),
      rateLimitNumber: mapValueOfType<int>(json, r'rate_limit_number'),
      rateLimitPeriod: EndpointsInputRateLimitPeriodEnum.fromJson(json[r'rate_limit_period']),
      rateLimitGranularity: EndpointsInputRateLimitGranularityEnum.fromJson(json[r'rate_limit_granularity']),
      accessMethod: EndpointsInputAccessMethodEnum.fromJson(json[r'access_method']),
      accessWhitelist: mapValueOfType<Object>(json, r'access_whitelist'),
      status: EndpointsInputStatusEnum.fromJson(json[r'status']),
      dataTimePeriodStart: mapDateTime(json, r'data_time_period_start', r''),
      dataTimePeriodEnd: mapDateTime(json, r'data_time_period_end', r''),
      dateCollectionStart: mapDateTime(json, r'date_collection_start', r''),
      geographicCoverageType: EndpointsInputGeographicCoverageTypeEnum.fromJson(json[r'geographic_coverage_type']),
      geographicCoverageDetails: mapValueOfType<String>(json, r'geographic_coverage_details'),
      dataSourceRefreshFrequency: EndpointsInputDataSourceRefreshFrequencyEnum.fromJson(json[r'data_source_refresh_frequency']),
      tags: mapValueOfType<String>(json, r'tags'),
      lastAccessed: mapDateTime(json, r'last_accessed', r''),
      maxRecordsPerRequest: mapValueOfType<int>(json, r'max_records_per_request'),
      exportEnabled: mapValueOfType<bool>(json, r'export_enabled'),
      maxRecordsPerExport: mapValueOfType<int>(json, r'max_records_per_export'),
      sampleResponse: mapValueOfType<Object>(json, r'sample_response'),
      active: mapValueOfType<bool>(json, r'active'),
    );
  }
  return null;
}