Uhhh... the documentation is shit; still lost
This commit is contained in:
21
Sources/OpenFoodFacts/Extension+String.swift
Normal file
21
Sources/OpenFoodFacts/Extension+String.swift
Normal file
@@ -0,0 +1,21 @@
|
||||
extension String {
|
||||
func camelCaseToSnakeCase() -> String {
|
||||
var result = ""
|
||||
var lastCharacterWasUppercase = false
|
||||
|
||||
for character in self {
|
||||
if character.isUppercase {
|
||||
if !result.isEmpty && !lastCharacterWasUppercase {
|
||||
result.append("_")
|
||||
}
|
||||
result.append(character.lowercased())
|
||||
lastCharacterWasUppercase = true
|
||||
} else {
|
||||
result.append(character)
|
||||
lastCharacterWasUppercase = false
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
14
Sources/OpenFoodFacts/types/SearchResponse.swift
Normal file
14
Sources/OpenFoodFacts/types/SearchResponse.swift
Normal file
@@ -0,0 +1,14 @@
|
||||
public struct SearchResponse: Codable, ObjectDebugger {
|
||||
public var count: Int
|
||||
public var page: Int
|
||||
public var pageCount: Int
|
||||
public var pageSize: Int
|
||||
public var products: [Product]?
|
||||
public var skip: Int
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case count, page, products, skip
|
||||
case pageCount = "page_count"
|
||||
case pageSize = "page_size"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user