Class: Passkit::BasePass
- Inherits:
-
Object
- Object
- Passkit::BasePass
- Defined in:
- lib/passkit/base_pass.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#add_other_files(path) ⇒ Object
After base files are copied this is called to allow for adding custom images.
-
#app_launch_url ⇒ Object
URL to launch the associated app (nil by default) Returns a String.
- #apple_team_identifier ⇒ Object
-
#associated_store_identifiers ⇒ Object
A list of Apple App Store identifiers for apps associated with the pass.
- #auxiliary_fields ⇒ Object
- #back_fields ⇒ Object
-
#background_color ⇒ Object
The background color, used for the background of the front and back of the pass.
-
#barcode ⇒ Object
QRCode by default.
-
#barcodes ⇒ Object
An array of barcodes, the first one that can be displayed on the device is picked.
-
#beacons ⇒ Object
List of iBeacon identifiers to identify when the pass should be displayed.
-
#boarding_pass ⇒ Object
Information specific to a boarding pass Returns a hash representing Pass.BoardingPass https://developer.apple.com/documentation/walletpasses/pass/boardingpass i.e 'PKTransitTypeGeneric'.
-
#description ⇒ Object
The description lets VoiceOver make your pass accessible to blind and low-vision users.
-
#expiration_date ⇒ Object
Date and time the pass expires, must include days, hours and minutes (seconds are optional) Returns a String representing the date and time in W3C format ('%Y-%m-%dT%H:%M:%S%:z') For example, 1980-05-07T10:30-05:00.
- #file_name ⇒ Object
-
#foreground_color ⇒ Object
The foreground color, used for the values of fields shown on the front of the pass.
- #format_version ⇒ Object
-
#grouping_identifier ⇒ Object
A key to identify group multiple passes together (e.g. a number of boarding passes for the same trip) Returns a String.
- #header_fields ⇒ Object
-
#initialize(generator = nil) ⇒ BasePass
constructor
A new instance of BasePass.
-
#label_color ⇒ Object
The label color, used for the labels of fields shown on the front of the pass.
- #language ⇒ Object
- #last_update ⇒ Object
-
#locations ⇒ Object
An array of up to 10 latitudes and longitudes.
-
#logo_text ⇒ Object
Barcode example def barcode { messageEncoding: 'iso-8859-1', format: 'PKBarcodeFormatCode128', message: '12345', altText: '12345' } end.
-
#max_distance ⇒ Object
Distance in meters from locations; if blank uses pass default.
-
#nfc ⇒ Object
Information specific to Value Added Service Protocol transactions Returns a hash representing Pass.NFC.
-
#organization_name ⇒ Object
The organization name is displayed on the lock screen when your pass is relevant and by apps such as Mail which act as a conduit for passes.
- #pass_path ⇒ Object
- #pass_type ⇒ Object
- #pass_type_identifier ⇒ Object
- #primary_fields ⇒ Object
-
#relevant_date ⇒ Object
Date and time when the pass becomes relevant and should be displayed, must include days, hours and minutes (seconds are optional) Returns a String representing the date and time in W3C format ('%Y-%m-%dT%H:%M:%S%:z').
- #secondary_fields ⇒ Object
-
#semantics ⇒ Object
Machine readable metadata that the device can use to suggest actions Returns a hash representing SemanticTags.
- #sharing_prohibited ⇒ Object
-
#strip_color ⇒ Object
The strip color, used to print the text over the background image.
-
#suppress_strip_shine ⇒ Object
Display the strip image without a shine effect Returns a boolean.
-
#user_info ⇒ Object
JSON dictionary to display custom information for companion apps.
- #voided ⇒ Object
- #web_service_url ⇒ Object
Constructor Details
#initialize(generator = nil) ⇒ BasePass
Returns a new instance of BasePass.
3 4 5 |
# File 'lib/passkit/base_pass.rb', line 3 def initialize(generator = nil) @generator = generator end |
Instance Method Details
#add_other_files(path) ⇒ Object
After base files are copied this is called to allow for adding custom images
99 100 |
# File 'lib/passkit/base_pass.rb', line 99 def add_other_files(path) end |
#app_launch_url ⇒ Object
URL to launch the associated app (nil by default) Returns a String
109 110 |
# File 'lib/passkit/base_pass.rb', line 109 def app_launch_url end |
#apple_team_identifier ⇒ Object
11 12 13 |
# File 'lib/passkit/base_pass.rb', line 11 def apple_team_identifier Passkit.configuration.apple_team_identifier end |
#associated_store_identifiers ⇒ Object
A list of Apple App Store identifiers for apps associated with the pass. The first one that is compatible with the device is picked. Returns an array of numbers
116 117 118 |
# File 'lib/passkit/base_pass.rb', line 116 def associated_store_identifiers [] end |
#auxiliary_fields ⇒ Object
222 223 224 |
# File 'lib/passkit/base_pass.rb', line 222 def auxiliary_fields [] end |
#back_fields ⇒ Object
226 227 228 |
# File 'lib/passkit/base_pass.rb', line 226 def back_fields [] end |
#background_color ⇒ Object
The background color, used for the background of the front and back of the pass. If you provide a background image, any background color is ignored.
62 63 64 65 |
# File 'lib/passkit/base_pass.rb', line 62 def background_color # white "rgb(255, 255, 255)" end |
#barcode ⇒ Object
QRCode by default
191 192 193 194 195 196 |
# File 'lib/passkit/base_pass.rb', line 191 def { messageEncoding: "iso-8859-1", format: "PKBarcodeFormatQR", message: "https://github.com/coorasse/passkit", altText: "https://github.com/coorasse/passkit" } end |
#barcodes ⇒ Object
An array of barcodes, the first one that can be displayed on the device is picked. Returns an array of hashes representing Pass.Barcodes
123 124 125 |
# File 'lib/passkit/base_pass.rb', line 123 def [] end |
#beacons ⇒ Object
List of iBeacon identifiers to identify when the pass should be displayed. Returns an array of hashes representing Pass.Beacons
130 131 132 |
# File 'lib/passkit/base_pass.rb', line 130 def beacons [] end |
#boarding_pass ⇒ Object
Information specific to a boarding pass Returns a hash representing Pass.BoardingPass https://developer.apple.com/documentation/walletpasses/pass/boardingpass i.e 'PKTransitTypeGeneric'
138 139 140 |
# File 'lib/passkit/base_pass.rb', line 138 def boarding_pass {} end |
#description ⇒ Object
The description lets VoiceOver make your pass accessible to blind and low-vision users. The value for the description key in the pass specifies the description.
83 84 85 |
# File 'lib/passkit/base_pass.rb', line 83 def description "A basic description for a pass" end |
#expiration_date ⇒ Object
Date and time the pass expires, must include days, hours and minutes (seconds are optional) Returns a String representing the date and time in W3C format ('%Y-%m-%dT%H:%M:%S%:z') For example, 1980-05-07T10:30-05:00.
146 147 |
# File 'lib/passkit/base_pass.rb', line 146 def expiration_date end |
#file_name ⇒ Object
186 187 188 |
# File 'lib/passkit/base_pass.rb', line 186 def file_name @file_name ||= SecureRandom.uuid end |
#foreground_color ⇒ Object
The foreground color, used for the values of fields shown on the front of the pass.
50 51 52 53 |
# File 'lib/passkit/base_pass.rb', line 50 def foreground_color # black "rgb(0, 0, 0)" end |
#format_version ⇒ Object
7 8 9 |
# File 'lib/passkit/base_pass.rb', line 7 def format_version Passkit.configuration.format_version end |
#grouping_identifier ⇒ Object
A key to identify group multiple passes together (e.g. a number of boarding passes for the same trip) Returns a String
152 153 |
# File 'lib/passkit/base_pass.rb', line 152 def grouping_identifier end |
#header_fields ⇒ Object
210 211 212 |
# File 'lib/passkit/base_pass.rb', line 210 def header_fields [] end |
#label_color ⇒ Object
The label color, used for the labels of fields shown on the front of the pass.
68 69 70 71 |
# File 'lib/passkit/base_pass.rb', line 68 def label_color # black "rgb(0, 0, 0)" end |
#language ⇒ Object
19 20 21 |
# File 'lib/passkit/base_pass.rb', line 19 def language nil end |
#last_update ⇒ Object
23 24 25 |
# File 'lib/passkit/base_pass.rb', line 23 def last_update @generator&.updated_at end |
#locations ⇒ Object
An array of up to 10 latitudes and longitudes. iOS uses these locations to determine when to display the pass on the lock screen
90 91 92 |
# File 'lib/passkit/base_pass.rb', line 90 def locations [] end |
#logo_text ⇒ Object
Barcode example def barcode { messageEncoding: 'iso-8859-1', format: 'PKBarcodeFormatCode128', message: '12345', altText: '12345' } end
206 207 208 |
# File 'lib/passkit/base_pass.rb', line 206 def logo_text "Logo text" end |
#max_distance ⇒ Object
Distance in meters from locations; if blank uses pass default. The system uses the smaller of either this distance or the default distance.
104 105 |
# File 'lib/passkit/base_pass.rb', line 104 def max_distance end |
#nfc ⇒ Object
Information specific to Value Added Service Protocol transactions Returns a hash representing Pass.NFC
158 159 |
# File 'lib/passkit/base_pass.rb', line 158 def nfc end |
#organization_name ⇒ Object
The organization name is displayed on the lock screen when your pass is relevant and by apps such as Mail which act as a conduit for passes. The value for the organizationName key in the pass specifies the organization name. Choose a name that users recognize and associate with your organization or company.
76 77 78 |
# File 'lib/passkit/base_pass.rb', line 76 def organization_name "Passkit" end |
#pass_path ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/passkit/base_pass.rb', line 27 def pass_path rails_folder = Rails.root.join("private/passkit/#{folder_name}") # if folder exists, otherwise is in the gem itself under lib/passkit/base_pass if File.directory?(rails_folder) rails_folder else File.join(File.dirname(__FILE__), folder_name) end end |
#pass_type ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/passkit/base_pass.rb', line 37 def pass_type :storeCard # :coupon # :eventTicket # :generic # :boardingPass end |
#pass_type_identifier ⇒ Object
15 16 17 |
# File 'lib/passkit/base_pass.rb', line 15 def pass_type_identifier Passkit.configuration.pass_type_identifier end |
#primary_fields ⇒ Object
214 215 216 |
# File 'lib/passkit/base_pass.rb', line 214 def primary_fields [] end |
#relevant_date ⇒ Object
Date and time when the pass becomes relevant and should be displayed, must include days, hours and minutes (seconds are optional) Returns a String representing the date and time in W3C format ('%Y-%m-%dT%H:%M:%S%:z')
165 166 |
# File 'lib/passkit/base_pass.rb', line 165 def relevant_date end |
#secondary_fields ⇒ Object
218 219 220 |
# File 'lib/passkit/base_pass.rb', line 218 def secondary_fields [] end |
#semantics ⇒ Object
Machine readable metadata that the device can use to suggest actions Returns a hash representing SemanticTags
171 172 |
# File 'lib/passkit/base_pass.rb', line 171 def semantics end |
#sharing_prohibited ⇒ Object
230 231 232 |
# File 'lib/passkit/base_pass.rb', line 230 def sharing_prohibited false end |
#strip_color ⇒ Object
The strip color, used to print the text over the background image.
56 57 58 |
# File 'lib/passkit/base_pass.rb', line 56 def strip_color "rgb(0, 0, 0)" end |
#suppress_strip_shine ⇒ Object
Display the strip image without a shine effect Returns a boolean
176 177 178 |
# File 'lib/passkit/base_pass.rb', line 176 def suppress_strip_shine true end |
#user_info ⇒ Object
JSON dictionary to display custom information for companion apps. Data isn't displayed to the user. e.g. a machine readable version of the user's favourite coffee
183 184 |
# File 'lib/passkit/base_pass.rb', line 183 def user_info end |
#voided ⇒ Object
94 95 96 |
# File 'lib/passkit/base_pass.rb', line 94 def voided false end |
#web_service_url ⇒ Object
45 46 47 |
# File 'lib/passkit/base_pass.rb', line 45 def web_service_url "#{Passkit.configuration.web_service_host}/passkit/api" end |