passbook

package module
v0.0.0-...-f8c890d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PKBarcodeFormatQR     BarcodeFormat = "PKBarcodeFormatQR"
	PKBarcodeFormatPDF417               = "PKBarcodeFormatPDF417"
	PKBarcodeFormatAztec                = "PKBarcodeFormatAztec"
)

Supported Barcode formats.

View Source
const (
	PKDataDetectorTypePhoneNumber   DataDetector = "PKDataDetectorTypePhoneNumber"
	PKDataDetectorTypeLink                       = "PKDataDetectorTypeLink"
	PKDataDetectorTypeAddress                    = "PKDataDetectorTypeAddress"
	PKDataDetectorTypeCalendarEvent              = "PKDataDetectorTypeCalendarEvent"
)
View Source
const (
	PKTextAlignmentNatural TextAlignment = "PKTextAlignmentNatural"
	PKTextAlignmentLeft                  = "PKTextAlignmentLeft"
	PKTextAlignmentCenter                = "PKTextAlignmentCenter"
	PKTextAlignmentRight                 = "PKTextAlignmentRight"
)
View Source
const (
	PKDateStyleNone   DateTimeStyle = "PKDateStyleNone"
	PKDateStyleShort                = "PKDateStyleShort"
	PKDateStyleMedium               = "PKDateStyleMedium"
	PKDateStyleLong                 = "PKDateStyleLong"
	PKDateStyleFull                 = "PKDateStyleFull"
)
View Source
const (
	PKTransitTypeAir     TransitType = "PKTransitTypeAir"
	PKTransitTypeBoat                = "PKTransitTypeBoat"
	PKTransitTypeBus                 = "PKTransitTypeBus"
	PKTransitTypeGeneric             = "PKTransitTypeGeneric"
	PKTransitTypeTrain               = "PKTransitTypeTrain"
)

Supported types of transit

View Source
const (
	PKNumberStyleDecimal    NumberStyle = "PKNumberStyleDecimal"
	PKNumberStylePercent                = "PKNumberStylePercent"
	PKNumberStyleScientific             = "PKNumberStyleScientific"
	PKNumberStyleSpellOut               = "PKNumberStyleSpellOut"
)

Variables

View Source
var ErrNoPass = errors.New("pass.json missed") // в файл не было добавлено описание pass.json

Functions

This section is empty.

Types

type Barcode

type Barcode struct {
	BarcodeImpl
}

func (Barcode) MarshalJSON

func (b Barcode) MarshalJSON() ([]byte, error)

type BarcodeFormat

type BarcodeFormat string

Barcode format.

type BarcodeImpl

type BarcodeImpl struct {
	Format          BarcodeFormat `json:"format"`            // Barcode format.
	Message         string        `json:"message"`           // Message or payload to be displayed as a barcode.
	MessageEncoding string        `json:"messageEncoding"`   // Textencodingthatisusedtoconvertthemessage from the string representation to a data representation to render the barcode.
	AltText         string        `json:"altText,omitempty"` // Text displayed near the barcode. For example, a human-readable version of the barcode data in case the barcode doesn’t scan.
}

Barcode Dictionary: Information about a pass’s barcode.

type Beacon

type Beacon struct {
	BeaconImpl
}

func (Beacon) MarshalJSON

func (b Beacon) MarshalJSON() ([]byte, error)

type BeaconImpl

type BeaconImpl struct {
	ProximityUUID string `json:"proximityUUID"`          // Unique identifier of a Bluetooth Low Energy location beacon.
	Major         uint16 `json:"major,omitempty"`        // Major identifier of a Bluetooth Low Energy location beacon.
	Minor         uint16 `json:"minor,omitempty"`        // Minor identifier of a Bluetooth Low Energy location beacon.
	RelevantText  string `json:"relevantText,omitempty"` // Text displayed on the lock screen when the pass is currently relevant.
}

Beacon Dictionary: Information about a location beacon. Available in iOS 7.0.

type Color

type Color struct {
	R uint8 // red
	G uint8 // green
	B uint8 // blue
}

func (Color) MarshalJSON

func (c Color) MarshalJSON() ([]byte, error)

func (Color) String

func (c Color) String() string

func (*Color) UnmarshalJSON

func (c *Color) UnmarshalJSON(data []byte) error

type DataDetector

type DataDetector string

type DateTimeStyle

type DateTimeStyle string

type Field

