Skip to content

Commit 92cbb50

Browse files
committed
first commit
0 parents  commit 92cbb50

34 files changed

+1722
-0
lines changed

.github/.codecov.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
codecov:
2+
notify:
3+
after_n_builds: 1
4+
wait_for_ci: false
5+
require_ci_to_pass: false
6+
comment:
7+
behavior: default
8+
layout: diff, files
9+
require_changes: true
10+
coverage:
11+
status:
12+
patch:
13+
default:
14+
branches:
15+
- ^main$
16+
informational: true
17+
only_pulls: false
18+
paths:
19+
- ^Sources.*
20+
target: auto
21+
project:
22+
default:
23+
branches:
24+
- ^main$
25+
informational: true
26+
only_pulls: false
27+
paths:
28+
- ^Sources.*
29+
target: auto
30+
github_checks:
31+
annotations: true
32+
ignore:
33+
- ^Tests/.*
34+
- ^.build/.*
35+
slack_app: false

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @fpseverino

.github/workflows/test.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: test
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref }}
4+
cancel-in-progress: true
5+
on:
6+
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
7+
push: { branches: [ main ] }
8+
9+
jobs:
10+
unit-tests:
11+
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
12+
with:
13+
with_linting: true
14+
secrets:
15+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc
9+
Package.resolved

.spi.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- documentation_targets: [FluentWallet, FluentPasses, FluentOrders]

