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
-
#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.
-
#coupon ⇒ Object
Information specific to a coupon Returns a hash representing Pass.Coupon.
- #description ⇒ Object
-
#event_ticket ⇒ Object
Information specific to an event ticket Returns a hash representing Pass.EventTicket.
-
#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.
- #file_name ⇒ Object
- #foreground_color ⇒ Object
- #format_version ⇒ Object
-
#generic ⇒ Object
Information specific to a generic pass Returns a hash representing Pass.Generic.
-
#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
- #language ⇒ Object
- #last_update ⇒ Object
-
#locations ⇒ Object
A pass can have up to ten relevant locations.
-
#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
- #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.
- #secondary_fields ⇒ Object
-
#semantics ⇒ Object
Machine readable metadata that the device can use to suggest actions Returns a hash representing SemanticTags.
- #sharing_prohibited ⇒ Object
-
#store_card ⇒ Object
Information specific to a store card Returns a hash representing Pass.StoreCard.
-
#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
85 86 |
# File 'lib/passkit/base_pass.rb', line 85 def add_other_files(path) end |
#app_launch_url ⇒ Object
URL to launch the associated app (nil by default) Returns a String
94 95 |
# File 'lib/passkit/base_pass.rb', line 94 def app_launch_url end |
#apple_team_identifier ⇒ Object
11 12 13 |
# File 'lib/passkit/base_pass.rb', line 11 def apple_team_identifier ENV["PASSKIT_APPLE_TEAM_IDENTIFIER"] || raise(Error.new("Missing environment variable: PASSKIT_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
101 102 103 |
# File 'lib/passkit/base_pass.rb', line 101 def associated_store_identifiers [] end |
#auxiliary_fields ⇒ Object
223 224 225 |
# File 'lib/passkit/base_pass.rb', line 223 def auxiliary_fields [] end |
#back_fields ⇒ Object
227 228 229 |
# File 'lib/passkit/base_pass.rb', line 227 def back_fields [] end |
#background_color ⇒ Object
55 56 57 58 |
# File 'lib/passkit/base_pass.rb', line 55 def background_color # white "rgb(255, 255, 255)" end |
#barcode ⇒ Object
QRCode by default
192 193 194 195 196 197 |
# File 'lib/passkit/base_pass.rb', line 192 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
108 109 110 |
# File 'lib/passkit/base_pass.rb', line 108 def [] end |
#beacons ⇒ Object
List of iBeacon identifiers to identify when the pass should be displayed. Returns an array of hashes representing Pass.Beacons
115 116 117 |
# File 'lib/passkit/base_pass.rb', line 115 def beacons [] end |
#boarding_pass ⇒ Object
Information specific to a boarding pass Returns a hash representing Pass.BoardingPass
121 122 |
# File 'lib/passkit/base_pass.rb', line 121 def boarding_pass end |
#coupon ⇒ Object
Information specific to a coupon Returns a hash representing Pass.Coupon
126 127 |
# File 'lib/passkit/base_pass.rb', line 126 def coupon end |
#description ⇒ Object
69 70 71 |
# File 'lib/passkit/base_pass.rb', line 69 def description "A basic description for a pass" end |
#event_ticket ⇒ Object
Information specific to an event ticket Returns a hash representing Pass.EventTicket
131 132 |
# File 'lib/passkit/base_pass.rb', line 131 def event_ticket 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
137 138 |
# File 'lib/passkit/base_pass.rb', line 137 def expiration_date end |
#file_name ⇒ Object
187 188 189 |
# File 'lib/passkit/base_pass.rb', line 187 def file_name @file_name ||= SecureRandom.uuid end |
#foreground_color ⇒ Object
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 ENV["PASSKIT_FORMAT_VERSION"] || 1 end |
#generic ⇒ Object
Information specific to a generic pass Returns a hash representing Pass.Generic
142 143 |
# File 'lib/passkit/base_pass.rb', line 142 def generic 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
148 149 |
# File 'lib/passkit/base_pass.rb', line 148 def grouping_identifier end |
#header_fields ⇒ Object
211 212 213 |
# File 'lib/passkit/base_pass.rb', line 211 def header_fields [] end |
#label_color ⇒ Object
60 61 62 63 |
# File 'lib/passkit/base_pass.rb', line 60 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
A pass can have up to ten relevant locations
76 77 78 |
# File 'lib/passkit/base_pass.rb', line 76 def locations [] end |
#logo_text ⇒ Object
Barcode example def barcode
{ messageEncoding: 'iso-8859-1',
format: 'PKBarcodeFormatCode128',
message: '12345',
altText: '12345' }
end
207 208 209 |
# File 'lib/passkit/base_pass.rb', line 207 def logo_text "Logo text" end |
#max_distance ⇒ Object
Distance in meters from locations; if blank uses pass default
89 90 |
# File 'lib/passkit/base_pass.rb', line 89 def max_distance end |
#nfc ⇒ Object
Information specific to Value Added Service Protocol transactions Returns a hash representing Pass.NFC
154 155 |
# File 'lib/passkit/base_pass.rb', line 154 def nfc end |
#organization_name ⇒ Object
65 66 67 |
# File 'lib/passkit/base_pass.rb', line 65 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 ENV["PASSKIT_PASS_TYPE_IDENTIFIER"] || raise(Error.new("Missing environment variable: PASSKIT_PASS_TYPE_IDENTIFIER")) end |
#primary_fields ⇒ Object
215 216 217 |
# File 'lib/passkit/base_pass.rb', line 215 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
161 162 |
# File 'lib/passkit/base_pass.rb', line 161 def relevant_date end |
#secondary_fields ⇒ Object
219 220 221 |
# File 'lib/passkit/base_pass.rb', line 219 def secondary_fields [] end |
#semantics ⇒ Object
Machine readable metadata that the device can use to suggest actions Returns a hash representing SemanticTags
167 168 |
# File 'lib/passkit/base_pass.rb', line 167 def semantics end |
#sharing_prohibited ⇒ Object
231 232 233 |
# File 'lib/passkit/base_pass.rb', line 231 def sharing_prohibited false end |
#store_card ⇒ Object
Information specific to a store card Returns a hash representing Pass.StoreCard
172 173 |
# File 'lib/passkit/base_pass.rb', line 172 def store_card end |
#suppress_strip_shine ⇒ Object
Display the strip image without a shine effect Returns a boolean
177 178 179 |
# File 'lib/passkit/base_pass.rb', line 177 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
184 185 |
# File 'lib/passkit/base_pass.rb', line 184 def user_info end |
#voided ⇒ Object
80 81 82 |
# File 'lib/passkit/base_pass.rb', line 80 def voided false end |
#web_service_url ⇒ Object
45 46 47 48 |
# File 'lib/passkit/base_pass.rb', line 45 def web_service_url raise Error.new("Missing environment variable: PASSKIT_WEB_SERVICE_HOST") unless ENV["PASSKIT_WEB_SERVICE_HOST"] "#{ENV["PASSKIT_WEB_SERVICE_HOST"]}/passkit/api" end |