hs-pkpass-0.3: A library for Passbook pass creation & signing

Safe HaskellNone

Passbook.Types

Contents

Description

This module provides types and functions for type-safe generation of PassBook's pass.json files.

This is a complete implementation of the Passbook Package Format Reference, available at https://developer.apple.com/library/ios/#documentation/UserExperience/Reference/PassKit_Bundle/Chapters/Introduction.html.

It ensures that passes are created correctly wherever possible. Currently, NSBundle localization is not supported.

Synopsis

Passbook types

data PassValue Source

Auxiliary type to ensure that field values are rendered correctly

data PassField Source

A single pass field. The type PassValue holds the fields value and ensures that the JSON output is compatible with Passbook. To create a very simple key/value field containing text you can use the mkSimpleField function.

Constructors

PassField 

Fields

changeMessage :: Maybe Text

Message displayed when the pass is updated. May contain the %@ placeholder for the value. (optional)

key :: Text

Must be a unique key within the scope of the pass (e.g. "departure-gate") (required)

label :: Maybe Text

Label text for the field. (optional)

textAlignment :: Maybe Alignment

Alignment for the field's contents. Not allowed for primary fields. (optional)

value :: PassValue

Value of the field. Must be a string, ISO 8601 date or a number. (required)

dateStyle :: Maybe DateTimeStyle

Style of date to display (optional)

timeStyle :: Maybe DateTimeStyle

Style of time to display (optional)

isRelative :: Maybe Bool

Is the date/time displayed relative to the current time or absolute? Default: False (optional)

currencyCode :: Maybe Text

ISO 4217 currency code for the field's value (optional)

numberStyle :: Maybe NumberStyle

Style of number to display. See NSNumberFormatterStyle docs for more information. (optional)

data PassContent Source

The fields within a pass

Constructors

PassContent 

Fields

headerFields :: [PassField]

Fields to be displayed on the front of the pass. Always shown in the stack.

primaryFields :: [PassField]

Fields to be displayed prominently on the front of the pass.

secondaryFields :: [PassField]

Fields to be displayed on the front of the pass.

auxiliaryFields :: [PassField]

Additional fields to be displayed on the front of the pass.

backFields :: [PassField]

Fields to be on the back of the pass.

data Pass Source

A complete pass

Constructors

Pass 

Fields

description :: Text

Brief description of the pass (required)

organizationName :: Text

Display name of the organization that signed the pass (required)

passTypeIdentifier :: Text

Pass type identifier, as issued by Apple (required)

serialNumber :: Text

Unique serial number for the pass (required)

teamIdentifier :: Text

Team identifier for the organization (required)

associatedStoreIdentifiers :: [Text]

A list of iTunes Store item identifiers for associated apps (optional)

locations :: [Location]

Locations where the pass is relevant (e.g. that of a store) (optional)

relevantDate :: Maybe RelevantDate

ISO 8601 formatted date for when the pass becomes relevant (optional)

barcode :: Maybe Barcode

Barcode information (optional)

backgroundColor :: Maybe RGBColor

Background color of the pass (optional)

foregroundColor :: Maybe RGBColor

Foreground color of the pass (optional)

labelColor :: Maybe Text

Color of the label text. If omitted, the color is determined automatically. (optional)

logoText :: Maybe Text

Text displayed next to the logo on the pass (optional)

suppressStripShine :: Maybe Bool

If True, the strip image is displayed without a shine effect. (optional)

webService :: Maybe WebService

Contains the authentication token (16 characters or longer) and the API end point for a Web Service

passContent :: PassType

The kind of pass and the passes' fields (required)

Passbook field types

data Location Source

A location field

Constructors

Location 

Fields

latitude :: Double

Latitude, in degrees, of the location (required)

longitude :: Double

Longitude, in degrees, of the location (required)

altitude :: Maybe Double

Altitude, in meters, of the location (optional)

relevantText :: Maybe Text

Text displayed on the lock screen when the pass is relevant (optional)

data RGBColor Source

A simple RGB color value. In combination with the rgb function this can be written just like in CSS, e.g. rgb(43, 53, 65). The rgb function also ensures that the provided values are valid.

data BarcodeFormat Source

Barcode is constructed by a Barcode format, an encoding type and the Barcode message.

Constructors

QRCode 
PDF417 
Aztec 

data Barcode Source

A pass barcode. In most cases the helper function mkBarcode should be sufficient.

Constructors

Barcode 

Fields

altText :: Maybe Text

Text displayed near the barcode (optional)

format :: BarcodeFormat

Barcode format (required)

message :: Text

Message / payload to be displayed as a barcode (required)

messageEncoding :: Text

Barcode encoding. Default in the mkBarcode functions is iso-8859-1 (required)

data DateTimeStyle Source

Pass field date/time display style

Constructors

None

Corresponds to NSDateFormatterNoStyle

Short

Corresponds to NSDateFormatterShortStyle

Medium

Corresponds to NSDateFormatterMediumStyle

Long

Corresponds to NSDateFormatterLongStyle

Full

Corresponds to NSDateFormatterFullStyle

data TransitType Source

BoardingPass transit type. Only necessary for Boarding Passes.

Constructors

Air 
Boat 
Bus 
Train 
GenericTransit 

data WebService Source

Constructors

WebService 

Fields

authenticationToken :: Text

Authentication token for use with the web service. Must be 16 characters or longer (optional)

webServiceURL :: Text

The URL of a web service that conforms to the API described in the Passbook Web Service Reference (optional)

Auxiliary functions

rgb :: (Int, Int, Int) -> Maybe RGBColorSource

Creates a Just RGBColor if all supplied numbers are between 0 and 255.

mkBarcode :: Text -> BarcodeFormat -> BarcodeSource

This function takes a Text and a BarcodeFormat and uses the text for both the barcode message and the alternative text.

mkSimpleFieldSource

Arguments

:: Text

Key

-> PassValue

Value

-> Maybe Text

Label

-> PassField 

Creates a simple PassField with just a key, a value and an optional label. All the other optional fields are set to Nothing.