.swift-format

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"fileScopedDeclarationPrivacy": {
3+
"accessLevel": "private"
4+
},
5+
"indentation": {
6+
"spaces": 4
7+
},
8+
"indentConditionalCompilationBlocks": true,
9+
"indentSwitchCaseLabels": false,
10+
"lineBreakAroundMultilineExpressionChainComponents": false,
11+
"lineBreakBeforeControlFlowKeywords": false,
12+
"lineBreakBeforeEachArgument": false,
13+
"lineBreakBeforeEachGenericRequirement": false,
14+
"lineLength": 140,
15+
"maximumBlankLines": 1,
16+
"multiElementCollectionTrailingCommas": true,
17+
"noAssignmentInExpressions": {
18+
"allowedFunctions": [
19+
"XCTAssertNoThrow"
20+
]
21+
},
22+
"prioritizeKeepingFunctionOutputTogether": false,
23+
"respectsExistingLineBreaks": true,
24+
"rules": {
25+
"AllPublicDeclarationsHaveDocumentation": false,
26+
"AlwaysUseLiteralForEmptyCollectionInit": false,
27+
"AlwaysUseLowerCamelCase": true,
28+
"AmbiguousTrailingClosureOverload": true,
29+
"BeginDocumentationCommentWithOneLineSummary": false,
30+
"DoNotUseSemicolons": true,
31+
"DontRepeatTypeInStaticProperties": true,
32+
"FileScopedDeclarationPrivacy": true,
33+
"FullyIndirectEnum": true,
34+
"GroupNumericLiterals": true,
35+
"IdentifiersMustBeASCII": true,
36+
"NeverForceUnwrap": false,
37+
"NeverUseForceTry": false,
38+
"NeverUseImplicitlyUnwrappedOptionals": false,
39+
"NoAccessLevelOnExtensionDeclaration": true,
40+
"NoAssignmentInExpressions": true,
41+
"NoBlockComments": true,
42+
"NoCasesWithOnlyFallthrough": true,
43+
"NoEmptyTrailingClosureParentheses": true,
44+
"NoLabelsInCasePatterns": true,
45+
"NoLeadingUnderscores": false,
46+
"NoParensAroundConditions": true,
47+
"NoPlaygroundLiterals": true,
48+
"NoVoidReturnOnFunctionSignature": true,
49+
"OmitExplicitReturns": false,
50+
"OneCasePerLine": true,
51+
"OneVariableDeclarationPerLine": true,
52+
"OnlyOneTrailingClosureArgument": true,
53+
"OrderedImports": true,
54+
"ReplaceForEachWithForLoop": true,
55+
"ReturnVoidInsteadOfEmptyTuple": true,
56+
"TypeNamesShouldBeCapitalized": true,
57+
"UseEarlyExits": false,
58+
"UseExplicitNilCheckInConditions": true,
59+
"UseLetInEveryBoundCaseVariable": true,
60+
"UseShorthandTypeNames": true,
61+
"UseSingleLinePropertyGetter": true,
62+
"UseSynthesizedInitializer": true,
63+
"UseTripleSlashForDocumentationComments": true,
64+
"UseWhereClausesInForLoops": false,
65+
"ValidateDocumentationComments": false
66+
},
67+
"spacesAroundRangeFormationOperators": false,
68+
"tabWidth": 4,
69+
"version": 1
70+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Francesco Paolo Severino
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Package.swift

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// swift-tools-version: 6.0
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "fluent-wallet",
6+
platforms: [
7+
.macOS(.v13)
8+
],
9+
products: [
10+
.library(name: "FluentPasses", targets: ["FluentPasses"]),
11+
.library(name: "FluentOrders", targets: ["FluentOrders"]),
12+
],
13+
dependencies: [
14+
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.49.0")
15+
],
16+
targets: [
17+
.target(
18+
name: "FluentWallet",
19+
dependencies: [
20+
.product(name: "FluentKit", package: "fluent-kit")
21+
],
22+
swiftSettings: swiftSettings
23+
),
24+
.target(
25+
name: "FluentPasses",
26+
dependencies: [
27+
.target(name: "FluentWallet")
28+
],
29+
swiftSettings: swiftSettings
30+
),
31+
.target(
32+
name: "FluentOrders",
33+
dependencies: [
34+
.target(name: "FluentWallet")
35+
],
36+
swiftSettings: swiftSettings
37+
),
38+
.testTarget(
39+
name: "FluentWalletTests",
40+
dependencies: [
41+
.target(name: "FluentWallet")
42+
],
43+
swiftSettings: swiftSettings
44+
),
45+
.testTarget(
46+
name: "FluentPassesTests",
47+
dependencies: [
48+
.target(name: "FluentPasses")
49+
],
50+
swiftSettings: swiftSettings
51+
),
52+
.testTarget(
53+
name: "FluentOrdersTests",
54+
dependencies: [
55+
.target(name: "FluentOrders")
56+
],
57+
swiftSettings: swiftSettings
58+
),
59+
]
60+
)
61+
62+
var swiftSettings: [SwiftSetting] {
63+
[
64+
.enableUpcomingFeature("ExistentialAny")
65+
]
66+
}

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# FluentWallet
2+
3+
🎟️ 📦 A collection of Fluent models for managing passes and orders for Apple Wallet.
4+
5+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Ffpseverino%2Ffluent-wallet%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/fpseverino/fluent-wallet)
6+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Ffpseverino%2Ffluent-wallet%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/fpseverino/fluent-wallet)
7+
8+
[![](https://img.shields.io/github/actions/workflow/status/fpseverino/fluent-wallet/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc)](https://github.com/fpseverino/fluent-wallet/actions/workflows/test.yml)
9+
[![](https://img.shields.io/codecov/c/github/fpseverino/fluent-wallet?style=plastic&logo=codecov&label=codecov)](https://codecov.io/github/fpseverino/fluent-wallet)
10+
11+
## Overview
12+
13+
This package provides a collection of Fluent protocol and concrete models, useful for managing the creation and update of passes and orders for the Apple Wallet app with your Swift on Server application.
14+
15+
### Getting Started
16+
17+
Use the SPM string to easily include the dependendency in your `Package.swift` file
18+
19+
```swift
20+
.package(url: "https://github.com/fpseverino/fluent-wallet.git", branch: "main")
21+
```
22+
23+
and add it to your target's dependencies:
24+
25+
```swift
26+
.product(name: "FluentPasses", package: "fluent-wallet")
27+
```
28+
29+
```swift
30+
.product(name: "FluentOrders", package: "fluent-wallet")
31+
```
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/// The structure of a `order.json` file.
2+
public enum OrderJSON {
3+
/// A protocol that defines the structure of a `order.json` file.
4+
///
5+
/// > Tip: See the [`Order`](https://developer.apple.com/documentation/walletorders/order) object to understand the keys.
6+
public protocol Properties: Encodable {
7+
/// The date and time when the customer created the order, in RFC 3339 format.
8+
var createdAt: String { get }
9+
10+
/// A unique order identifier scoped to your order type identifier.
11+
///
12+
/// In combination with the order type identifier, this uniquely identifies an order within the system and isn’t displayed to the user.
13+
var orderIdentifier: String { get }
14+
15+
/// A URL where the customer can manage the order.
16+
var orderManagementURL: String { get }
17+
18+
/// The type of order this bundle represents.
19+
///
20+
/// Currently the only supported value is `ecommerce`.
21+
var orderType: OrderType { get }
22+
23+
/// An identifier for the order type associated with the order.
24+
///
25+
/// The value must correspond with your signing certificate and isn’t displayed to the user.
26+
var orderTypeIdentifier: String { get }
27+
28+
/// A high-level status of the order, used for display purposes.
29+
///
30+
/// The system considers orders with status `completed` or `cancelled` closed.
31+
var status: OrderStatus { get }
32+
33+
/// The version of the schema used for the order.
34+
///
35+
/// The current version is `1`.
36+
var schemaVersion: SchemaVersion { get }
37+
38+
/// The date and time when the order was last updated, in RFC 3339 format.
39+
///
40+
/// This should equal the `createdAt` time, if the order hasn’t had any updates.
41+
/// Must be monotonically increasing.
42+
/// Consider using a hybrid logical clock if your web service can’t make that guarantee.
43+
var updatedAt: String { get }
44+
}
45+
}
46+
47+
extension OrderJSON {
48+
/// A protocol that represents the merchant associated with the order.
49+
///
50+
/// > Tip: See the [`Order.Merchant`](https://developer.apple.com/documentation/walletorders/merchant) object to understand the keys.
51+
public protocol Merchant: Encodable {
52+
/// The localized display name of the merchant.
53+
var displayName: String { get }
54+
55+
/// The Apple Merchant Identifier for this merchant, generated at `developer.apple.com`.
56+
var merchantIdentifier: String { get }
57+
58+
/// The URL for the merchant’s website or landing page.
59+
var url: String { get }
60+
}
61+
}
62+
63+
extension OrderJSON {
64+
/// A protocol that represents the details of a barcode for an order.
65+
///
66+
/// > Tip: See the [`Order.Barcode`](https://developer.apple.com/documentation/walletorders/barcode) object to understand the keys.
67+
public protocol Barcode: Encodable {
68+
/// The format of the barcode.
69+
var format: BarcodeFormat { get }
70+
71+
/// The contents of the barcode.
72+
var message: String { get }
73+
74+
/// The text encoding of the barcode message.
75+
///
76+
/// Typically this is `iso-8859-1`, but you may specify an alternative encoding if required.
77+
var messageEncoding: String { get }
78+
}
79+
}
80+
81+
extension OrderJSON {
82+
/// The type of order this bundle represents.
83+
public enum OrderType: String, Encodable {
84+
case ecommerce
85+
}
86+
87+
/// A high-level status of the order, used for display purposes.
88+
public enum OrderStatus: String, Encodable {
89+
case completed
90+
case cancelled
91+
case open
92+
}
93+
94+
/// The version of the schema used for the order.
95+
public enum SchemaVersion: Int, Encodable {
96+
case v1 = 1
97+
}
98+
99+
/// The format of the barcode.
100+
public enum BarcodeFormat: String, Encodable {
101+
case pdf417
102+
case qr
103+
case aztec
104+
case code128
105+
}
106+
}

0 commit comments

Comments
 (0)