Added all the types; some of them will need to be fixed
This commit is contained in:
12
Sources/USDA/types/AbridgedFoodItem.swift
Normal file
12
Sources/USDA/types/AbridgedFoodItem.swift
Normal file
@@ -0,0 +1,12 @@
|
||||
public struct AbridgedFoodItem: Codable {
|
||||
public let dataType: String
|
||||
public let description: String
|
||||
public let fdcId: Int
|
||||
public let foodNutrients: [AbridgedFoodNutrient]
|
||||
public let publicationDate: String?
|
||||
public let brandOwner: String?
|
||||
public let gtinUpc: String?
|
||||
public let ndbNumber: Int?
|
||||
public let foodCode: String?
|
||||
}
|
||||
|
||||
9
Sources/USDA/types/AbridgedFoodNutrient.swift
Normal file
9
Sources/USDA/types/AbridgedFoodNutrient.swift
Normal file
@@ -0,0 +1,9 @@
|
||||
public struct AbridgedFoodNutrient: Codable {
|
||||
public let number: Int
|
||||
public let name: String
|
||||
public let amount: Float
|
||||
public let unitName: String
|
||||
public let derivationCode: String
|
||||
public let derivationDescription: String
|
||||
}
|
||||
|
||||
44
Sources/USDA/types/BrandedFoodItem.swift
Normal file
44
Sources/USDA/types/BrandedFoodItem.swift
Normal file
@@ -0,0 +1,44 @@
|
||||
public struct BrandedFoodItem: Codable {
|
||||
public let fdcId: Int
|
||||
public let availableDate: String?
|
||||
public let brandOwner: String?
|
||||
public let dataSource: String?
|
||||
public let dataType: String
|
||||
public let description: String
|
||||
public let foodClass: String?
|
||||
public let gtinUpc: String?
|
||||
public let householdServingFullText: String?
|
||||
public let ingredients: String?
|
||||
public let modifiedDate: String?
|
||||
public let publicationDate: String?
|
||||
public let servingSize: Float?
|
||||
public let servingSizeUnit: String?
|
||||
public let preparationStateCode: String?
|
||||
public let brandedFoodCategory: String?
|
||||
public let tradeChannel: [String]?
|
||||
public let gpcClassCode: Int?
|
||||
public let foodNutrients: [Any]?
|
||||
public let foodUpdateLog: [Any]?
|
||||
public let labelNutrients: LabelNutrients?
|
||||
|
||||
public struct LabelNutrients: Codable {
|
||||
public let fat: Nutrient
|
||||
public let saturatedFat: Nutrient
|
||||
public let transFat: Nutrient
|
||||
public let cholesterol: Nutrient
|
||||
public let sodium: Nutrient
|
||||
public let carbohydrates: Nutrient
|
||||
public let fiber: Nutrient
|
||||
public let sugars: Nutrient
|
||||
public let protein: Nutrient
|
||||
public let calcium: Nutrient
|
||||
public let iron: Nutrient
|
||||
public let potassium: Nutrient
|
||||
public let calories: Nutrient
|
||||
|
||||
public struct Nutrient: Codable {
|
||||
public let value: Float
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
Sources/USDA/types/DataType.swift
Normal file
6
Sources/USDA/types/DataType.swift
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
public enum DataType: String, Codable {
|
||||
case Branded, Foundation
|
||||
case SR_Legacy = "SR Legacy"
|
||||
case Survey = "Survey (FNDDS)"
|
||||
}
|
||||
6
Sources/USDA/types/FoodAttribute.swift
Normal file
6
Sources/USDA/types/FoodAttribute.swift
Normal file
@@ -0,0 +1,6 @@
|
||||
public struct FoodAttribute: Codable {
|
||||
public let id: Int
|
||||
public let sequenceNumber: Int
|
||||
public let value: String
|
||||
public let foodAttributeType: FoodAttributeType
|
||||
}
|
||||
5
Sources/USDA/types/FoodAttributeType.swift
Normal file
5
Sources/USDA/types/FoodAttributeType.swift
Normal file
@@ -0,0 +1,5 @@
|
||||
public struct FoodAttributeType: Codable {
|
||||
public let id: Int
|
||||
public let name: String
|
||||
public let description: String
|
||||
}
|
||||
5
Sources/USDA/types/FoodCategory.swift
Normal file
5
Sources/USDA/types/FoodCategory.swift
Normal file
@@ -0,0 +1,5 @@
|
||||
public struct FoodCategory: Codable {
|
||||
public let id: Int
|
||||
public let code: String
|
||||
public let description: String
|
||||
}
|
||||
10
Sources/USDA/types/FoodComponent.swift
Normal file
10
Sources/USDA/types/FoodComponent.swift
Normal file
@@ -0,0 +1,10 @@
|
||||
public struct FoodComponent: Codable {
|
||||
public let id: Int
|
||||
public let name: String
|
||||
public let dataPoints: Int
|
||||
public let gramWeight: Float
|
||||
public let isRefuse: Bool
|
||||
public let minYearAcquired: Int
|
||||
public let percentWeight: Float
|
||||
}
|
||||
|
||||
7
Sources/USDA/types/FoodListCriteria.swift
Normal file
7
Sources/USDA/types/FoodListCriteria.swift
Normal file
@@ -0,0 +1,7 @@
|
||||
public struct FoodListCriteria: Codable {
|
||||
public let dataType: [DataType]?
|
||||
public let pageSize: Int? // 1..=200, default 50
|
||||
public let pageNumber: Int?
|
||||
public let sortBy: SortBy?
|
||||
public let sortOrder: SortOrder?
|
||||
}
|
||||
13
Sources/USDA/types/FoodNutrient.swift
Normal file
13
Sources/USDA/types/FoodNutrient.swift
Normal file
@@ -0,0 +1,13 @@
|
||||
public struct FoodNutrient: Codable {
|
||||
public let id: Int
|
||||
public let amount: Float
|
||||
public let dataPoints: Int
|
||||
public let min: Float
|
||||
public let max: Float
|
||||
public let median: Float
|
||||
public let type: String
|
||||
public let nutrient: Nutrient
|
||||
public let foodNutrientDerivation: FoodNutrientDerivation
|
||||
public let nutrientAnalysisDetails: NutrientAnalysisDetails
|
||||
}
|
||||
|
||||
6
Sources/USDA/types/FoodNutrientDerivation.swift
Normal file
6
Sources/USDA/types/FoodNutrientDerivation.swift
Normal file
@@ -0,0 +1,6 @@
|
||||
public struct FoodNutrientDerivation: Codable {
|
||||
public let id: Int
|
||||
public let code: String
|
||||
public let description: String
|
||||
public let foodNutrientSource: FoodNutrientSource
|
||||
}
|
||||
5
Sources/USDA/types/FoodNutrientSource.swift
Normal file
5
Sources/USDA/types/FoodNutrientSource.swift
Normal file
@@ -0,0 +1,5 @@
|
||||
public struct FoodNutrientSource: Codable {
|
||||
public let id: Int
|
||||
public let code: String
|
||||
public let description: String
|
||||
}
|
||||
11
Sources/USDA/types/FoodPortion.swift
Normal file
11
Sources/USDA/types/FoodPortion.swift
Normal file
@@ -0,0 +1,11 @@
|
||||
public struct FoodPortion: Codable {
|
||||
public let id: Int
|
||||
public let amount: Float
|
||||
public let dataPoints: Int
|
||||
public let gramWeight: Float
|
||||
public let minYearAcquired: Int
|
||||
public let modifier: String
|
||||
public let portionDescription: String
|
||||
public let sequenceNumber: Int
|
||||
public let measureUnit: MeasureUnit
|
||||
}
|
||||
12
Sources/USDA/types/FoodSearchCriteria.swift
Normal file
12
Sources/USDA/types/FoodSearchCriteria.swift
Normal file
@@ -0,0 +1,12 @@
|
||||
public struct FoodSearchCriteria: Codable {
|
||||
public let query: String
|
||||
public let dataType: DataType?
|
||||
public let pageSize: Int?
|
||||
public let pageNumber: Int?
|
||||
public let sortBy: SortBy?
|
||||
public let sortOrder: SortOrder?
|
||||
public let brandOwner: String?
|
||||
public let tradeChannel: [TradeChannel]? // Max items: 3
|
||||
public let startDate: String? // Format: YYYY-MM-DD
|
||||
public let endDate: String? // Format: YYYY-MM-DD
|
||||
}
|
||||
19
Sources/USDA/types/FoodUpdateLog.swift
Normal file
19
Sources/USDA/types/FoodUpdateLog.swift
Normal file
@@ -0,0 +1,19 @@
|
||||
public struct FoodUpdateLog: Codable {
|
||||
public let fdcId: Int
|
||||
public let availableDate: String
|
||||
public let brandOwner: String
|
||||
public let dataSource: String
|
||||
public let dataType: String
|
||||
public let description: String
|
||||
public let foodClass: String
|
||||
public let gtinUpc: String
|
||||
public let householdServingFullText: String
|
||||
public let ingredients: String
|
||||
public let modifiedDate: String
|
||||
public let publicationDate: String
|
||||
public let servingSize: Float
|
||||
public let servingSizeUnit: String
|
||||
public let brandedFoodCategory: String
|
||||
public let changes: String
|
||||
public let foodAttributes: [FoodAttribute]
|
||||
}
|
||||
9
Sources/USDA/types/FoodsCriteria.swift
Normal file
9
Sources/USDA/types/FoodsCriteria.swift
Normal file
@@ -0,0 +1,9 @@
|
||||
public struct FoodsCriteria: Codable {
|
||||
public let fdcIds: [Int] // Max : 20 items
|
||||
public let format: [Format]?
|
||||
public let nutrients: [Int]? // Max : 25 items
|
||||
|
||||
public enum Format: String, Codable {
|
||||
case abridged, full
|
||||
}
|
||||
}
|
||||
5
Sources/USDA/types/InputFoodFoundation.swift
Normal file
5
Sources/USDA/types/InputFoodFoundation.swift
Normal file
@@ -0,0 +1,5 @@
|
||||
public struct InputFoodFoundation: Codable {
|
||||
public let id: Int
|
||||
public let foodDescription: String
|
||||
public let inputFood: SampleFoodItem
|
||||
}
|
||||
15
Sources/USDA/types/InputFoodSurvey.swift
Normal file
15
Sources/USDA/types/InputFoodSurvey.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
public struct InputFoodSurvey: Codable {
|
||||
public let id: Int
|
||||
public let amount: Float
|
||||
public let foodDescription: String
|
||||
public let ingredientCode: Int
|
||||
public let ingredientDescription: String
|
||||
public let ingredientWeight: Float
|
||||
public let portionCode: String
|
||||
public let portionDescription: String
|
||||
public let sequenceNumber: Int
|
||||
public let surveyFlag: Int
|
||||
public let unit: String
|
||||
public let inputFood: SurveyFoodItem
|
||||
public let retentionFactor: RetentionFactor
|
||||
}
|
||||
5
Sources/USDA/types/MeasureUnit.swift
Normal file
5
Sources/USDA/types/MeasureUnit.swift
Normal file
@@ -0,0 +1,5 @@
|
||||
public struct MeasureUnit: Codable {
|
||||
public let id: Int
|
||||
public let abbreviation: String
|
||||
public let name: String
|
||||
}
|
||||
8
Sources/USDA/types/Nutrient.swift
Normal file
8
Sources/USDA/types/Nutrient.swift
Normal file
@@ -0,0 +1,8 @@
|
||||
public struct Nutrient: Codable {
|
||||
public let description: String
|
||||
public let id: Int
|
||||
public let number: String
|
||||
public let name: String
|
||||
public let rank: Int
|
||||
public let unitName: String
|
||||
}
|
||||
6
Sources/USDA/types/NutrientAcquisitionDetails.swift
Normal file
6
Sources/USDA/types/NutrientAcquisitionDetails.swift
Normal file
@@ -0,0 +1,6 @@
|
||||
public struct NutrientAcquisitionDetails: Codable {
|
||||
public let sampleUnitId: Int
|
||||
public let purchaseDate: String
|
||||
public let storeCity: String
|
||||
public let storeState: String
|
||||
}
|
||||
10
Sources/USDA/types/NutrientAnalysisDetails.swift
Normal file
10
Sources/USDA/types/NutrientAnalysisDetails.swift
Normal file
@@ -0,0 +1,10 @@
|
||||
public struct NutrientAnalysisDetails: Codable {
|
||||
public let subSampleId: Int
|
||||
public let amount: Float
|
||||
public let nutrientId: Int
|
||||
public let labMethodDescription: String
|
||||
public let labMethodOriginalDescription: String
|
||||
public let labMethodLink: String
|
||||
public let labMethodTechnique: String
|
||||
public let nutrientAcquisitionDetails: [NutrientAcquisitionDetails]
|
||||
}
|
||||
5
Sources/USDA/types/NutrientConversionFactors.swift
Normal file
5
Sources/USDA/types/NutrientConversionFactors.swift
Normal file
@@ -0,0 +1,5 @@
|
||||
public struct NutrientConversionFactors: Codable {
|
||||
public let type: String
|
||||
public let value: Float
|
||||
}
|
||||
|
||||
5
Sources/USDA/types/RetentionFactor.swift
Normal file
5
Sources/USDA/types/RetentionFactor.swift
Normal file
@@ -0,0 +1,5 @@
|
||||
public struct RetentionFactor: Codable {
|
||||
public let id: Int
|
||||
public let code: Int
|
||||
public let description: String
|
||||
}
|
||||
8
Sources/USDA/types/SampleFoodItem.swift
Normal file
8
Sources/USDA/types/SampleFoodItem.swift
Normal file
@@ -0,0 +1,8 @@
|
||||
public struct SampleFoodItem: Codable {
|
||||
public let fdcId: Int
|
||||
public let dataType: String
|
||||
public let description: String
|
||||
public let foodClass: String
|
||||
public let publicationDate: String
|
||||
public let foodAttributes: [FoodCategory]
|
||||
}
|
||||
7
Sources/USDA/types/SearchResult.swift
Normal file
7
Sources/USDA/types/SearchResult.swift
Normal file
@@ -0,0 +1,7 @@
|
||||
public struct SearchResult: Codable {
|
||||
public let foodSearchCriteria: FoodSearchCriteria?
|
||||
public let totalHits: Int?
|
||||
public let currentPage: Int?
|
||||
public let totalPages: Int?
|
||||
public let foods: [SearchResultFood]?
|
||||
}
|
||||
17
Sources/USDA/types/SearchResultFood.swift
Normal file
17
Sources/USDA/types/SearchResultFood.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
public struct SearchResultFood: Codable {
|
||||
public let fdcId: Int
|
||||
public let dataType: String?
|
||||
public let description: String
|
||||
public let foodCode: String?
|
||||
public let foodNutrients: [AbridgedFoodNutrient]
|
||||
public let publicationDate: String?
|
||||
public let scientificName: String?
|
||||
public let brandOwner: String?
|
||||
public let gtinUpc: String?
|
||||
public let ingredients: String?
|
||||
public let ndbNumber: Int?
|
||||
public let additionalDescriptions: String?
|
||||
public let allHighlightFields: String?
|
||||
public let score: Float?
|
||||
}
|
||||
|
||||
4
Sources/USDA/types/SortBy.swift
Normal file
4
Sources/USDA/types/SortBy.swift
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
public enum SortBy: String, Codable {
|
||||
case dataType_keyword = "dataType.keyword", lowercaseDescription_keyword="lowercaseDescription.keyword", fdcId, publishedDate
|
||||
}
|
||||
4
Sources/USDA/types/SortOrder.swift
Normal file
4
Sources/USDA/types/SortOrder.swift
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
public enum SortOrder: String, Codable {
|
||||
case asc, desc
|
||||
}
|
||||
14
Sources/USDA/types/SurveyFoodItem.swift
Normal file
14
Sources/USDA/types/SurveyFoodItem.swift
Normal file
@@ -0,0 +1,14 @@
|
||||
public struct SurveyFoodItem: Codable {
|
||||
public let fdcId: Int
|
||||
public let dataType: String
|
||||
public let description: String
|
||||
public let endDate: String
|
||||
public let foodClass: String
|
||||
public let foodCode: String
|
||||
public let publicationDate: String
|
||||
public let startDate: String
|
||||
public let foodAttributes: [FoodAttribute]
|
||||
public let foodPortions: [FoodPortion]
|
||||
// ... other properties for SurveyFoodItem
|
||||
public let wweiaFoodCategory: WweiaFoodCategory
|
||||
}
|
||||
3
Sources/USDA/types/TradeChannel.swift
Normal file
3
Sources/USDA/types/TradeChannel.swift
Normal file
@@ -0,0 +1,3 @@
|
||||
public enum TradeChannel: String, Codable {
|
||||
case CHILD_NUTRITION_FOOD_PROGRAMS, DRUG, FOOD_SERVICE, GROCERY, MASS_MERCHANDISING, MILITARY, ONLINE, VENDING
|
||||
}
|
||||
4
Sources/USDA/types/WweiaFoodCategory.swift
Normal file
4
Sources/USDA/types/WweiaFoodCategory.swift
Normal file
@@ -0,0 +1,4 @@
|
||||
public struct WweiaFoodCategory: Codable {
|
||||
public let wweiaFoodCategoryCode: Int
|
||||
public let wweiaFoodCategoryDescription: String
|
||||
}
|
||||
Reference in New Issue
Block a user