Skip to content

Commit 4bc14f0

Browse files
committed
Switch from Codable to Encodable for JSON protocols
1 parent ada81cd commit 4bc14f0

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

Sources/WalletOrders/OrderJSON.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ public enum OrderJSON {
33
/// A protocol that defines the structure of a `order.json` file.
44
///
55
/// > Tip: See the [`Order`](https://developer.apple.com/documentation/walletorders/order) object to understand the keys.
6-
public protocol Properties: Codable, Sendable {
6+
public protocol Properties: Encodable, Sendable {
77
/// The date and time when the customer created the order, in RFC 3339 format.
88
var createdAt: String { get }
99

@@ -48,7 +48,7 @@ extension OrderJSON {
4848
/// A protocol that represents the merchant associated with the order.
4949
///
5050
/// > Tip: See the [`Order.Merchant`](https://developer.apple.com/documentation/walletorders/merchant) object to understand the keys.
51-
public protocol Merchant: Codable, Sendable {
51+
public protocol Merchant: Encodable, Sendable {
5252
/// The localized display name of the merchant.
5353
var displayName: String { get }
5454

@@ -64,7 +64,7 @@ extension OrderJSON {
6464
/// A protocol that represents the details of a barcode for an order.
6565
///
6666
/// > Tip: See the [`Order.Barcode`](https://developer.apple.com/documentation/walletorders/barcode) object to understand the keys.
67-
public protocol Barcode: Codable, Sendable {
67+
public protocol Barcode: Encodable, Sendable {
6868
/// The format of the barcode.
6969
var format: BarcodeFormat { get }
7070

Sources/WalletPasses/PassJSON.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ public enum PassJSON {
33
/// A protocol that defines the structure of a `pass.json` file.
44
///
55
/// > Tip: See the [`Pass`](https://developer.apple.com/documentation/walletpasses/pass) object to understand the keys.
6-
public protocol Properties: Codable, Sendable {
6+
public protocol Properties: Encodable, Sendable {
77
/// A short description that iOS accessibility technologies use for a pass.
88
var description: String { get }
99

@@ -34,7 +34,7 @@ extension PassJSON {
3434
/// A protocol that represents the information to display in a field on a pass.
3535
///
3636
/// > Tip: See the [`PassFieldContent`](https://developer.apple.com/documentation/walletpasses/passfieldcontent) object to understand the keys.
37-
public protocol PassFieldContent: Codable, Sendable {
37+
public protocol PassFieldContent: Encodable, Sendable {
3838
/// A unique key that identifies a field in the pass; for example, `departure-gate`.
3939
var key: String { get }
4040

@@ -49,7 +49,7 @@ extension PassJSON {
4949
/// A protocol that represents the groups of fields that display the information for a boarding pass.
5050
///
5151
/// > Tip: See the [`Pass.BoardingPass`](https://developer.apple.com/documentation/walletpasses/pass/boardingpass) object to understand the keys.
52-
public protocol BoardingPass: Codable, Sendable {
52+
public protocol BoardingPass: Encodable, Sendable {
5353
/// The type of transit for a boarding pass.
5454
///
5555
/// This key is invalid for other types of passes.
@@ -64,7 +64,7 @@ extension PassJSON {
6464
/// A protocol that represents a barcode on a pass.
6565
///
6666
/// > Tip: See the [`Pass.Barcodes`](https://developer.apple.com/documentation/walletpasses/pass/barcodes) object to understand the keys.
67-
public protocol Barcodes: Codable, Sendable {
67+
public protocol Barcodes: Encodable, Sendable {
6868
/// The format of the barcode.
6969
///
7070
/// The barcode format `PKBarcodeFormatCode128` isn’t supported for watchOS.
@@ -83,7 +83,7 @@ extension PassJSON {
8383
/// A protocol that represents a location that the system uses to show a relevant pass.
8484
///
8585
/// > Tip: See the [`Pass.Locations`](https://developer.apple.com/documentation/walletpasses/pass/locations) object to understand the keys.
86-
public protocol Locations: Codable, Sendable {
86+
public protocol Locations: Encodable, Sendable {
8787
/// The latitude, in degrees, of the location.
8888
var latitude: Double { get }
8989

@@ -96,7 +96,7 @@ extension PassJSON {
9696
/// An object that represents the near-field communication (NFC) payload the device passes to an Apple Pay terminal.
9797
///
9898
/// > Tip: See the [`Pass.NFC`](https://developer.apple.com/documentation/walletpasses/pass/nfc) object to understand the keys.
99-
public protocol NFC: Codable, Sendable {
99+
public protocol NFC: Encodable, Sendable {
100100
/// The payload the device transmits to the Apple Pay terminal.
101101
///
102102
/// The size must be no more than 64 bytes.

Tests/WalletOrdersTests/TestOrder.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22
import WalletOrders
33

4-
struct TestOrder: OrderJSON.Properties {
4+
struct TestOrder: OrderJSON.Properties, Decodable {
55
var schemaVersion = OrderJSON.SchemaVersion.v1
66
var orderTypeIdentifier = "order.com.example.swift-wallet"
77
var orderIdentifier = UUID().uuidString
@@ -15,7 +15,7 @@ struct TestOrder: OrderJSON.Properties {
1515
var authenticationToken = UUID().uuidString
1616
var webServiceURL = "https://www.example.com/api/orders/"
1717

18-
struct MerchantData: OrderJSON.Merchant {
18+
struct MerchantData: OrderJSON.Merchant, Decodable {
1919
var merchantIdentifier = "com.example.pet-store"
2020
var displayName = "Pet Store"
2121
var url = "https://www.example.com/"

Tests/WalletPassesTests/TestPass.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22
import WalletPasses
33

4-
struct TestPass: PassJSON.Properties {
4+
struct TestPass: PassJSON.Properties, Decodable {
55
var description = "Test Pass"
66
var formatVersion = PassJSON.FormatVersion.v1
77
var organizationName = "example"
@@ -15,23 +15,23 @@ struct TestPass: PassJSON.Properties {
1515
var backgroundColor = "rgb(207, 77, 243)"
1616
var foregroundColor = "rgb(255, 255, 255)"
1717

18-
var barcodes = Barcode(message: "test")
19-
struct Barcode: PassJSON.Barcodes {
18+
var barcodes = [Barcode(message: "test")]
19+
struct Barcode: PassJSON.Barcodes, Decodable {
2020
var format = PassJSON.BarcodeFormat.qr
2121
var message: String
2222
var messageEncoding = "iso-8859-1"
2323
}
2424

2525
var boardingPass = Boarding(transitType: .air)
26-
struct Boarding: PassJSON.BoardingPass {
26+
struct Boarding: PassJSON.BoardingPass, Decodable {
2727
let transitType: PassJSON.TransitType
2828
let headerFields: [PassField]
2929
let primaryFields: [PassField]
3030
let secondaryFields: [PassField]
3131
let auxiliaryFields: [PassField]
3232
let backFields: [PassField]
3333

34-
struct PassField: PassJSON.PassFieldContent {
34+
struct PassField: PassJSON.PassFieldContent, Decodable {
3535
let key: String
3636
let label: String
3737
let value: String

0 commit comments

Comments
 (0)