type Field struct {
	Key               string         `json:"key"`                        // The key must be unique within the scope of the entire pass.
	Label             string         `json:"label,omitempty"`            // Label text for the field.
	Value             interface{}    `json:"value"`                      // Value of the field.
	AttributedValue   string         `json:"attributedValue,omitempty"`  // Attributed value of the field.
	TextAlignment     TextAlignment  `json:"textAlignment,omitempty"`    // Alignment for the field’s contents.
	ChangeMessage     string         `json:"changeMessage,omitempty"`    // Format string for the alert text that is displayed when the pass is updated. The format string must contain the escape %@, which is replaced with the field’s new value. For example, “Gate changed to %@.”
	DataDetectorTypes []DataDetector `json:"dataDetectorTypes,omitempty` // Data dectors that are applied to the field’s value.
	// Date Style Keys: Information about how a date should be displayed in a field.
	// If any of these keys is present, the value of the field is treated as a date. Either specify both a date style and a time style, or neither.
	DateStyle       DateTimeStyle `json:"dateStyle,omitempty"`       // Style of date to display.
	TimeStyle       DateTimeStyle `json:"timeStyle,omitempty"`       // Style of time to display.
	IgnoresTimeZone bool          `json:"ignoresTimeZone,omitempty"` // Always display the time and date in the given time zone, not in the user’s current time zone.
	IsRelative      bool          `json:"isRelative,omitempty"`      // If true, the label’s value is displayed as a relative date; otherwise, it is displayed as an absolute date.
	// Number Style Keys: Information about how a number should be displayed in a field.
	// These keys are optional if the field’s value is a number; otherwise they are not allowed. Only one of these keys is allowed per field.
	CurrencyCode string      `json:"currencyCode,omitempty"` // ISO 4217 currency code for the field’s value.
	NumberStyle  NumberStyle `json:"numberStyle,omitempty"`  // Style of number to display.
}

Standard Field Dictionary Keys: Information about a field. These keys are used for all dictionaries that define a field.

type Fields

type Fields struct {
	TransitType TransitType `json:"transitType,omitempty"`     // Type of transit. Required for boarding passes; otherwise not allowed.
	Primary     FieldsData  `json:"primaryFields,omitempty"`   // Fields to be displayed prominently on the front of the pass.
	Secondary   FieldsData  `json:"secondaryFields,omitempty"` // Fields to be displayed on the front of the pass.
	Auxiliary   FieldsData  `json:"auxiliaryFields,omitempty"` // Additional fields to be displayed on the front of the pass.
	Back        FieldsData  `json:"backFields,omitempty"`      // Fields to be on the back of the pass.
	Header      FieldsData  `json:"headerFields,omitempty"`    // Fields to be displayed in the header on the front of the pass.
}

Fields Pass Structure Dictionary: Keys that define the structure of the pass. These keys are used for all pass styles and partition the fields into the various parts of the pass.

type FieldsData

type FieldsData map[string]Field

FieldsData describe array of field dictionaries

func (FieldsData) MarshalJSON

func (fd FieldsData) MarshalJSON() ([]byte, error)

func (*FieldsData) UnmarshalJSON

func (fd *FieldsData) UnmarshalJSON(data []byte) error

type Location

type Location struct {
	Latitude     float64 `json:"latitude"`               // Latitude, in degrees, of the location.
	Longitude    float64 `json:"longitude"`              // Longitude, in degrees, of the location.
	Altitude     float64 `json:"altitude,omitempty"`     // Altitude, in meters, of the location.
	RelevantText string  `json:"relevantText,omitempty"` // Text displayed on the lock screen when the pass is currently relevant.
}

Location Dictionary: Information about a location.

type NumberStyle

type NumberStyle string

type Pass

type Pass struct {
	PassImpl
}

func (Pass) MarshalJSON

func (p Pass) MarshalJSON() ([]byte, error)

type PassImpl

