Skip to content

Commit

Permalink
Feat/fiixed cert logic (#52)
Browse files Browse the repository at this point in the history
* Fixed run dest JsonLogic

* minor

* changed version

* changed version 2

* changed version

* updated version - restored

* fixed test warnings
  • Loading branch information
ihorkhomyak authored May 10, 2022
1 parent 01de90f commit c5103a5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
10 changes: 6 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,28 @@ let package = Package(
platforms: [
.macOS(.v10_13), .iOS(.v11), .tvOS(.v9), .watchOS(.v2)
],

products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "CertLogic",
targets: ["CertLogic"]),
],

dependencies: [
// Dependencies declare other packages that this package depends on.
.package(name: "jsonlogic", url: "https://github.com/eu-digital-green-certificates/json-logic-swift.git", from: "1.1.9"),
.package(name: "SwiftyJSON", url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "5.0.0")
.package(name: "JsonLogic", url: "https://github.com/eu-digital-green-certificates/json-logic-swift.git", from: "1.2.1"),
.package(name: "SwiftyJSON", url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "5.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "CertLogic",
dependencies: ["jsonlogic", "SwiftyJSON"],
dependencies: ["JsonLogic", "SwiftyJSON"],
resources: [.process("Resources")]),
.testTarget(
name: "CertLogicTests",
dependencies: ["CertLogic", "jsonlogic", "SwiftyJSON"]),
dependencies: ["CertLogic", "JsonLogic", "SwiftyJSON"]),
]
)
2 changes: 1 addition & 1 deletion Sources/CertLogic/CertLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// Created by Alexandr Chernyy on 08.06.2021.
//
import jsonlogic
import JsonLogic
import SwiftyJSON
import Foundation

Expand Down
1 change: 1 addition & 0 deletions Sources/CertLogic/Date+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ extension Date {
var ISO8601String: String { return Date.iso8601Full.string(from: self) }

}

2 changes: 1 addition & 1 deletion Sources/CertLogic/Sequence+.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// File.swift
// Sequence.swift
//
//
// Created by Alexandr Chernyy on 07.07.2021.
Expand Down
3 changes: 1 addition & 2 deletions Tests/CertLogicTests/CertLogicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -611,13 +611,12 @@ final class CertLogicTests: XCTestCase {
}
}
"""

// "Logic": "{\\\"and\\\":[{\\\">=\\\":[{\\\"var\\\":\\\"dt\\\"},\\\"23.12.2012\\\"]},{\\\">=\\\":[{\\\"var\\\":\\\"nm\\\"},\\\"ABC\\\"]}]}"


if let externalParameter: ExternalParameter = CertLogicEngine.getItem(from: external) {
let rules: [Rule] = CertLogicEngine.getItems(from: rulesString)
let valueSet: ValueSet? = CertLogicEngine.getItem(from: valueSetString)
let _: ValueSet? = CertLogicEngine.getItem(from: valueSetString)
let engine = CertLogicEngine(schema: euDgcSchemaV1, rules: rules)
let filter = FilterParameter(validationClock: Date(), countryCode: "UA", certificationType: .vaccination)
let result = engine.validate(filter: filter, external: externalParameter, payload: payload)
Expand Down
22 changes: 11 additions & 11 deletions Tests/CertLogicTests/RuleEngineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -410,17 +410,17 @@ final class RuleEngineTests: XCTestCase {
{"==":["1","1"]}
"""), countryCode: "DE")

let rule3 = Rule(identifier: "VR-DE-0002", type: "Acceptance", version: "2.0.1", schemaVersion: "1.0.0", engine: "CERTLOGIC", engineVersion: "1.0.0", certificateType: "Vaccination", description: [Description(lang: "en", desc: "Hello")], validFrom: "2020-06-01T00:00:00Z", validTo: "2030-06-01T00:00:00Z", affectedString: ["v.0.ma"], logic: JSON("""
{"==":["1","1"]}
"""), countryCode: "DE")

let rule4 = Rule(identifier: "VR-DE-0003", type: "Acceptance", version: "0.0.1", schemaVersion: "1.0.0", engine: "CERTLOGIC", engineVersion: "1.0.0", certificateType: "Vaccination", description: [Description(lang: "en", desc: "Hello")], validFrom: "2020-06-01T00:00:00Z", validTo: "2030-06-01T00:00:00Z", affectedString: ["v.0.ma"], logic: JSON("""
{">":["1","1"]}
"""), countryCode: "DE")

let rule5 = Rule(identifier: "VR-DE-0003", type: "Acceptance", version: "3.0.1", schemaVersion: "1.0.0", engine: "CERTLOGIC", engineVersion: "1.0.0", certificateType: "Vaccination", description: [Description(lang: "en", desc: "Hello")], validFrom: "2020-06-01T00:00:00Z", validTo: "2030-06-01T00:00:00Z", affectedString: ["v.0.ma"], logic: JSON("""
{"==":["1","1"]}
"""), countryCode: "DE")
// let rule3 = Rule(identifier: "VR-DE-0002", type: "Acceptance", version: "2.0.1", schemaVersion: "1.0.0", engine: "CERTLOGIC", engineVersion: "1.0.0", certificateType: "Vaccination", description: [Description(lang: "en", desc: "Hello")], validFrom: "2020-06-01T00:00:00Z", validTo: "2030-06-01T00:00:00Z", affectedString: ["v.0.ma"], logic: JSON("""
// {"==":["1","1"]}
// """), countryCode: "DE")
//
// let rule4 = Rule(identifier: "VR-DE-0003", type: "Acceptance", version: "0.0.1", schemaVersion: "1.0.0", engine: "CERTLOGIC", engineVersion: "1.0.0", certificateType: "Vaccination", description: [Description(lang: "en", desc: "Hello")], validFrom: "2020-06-01T00:00:00Z", validTo: "2030-06-01T00:00:00Z", affectedString: ["v.0.ma"], logic: JSON("""
// {">":["1","1"]}
// """), countryCode: "DE")
//
// let rule5 = Rule(identifier: "VR-DE-0003", type: "Acceptance", version: "3.0.1", schemaVersion: "1.0.0", engine: "CERTLOGIC", engineVersion: "1.0.0", certificateType: "Vaccination", description: [Description(lang: "en", desc: "Hello")], validFrom: "2020-06-01T00:00:00Z", validTo: "2030-06-01T00:00:00Z", affectedString: ["v.0.ma"], logic: JSON("""
// {"==":["1","1"]}
// """), countryCode: "DE")

let engine = CertLogicEngine(schema: euDgcSchemaV1, rules: [rule1,rule2])

Expand Down

0 comments on commit c5103a5

Please sign in to comment.