Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JsonKey with name #78

Merged
merged 1 commit into from
Aug 29, 2024
Merged
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
4 changes: 4 additions & 0 deletions passkit/lib/src/pkpass/barcode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,26 @@ class Barcode {

/// Optional. Text displayed near the barcode. For example, a human-readable
/// version of the barcode data in case the barcode doesn’t scan.
@JsonKey(name: 'altText')
final String? altText;

/// Required. Barcode format. For the barcode dictionary, you can use only the
/// following values: PKBarcodeFormatQR, PKBarcodeFormatPDF417, or
/// PKBarcodeFormatAztec. For dictionaries in the barcodes array, you may also
/// use PKBarcodeFormatCode128.
@JsonKey(name: 'format')
final PkPassBarcodeType format;

/// Required. Message or payload to be displayed as a barcode.
@JsonKey(name: 'message')
final String message;

/// Required. Text encoding that is used to convert the message from the
/// string representation to a data representation to render the barcode.
/// The value is typically iso-8859-1, but you may use another encoding that
/// is supported by your barcode scanning infrastructure.
// IANA character set name, as a string
@JsonKey(name: 'messageEncoding')
final String messageEncoding;

/// Converts this instance to a JSON object
Expand Down
4 changes: 4 additions & 0 deletions passkit/lib/src/pkpass/beacon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ class Beacon {

/// Optional. Major identifier of a Bluetooth Low Energy location beacon.
// 16-bit unsigned integer
@JsonKey(name: 'major')
final int? major;

/// Optional. Minor identifier of a Bluetooth Low Energy location beacon.
// 16-bit unsigned integer
@JsonKey(name: 'minor')
final int? minor;

/// Required. Unique identifier of a Bluetooth Low Energy location beacon.
@JsonKey(name: 'proximityUUID')
final String proximityUUID;

/// Optional. Text displayed on the lock screen when the pass is currently
/// relevant. For example, a description of the nearby location such as
/// “Store nearby on 1st and Main.”
@JsonKey(name: 'relevantText')
final String? relevantText;

/// Converts this instance to a JSON object
Expand Down
15 changes: 15 additions & 0 deletions passkit/lib/src/pkpass/field_dict.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class FieldDict {
/// This key’s value overrides the text specified by the value key.
/// Available in iOS 7.0.
// localizable string, ISO 8601 date as a string, or number
@JsonKey(name: 'attributedValue')
final String? attributedValue;

/// Optional. Format string for the alert text that is displayed when the pass
Expand All @@ -47,6 +48,7 @@ class FieldDict {
/// If you don’t specify a change message, the user isn’t notified when the
/// field changes.
// localizable format string
@JsonKey(name: 'changeMessage')
final String? changeMessage;

/// Optional. Data detectors that are applied to the field’s value.
Expand All @@ -60,14 +62,17 @@ class FieldDict {
/// no data detectors.
///
/// Data detectors are applied only to back fields.
@JsonKey(name: 'dataDetectorTypes')
final List<DataDetectorTypes>? dataDetectorTypes;

/// Required. The key must be unique within the scope of the entire pass.
/// For example, “departure-gate.”
@JsonKey(name: 'key')
final String key;

/// Optional. Label text for the field.
// localizable string
@JsonKey(name: 'label')
final String? label;

/// Optional. Alignment for the field’s contents.
Expand All @@ -82,25 +87,31 @@ class FieldDict {
/// appropriately based on its script direction.
///
/// This key is not allowed for primary fields or back fields.
@JsonKey(name: 'textAlignment')
final PkTextAlignment textAlignment;

/// Required. Value of the field, for example, 42.
/// This can contain a localizable string, ISO 8601 date as a string,
/// or a number (double/int)
@JsonKey(name: 'value')
final Object? value;

/// The currency code to use for the value of the field.
/// ISO 4217 currency code as a string
@JsonKey(name: 'currencyCode')
final String? currencyCode;

/// The style of the date to display in the field.
@JsonKey(name: 'dateStyle')
final DateStyle? dateStyle;

/// The style of the time displayed in the field.
@JsonKey(name: 'timeStyle')
final DateStyle? timeStyle;

/// The style of the number to display in the field. Formatter styles have the same meaning as the formats with corresponding names in NumberFormatter.Style.
/// Possible Values: PKNumberStyleDecimal, PKNumberStylePercent, PKNumberStyleScientific, PKNumberStyleSpellOut
@JsonKey(name: 'numberStyle')
final NumberStyle? numberStyle;

/// A Boolean value that controls the time zone for the time and date to
Expand All @@ -109,12 +120,14 @@ class FieldDict {
/// date appear in the time zone associated with the date and time of value.
///
/// This key doesn’t affect the pass relevance calculation.
@JsonKey(name: 'ignoresTimeZone')
final bool? ignoresTimeZone;

/// A Boolean value that controls whether the date appears as a relative date.
/// The default value is false, which displays the date as an absolute date.
///
/// This key doesn’t affect the pass relevance calculation.
@JsonKey(name: 'isRelative')
final bool? isRelative;

/// You can augment the user-visible information on Wallet passes with
Expand All @@ -124,6 +137,7 @@ class FieldDict {
///
/// An object that contains machine-readable metadata the system uses to offer
/// a pass and suggest related actions.
@JsonKey(name: 'semantics')
final Semantics? semantics;

/// A number you use to add a row to the auxiliary field in an event ticket
Expand All @@ -132,6 +146,7 @@ class FieldDict {
///
/// Possible Values: 0, 1
/// This field is only valid for event pass types.
@JsonKey(name: 'row')
final int? row;

String? formatted({String? locale}) {
Expand Down
4 changes: 4 additions & 0 deletions passkit/lib/src/pkpass/location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ class Location {
Map<String, dynamic> toJson() => _$LocationToJson(this);

/// Optional. Altitude, in meters, of the location.
@JsonKey(name: 'altitude')
final double? altitude;

/// Required. Latitude, in degrees, of the location.
@JsonKey(name: 'latitude')
final double latitude;

/// Required. Longitude, in degrees, of the location.
@JsonKey(name: 'longitude')
final double longitude;

/// Optional. Text displayed on the lock screen when the pass is currently
/// relevant. For example, a description of the nearby location such as
/// “Store nearby on 1st and Main.”
@JsonKey(name: 'relevantText')
final String? relevantText;
}
3 changes: 3 additions & 0 deletions passkit/lib/src/pkpass/nfc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ class Nfc {
/// Required. The payload to be transmitted to the Apple Pay terminal.
/// Must be 64 bytes or less. Messages longer than 64 bytes are truncated by
/// the system.
@JsonKey(name: 'message')
final String message;

/// Optional. The public encryption key used by the Value Added Services
/// protocol. Use a Base64 encoded X.509 SubjectPublicKeyInfo structure
/// containing a ECDH public key for group P256.
@JsonKey(name: 'encryptionPublicKey')
final String? encryptionPublicKey;

/// A Boolean value that indicates whether the NFC pass requires
Expand All @@ -32,5 +34,6 @@ class Nfc {
/// This key is valid in iOS 13.1 and later. Set sharingProhibited to `true`
/// to prevent users from sharing passes with older iOS versions and bypassing
/// the authentication requirement.
@JsonKey(name: 'requiresAuthentication')
final bool? requiresAuthentication;
}
36 changes: 33 additions & 3 deletions passkit/lib/src/pkpass/pass_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,33 @@ class PassData {
/// Don't try to include all of the data on the pass in its description,
/// just include enough detail to distinguish passes of the same type.
// localizable
@JsonKey(name: 'description')
final String description;

/// Required. Version of the file format. The value must be 1.
@JsonKey(name: 'formatVersion')
final int formatVersion;

/// Required. Display name of the organization that originated and signed the
/// pass.
// localizable
@JsonKey(name: 'organizationName')
final String organizationName;

/// Required. Pass type identifier, as issued by Apple. The value must
/// correspond with your signing certificate.
@JsonKey(name: 'passTypeIdentifier')
final String passTypeIdentifier;

/// Required. Serial number that uniquely identifies the pass.
/// No two passes with the same pass type identifier may have the same
/// serial number.
@JsonKey(name: 'serialNumber')
final String serialNumber;

/// Required. Team identifier of the organization that originated and signed
/// the pass, as issued by Apple.
@JsonKey(name: 'teamIdentifier')
final String teamIdentifier;

/// Optional. A URL to be passed to the associated app when launching it.
Expand All @@ -88,6 +94,7 @@ class PassData {
/// application:openURL:options: methods of its app delegate.
/// If this key is present, the associatedStoreIdentifiers key must also be
/// present.
@JsonKey(name: 'appLaunchURL')
final String? appLaunchURL;

/// Optional. A list of iTunes Store item identifiers for the associated apps.
Expand All @@ -96,6 +103,7 @@ class PassData {
/// compatible with the current device. If the app is not installed, the link
/// opens the App Store and shows the app. If the app is already installed,
/// the link launches the app.
@JsonKey(name: 'associatedStoreIdentifiers')
final List<int>? associatedStoreIdentifiers;

/// Optional. Custom information for companion apps. This data is not
Expand All @@ -105,34 +113,40 @@ class PassData {
/// app to read, making it easy to place an order for “the usual” from the
/// app.
/// Available in iOS 7.0.
@JsonKey(name: 'userInfo')
final Map<String, dynamic>? userInfo;

/// Optional. Date and time when the pass expires.
/// The value must be a complete date with hours and minutes, and may
/// optionally include seconds.
/// Available in iOS 7.0.
// W3C date, as a string
@JsonKey(name: 'expirationDate')
final DateTime? expirationDate;

/// Optional. Indicates that the pass is void—for example, a one time use
/// coupon that has been redeemed. The default value is false.
/// Available in iOS 7.0.
@JsonKey(name: 'voided')
final bool? voided;

/// Optional. Beacons marking locations where the pass is relevant.
/// For these dictionaries’ keys, see Beacon Dictionary Keys
/// Available in iOS 7.0.
@JsonKey(name: 'beacons')
final List<Beacon>? beacons;

/// Optional. Locations where the pass is relevant. For example, the location
/// of your store.
/// For these dictionaries’ keys, see Location Dictionary Keys.
@JsonKey(name: 'locations')
final List<Location>? locations;

/// Optional. Maximum distance in meters from a relevant latitude and
/// longitude that the pass is relevant. This number is compared to the pass’s
/// default distance and the smaller value is used.
/// Available in iOS 7.0.
@JsonKey(name: 'maxDistance')
final num? maxDistance;

/// Recommended for event tickets and boarding passes; otherwise optional.
Expand All @@ -141,43 +155,51 @@ class PassData {
/// The value must be a complete date with hours and minutes, and may
/// optionally include seconds.
// W3C date, as a string
@JsonKey(name: 'relevantDate')
final DateTime? relevantDate;

/// Information specific to a boarding pass.
@JsonKey(name: 'boardingPass')
final PassStructure? boardingPass;

/// Information specific to a coupon.
@JsonKey(name: 'coupon')
final PassStructure? coupon;

/// Information specific to an event ticket.
@JsonKey(name: 'eventTicket')
final PassStructure? eventTicket;

/// Information specific to a generic pass.
@JsonKey(name: 'generic')
final PassStructure? generic;

/// Information specific to a store card.
@JsonKey(name: 'storeCard')
final PassStructure? storeCard;

/// Optional. Information specific to the pass’s barcode. For this
/// dictionary’s keys, see Barcode Dictionary Keys.
/// Note:Deprecated in iOS 9.0 and later; use barcodes instead.
@JsonKey(name: 'barcode')
final Barcode? barcode;

/// Optional. Information specific to the pass’s barcode. The system uses the
/// first valid barcode dictionary in the array. Additional dictionaries can
/// be added as fallbacks. For this dictionary’s keys,
/// see Barcode Dictionary Keys.
/// Note: Available only in iOS 9.0 and later.
@JsonKey(name: 'barcodes')
final List<Barcode>? barcodes;

/// Optional. Background color of the pass, specified as an CSS-style RGB
/// triple. For example, rgb(23, 187, 82).
@JsonKey(fromJson: parseColor, toJson: colorToString)
@JsonKey(name: 'backgroundColor', fromJson: parseColor, toJson: colorToString)
final Color? backgroundColor;

/// Optional. Foreground color of the pass, specified as a CSS-style RGB
/// triple. For example, rgb(100, 10, 110).
@JsonKey(fromJson: parseColor, toJson: colorToString)
@JsonKey(name: 'foregroundColor', fromJson: parseColor, toJson: colorToString)
final Color? foregroundColor;

/// Optional for event tickets and boarding passes; otherwise not allowed.
Expand All @@ -188,31 +210,36 @@ class PassData {
/// Use this to group passes that are tightly related, such as the boarding
/// passes for different connections of the same trip.
/// Available in iOS 7.0.
@JsonKey(name: 'groupingIdentifier')
final String? groupingIdentifier;

/// Optional. Color of the label text, specified as a CSS-style RGB triple.
/// For example, rgb(255, 255, 255).
/// If omitted, the label color is determined automatically.
@JsonKey(fromJson: parseColor, toJson: colorToString)
@JsonKey(name: 'labelColor', fromJson: parseColor, toJson: colorToString)
final Color? labelColor;

/// Optional. Text displayed next to the logo on the pass.
// localizable string
@JsonKey(name: 'logoText')
final String? logoText;

/// Optional. If true, the strip image is displayed without a shine effect.
/// The default value prior to iOS 7.0 is false.
/// In iOS 7.0, a shine effect is never applied, and this key is deprecated.
@JsonKey(name: 'suppressStripShine')
final bool? suppressStripShine;

/// A Boolean value introduced in iOS 11 that controls whether to show the
/// Share button on the back of a pass. A value of true removes the button.
/// The default value is false. This flag has no effect in earlier versions of
/// iOS, nor does it prevent sharing the pass in some other way.
@JsonKey(name: 'sharingProhibited')
final bool? sharingProhibited;

/// The authentication token to use with the web service. The token must be 16
/// characters or longer.
@JsonKey(name: 'authenticationToken')
final String? authenticationToken;

/// The URL of a web service that conforms to the API described in PassKit Web
Expand All @@ -221,11 +248,13 @@ class PassData {
/// included in the value of this key.
/// On devices configured for development, there is UI in Settings to allow
/// HTTP web services.
@JsonKey(name: 'webServiceURL')
final Uri? webServiceURL;

/// Optional. Information used for Value Added Service Protocol transactions.
/// For this dictionary’s keys, see NFC Dictionary Keys.
/// Available in iOS 9.0.
@JsonKey(name: 'nfc')
final Nfc? nfc;

/// You can augment the user-visible information on Wallet passes with
Expand All @@ -235,5 +264,6 @@ class PassData {
///
/// An object that contains machine-readable metadata the system uses to offer
/// a pass and suggest related actions.
@JsonKey(name: 'semantics')
final Semantics? semantics;
}
Loading
Loading