type PassImpl struct {
	// Standard Keys: Information that is required for all passes.
	FormatVersion      int    `json:"formatVersion"`      // Version of the file format. The value must be 1.
	PassTypeIdentifier string `json:"passTypeIdentifier"` // Pass type identifier, as issued by Apple. The value must correspond with your signing certificate.
	SerialNumber       string `json:"serialNumber"`       // Serial number that uniquely identifies the pass. No two passes with the same pass type identifier may have the same serial number.
	TeamIdentifier     string `json:"teamIdentifier"`     // Team identifier of the organization that originated and signed the pass, as issued by Apple.
	OrganizationName   string `json:"organizationName"`   // Display name of the organization that originated and signed the pass.
	Description        string `json:"description"`        // Brief description of the pass, used by the iOS accessibility technologies.
	// Associated App Keys: Information about an app that is associated with a pass.
	AppLaunchURL               string `json:"appLaunchURL,omitempty"`               // A URL to be passed to the associated app when launching it.
	AssociatedStoreIdentifiers []int  `json:"associatedStoreIdentifiers,omitempty"` // A list of iTunes Store item identifiers for the associated apps.
	// Companion App Keys: Custom information about a pass provided for a companion app to use.
	UserInfo map[string]interface{} `json:"userInfo,omitempty"` // Custom information for companion apps. This data is not displayed to the user.
	// Expiration Keys: Information about when a pass expires and whether it is still valid.
	// A pass is marked as expired if the current date is after the pass’s expiration date, or if the pass has been explicitly marked as voided.
	ExpirationDate *W3Time `json:"expirationDate,omitempty"` // Date and time when the pass expires.
	Voided         bool    `json:"voided,omitempty"`         // Indicates that the pass is void—for example, a one time use coupon that has been redeemed.
	// Relevance Keys: Information about where and when a pass is relevant.
	Beacons      []Beacon   `json:"beacons,omitempty"`      // Beacons marking locations where the pass is relevant.
	Locations    []Location `json:"locations,omitempty"`    // Locations where the pass is relevant.
	MaxDistance  uint       `json:"maxDistance,omitempty"`  // Maximum distance in meters from a relevant latitude and longitude that the pass is relevant.
	RelevantDate *W3Time    `json:"relevantDate,omitempty"` // Date and time when the pass becomes relevant.
	// Visual Appearance Keys: Visual styling and appearance of the pass.
	Barcode            *Barcode `json:"barcode,omitempty"`            // Information specific to barcodes.
	BackgroundColor    *Color   `json:"backgroundColor,omitempty"`    // Background color of the pass, specified as an CSS-style RGB triple.
	ForegroundColor    *Color   `json:"foregroundColor,omitempty"`    // Foreground color of the pass, specified as a CSS-style RGB triple.
	LabelColor         *Color   `json:"labelColor,omitempty"`         // Color of the label text, specified as a CSS-style RGB triple.
	LogoText           string   `json:"logoText,omitempty"`           // Text displayed next to the logo on the pass.
	GroupingIdentifier string   `json:"groupingIdentifier,omitempty"` // Optional for event tickets and boarding passes; otherwise not allowed. Identifier used to group related passes. If a grouping identifier is specified, passes with the same style, pass type identifier, and grouping identifier are displayed as a group. Otherwise, passes are grouped automatically.
	// Style Keys: Specifies the pass style.
	// Provide exactly one key—the key that corresponds with the pass’s type.
	Generic      *Fields `json:"generic,omitempty"`      // Information specific to a generic pass.
	BoardingPass *Fields `json:"boardingPass,omitempty"` // Information specific to a boarding pass.
	Coupon       *Fields `json:"coupon,omitempty"`       // Information specific to a coupon.
	EventTicket  *Fields `json:"eventTicket,omitempty"`  // Information specific to an event ticket.
	StoreCard    *Fields `json:"storeCard,omitempty"`    // Information specific to a store card.
	// Web Service Keys: Information used to update passes using the web service.
	AuthenticationToken string `json:"authenticationToken,omitempty"` // The authentication token to use with the web service. The token must be 16 characters or longer.
	WebServiceURL       string `json:"webServiceURL,omitempty"`       // The URL of a web service that conforms to the API described in Passbook Web Service Reference.
}

type TextAlignment

type TextAlignment string

type TransitType

type TransitType string

Type of transit

type W3Time

type W3Time time.Time

func (W3Time) MarshalJSON

func (t W3Time) MarshalJSON() ([]byte, error)

func (*W3Time) UnmarshalJSON

func (t *W3Time) UnmarshalJSON(data []byte) error

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer позволяет записывать файлы в формате Apple Passbook.

func NewWriter

func NewWriter(out io.Writer, cert *x509.Certificate, priv *rsa.PrivateKey) *Writer

NewWriter создает новый Writer, позволяющий создать файл в формате Apple Passbook. В качестве параметров передается поток, в который будет записываться отдаваемый файл, а так же сертификаты, которые будут использоваться при создании цифровой подписи.

func (*Writer) Add

func (w *Writer) Add(name string, r io.Reader) error

Add добавляет новый файл в Passbook. Добавляются только файлы с расширением .png и .strings. Плюс, добавляется файл с именем pass.json, который и является непосредственным описанием. Все остальные файлы игнорируются.

func (*Writer) Close

func (w *Writer) Close() (err error)

Close заканчивает запись файла в формате Apple Passbook и добавляет в него автоматически сгенерированный манифест и файл подписи. В момент создания цифровой подписи может возникнуть ошибка, которая в данном случае так же будет возвращена. Кроме этого, ошибка вернется, если в файл не было добавлено описание pass.json.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL