Skip to content

Commit

Permalink
Version 0.6.0 (#10)
Browse files Browse the repository at this point in the history
- Complete Pass Personalization implementation
- Refactor APNs setup and routes registration
- Change `PKPass` schema to `Pass`
- Move from `openssl` to `swift-certificates` for unencrypted private keys
- Move to `vapor-community/Zip` for bundle compression
- Add unit tests
- Various improvements 

---------

Co-authored-by: Paul Toffoloni <[email protected]>
  • Loading branch information
fpseverino and ptoffy authored Aug 21, 2024
1 parent 06b3143 commit 381051c
Show file tree
Hide file tree
Showing 60 changed files with 3,106 additions and 1,482 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ on:

jobs:
unit-tests:
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
20 changes: 18 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ let package = Package(
.library(name: "Orders", targets: ["Orders"]),
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", from: "4.102.0"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.103.1"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.11.0"),
.package(url: "https://github.com/vapor/apns.git", from: "4.1.0"),
.package(url: "https://github.com/vapor/apns.git", from: "4.2.0"),
.package(url: "https://github.com/vapor-community/Zip.git", from: "2.2.0"),
.package(url: "https://github.com/apple/swift-certificates.git", from: "1.5.0"),
// used in tests
.package(url: "https://github.com/vapor/fluent-sqlite-driver.git", from: "4.7.4"),
],
targets: [
.target(
Expand All @@ -22,6 +26,8 @@ let package = Package(
.product(name: "Fluent", package: "fluent"),
.product(name: "Vapor", package: "vapor"),
.product(name: "VaporAPNS", package: "apns"),
.product(name: "Zip", package: "zip"),
.product(name: "X509", package: "swift-certificates"),
],
swiftSettings: swiftSettings
),
Expand All @@ -43,15 +49,25 @@ let package = Package(
name: "PassesTests",
dependencies: [
.target(name: "Passes"),
.target(name: "PassKit"),
.product(name: "XCTVapor", package: "vapor"),
.product(name: "FluentSQLiteDriver", package: "fluent-sqlite-driver"),
],
resources: [
.copy("Templates"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "OrdersTests",
dependencies: [
.target(name: "Orders"),
.target(name: "PassKit"),
.product(name: "XCTVapor", package: "vapor"),
.product(name: "FluentSQLiteDriver", package: "fluent-sqlite-driver"),
],
resources: [
.copy("Templates"),
],
swiftSettings: swiftSettings
),
Expand Down
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<img src="https://avatars.githubusercontent.com/u/26165732?s=200&v=4" width="100" height="100" alt="avatar" />
<h1>PassKit</h1>
<a href="https://swiftpackageindex.com/vapor-community/PassKit/0.5.0/documentation/passkit">
<a href="https://swiftpackageindex.com/vapor-community/PassKit/documentation">
<img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation">
</a>
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
Expand All @@ -20,21 +20,10 @@

🎟️ 📦 Create, distribute, and update passes and orders for the Apple Wallet app with Vapor.

### Major Releases

The table below shows a list of PassKit major releases alongside their compatible Swift versions.

|Version|Swift|SPM|
|---|---|---|
|0.5.0|5.10+|`from: "0.5.0"`|
|0.4.0|5.10+|`from: "0.4.0"`|
|0.2.0|5.9+|`from: "0.2.0"`|
|0.1.0|5.9+|`from: "0.1.0"`|

Use the SPM string to easily include the dependendency in your `Package.swift` file.

```swift
.package(url: "https://github.com/vapor-community/PassKit.git", from: "0.5.0")
.package(url: "https://github.com/vapor-community/PassKit.git", from: "0.6.0")
```

> Note: This package is made for Vapor 4.
Expand All @@ -50,7 +39,7 @@ Add the `Passes` product to your target's dependencies:
.product(name: "Passes", package: "PassKit")
```

See the framework's [documentation](https://swiftpackageindex.com/vapor-community/PassKit/0.5.0/documentation/passes) for information on how to use it.
See the framework's [documentation](https://swiftpackageindex.com/vapor-community/PassKit/documentation/passes) for information and guides on how to use it.

For information on Apple Wallet passes, see the [Apple Developer Documentation](https://developer.apple.com/documentation/walletpasses).

Expand All @@ -65,6 +54,6 @@ Add the `Orders` product to your target's dependencies:
.product(name: "Orders", package: "PassKit")
```

See the framework's [documentation](https://swiftpackageindex.com/vapor-community/PassKit/0.5.0/documentation/orders) for information on how to use it.
See the framework's [documentation](https://swiftpackageindex.com/vapor-community/PassKit/documentation/orders) for information and guides on how to use it.

For information on Apple Wallet orders, see the [Apple Developer Documentation](https://developer.apple.com/documentation/walletorders).
54 changes: 40 additions & 14 deletions Sources/Orders/DTOs/OrderJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,40 @@ public struct OrderJSON {
}
}

extension OrderJSON {
/// A protocol that represents the merchant associated with the order.
///
/// > Tip: See the [`Order.Merchant`](https://developer.apple.com/documentation/walletorders/merchant) object to understand the keys.
public protocol Merchant: Encodable {
/// The localized display name of the merchant.
var displayName: String { get }

/// The Apple Merchant Identifier for this merchant, generated at `developer.apple.com`.
var merchantIdentifier: String { get }

/// The URL for the merchant’s website or landing page.
var url: String { get }
}
}

extension OrderJSON {
/// A protocol that represents the details of a barcode for an order.
///
/// > Tip: See the [`Order.Barcode`](https://developer.apple.com/documentation/walletorders/barcode) object to understand the keys.
public protocol Barcode: Encodable {
/// The format of the barcode.
var format: BarcodeFormat { get }

/// The contents of the barcode.
var message: String { get }

/// The text encoding of the barcode message.
///
/// Typically this is `iso-8859-1`, but you may specify an alternative encoding if required.
var messageEncoding: String { get }
}
}

extension OrderJSON {
/// The type of order this bundle represents.
public enum OrderType: String, Encodable {
Expand All @@ -68,20 +102,12 @@ extension OrderJSON {
public enum SchemaVersion: Int, Encodable {
case v1 = 1
}
}

extension OrderJSON {
/// A protocol that represents the merchant associated with the order.
///
/// > Tip: See the [`Order.Merchant`](https://developer.apple.com/documentation/walletorders/merchant) object to understand the keys.
public protocol Merchant: Encodable {
/// The localized display name of the merchant.
var displayName: String { get }

/// The Apple Merchant Identifier for this merchant, generated at `developer.apple.com`.
var merchantIdentifier: String { get }

/// The URL for the merchant’s website or landing page.
var url: String { get }
/// The format of the barcode.
public enum BarcodeFormat: String, Encodable {
case pdf417
case qr
case aztec
case code128
}
}
6 changes: 1 addition & 5 deletions Sources/Orders/DTOs/OrdersForDeviceDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ struct OrdersForDeviceDTO: Content {

init(with orderIdentifiers: [String], maxDate: Date) {
self.orderIdentifiers = orderIdentifiers
self.lastModified = ISO8601DateFormatter.string(
from: maxDate,
timeZone: .init(secondsFromGMT: 0)!,
formatOptions: .withInternetDateTime
)
self.lastModified = String(maxDate.timeIntervalSince1970)
}
}
2 changes: 1 addition & 1 deletion Sources/Orders/Models/Concrete Models/Order.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import FluentKit

/// The `Model` that stores Wallet orders.
open class Order: OrderModel, @unchecked Sendable {
final public class Order: OrderModel, @unchecked Sendable {
/// The schema name of the order model.
public static let schema = Order.FieldKeys.schemaName

Expand Down
9 changes: 0 additions & 9 deletions Sources/Orders/Models/OrderModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ internal extension OrderModel {

return orderTypeIdentifier
}

var _$createdAt: Timestamp<DefaultTimestampFormat> {
guard let mirror = Mirror(reflecting: self).descendant("_createdAt"),
let createdAt = mirror as? Timestamp<DefaultTimestampFormat> else {
fatalError("createdAt property must be declared using @Timestamp(on: .create)")
}

return createdAt
}

var _$updatedAt: Timestamp<DefaultTimestampFormat> {
guard let mirror = Mirror(reflecting: self).descendant("_updatedAt"),
Expand Down
181 changes: 0 additions & 181 deletions Sources/Orders/Orders.docc/DistributeUpdate.md

This file was deleted.

Loading

0 comments on commit 381051c

Please sign in to comment.