Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Model/OFF/ProductConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public struct ProductQueryConfiguration {
var languages: [OpenFoodFactsLanguage]
var fields: [ProductField]?

init(barcode: String,
public init(barcode: String,
languages: [OpenFoodFactsLanguage] = [],
country: OpenFoodFactsCountry? = nil,
fields: [ProductField]? = nil) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Model/OFF/ProductField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

enum ProductField: String {
public enum ProductField: String {
case barcode = "code"
case name = "product_name"
case nameInLanguages = "product_name_"
Expand Down
20 changes: 10 additions & 10 deletions Sources/Model/OFF/ProductResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ import Foundation
public struct ProductResponse: Decodable {

/// Possible value for [status]: the operation failed.
static let statusFailure = "failure"
public static let statusFailure = "failure"

/// Possible value for [status]: the operation succeeded with warnings.
static let statusWarning = "success_with_warnings"
public static let statusWarning = "success_with_warnings"

/// Possible value for [status]: the operation succeeded.
static let statusSuccess = "success"
public static let statusSuccess = "success"

/// Possible value for [result.id]: product found
static let resultProductFound = "product_found"
public static let resultProductFound = "product_found"

/// Possible value for [result.id]: product not found
static let resultProductNotFound = "product_not_found"
public static let resultProductNotFound = "product_not_found"

let barcode: String?
let status: String?
let product: Product?
public let barcode: String?
public let status: String?
public let product: Product?

enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case barcode = "code"
case status
case product
}

func hasProduct() -> Bool {
public func hasProduct() -> Bool {
guard let status = self.status else { return false }
return status == ProductResponse.resultProductFound || status == ProductResponse.statusSuccess || status == ProductResponse.statusWarning
}
Expand Down