Class: Passkit::BasePass

Inherits:
Object
  • Object
show all
Defined in:
lib/passkit/base_pass.rb

Direct Known Subclasses

ExampleStoreCard

Instance Method Summary collapse

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_urlObject

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_identifierObject



11
12
13
# File 'lib/passkit/base_pass.rb', line 11

def apple_team_identifier
  Passkit.configuration.apple_team_identifier
end

#associated_store_identifiersObject

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_fieldsObject



222
223
224
# File 'lib/passkit/base_pass.rb', line 222

def auxiliary_fields
  []
end

#back_fieldsObject



226
227
228
# File 'lib/passkit/base_pass.rb', line 226

def back_fields
  []
end

#background_colorObject

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

#barcodeObject

QRCode by default



191
192
193
194
195
196
# File 'lib/passkit/base_pass.rb', line 191

def barcode
  { messageEncoding: "iso-8859-1",
    format: "PKBarcodeFormatQR",
    message: "https://github.com/coorasse/passkit",
    altText: "https://github.com/coorasse/passkit" }
end

#barcodesObject

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 barcodes
  []
end

#beaconsObject

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_passObject

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

#descriptionObject

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_dateObject

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_nameObject



186
187
188
# File 'lib/passkit/base_pass.rb', line 186

def file_name
  @file_name ||= SecureRandom.uuid
end

#foreground_colorObject

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_versionObject



7
8
9
# File 'lib/passkit/base_pass.rb', line 7

def format_version
  Passkit.configuration.format_version
end

#grouping_identifierObject

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_fieldsObject



210
211
212
# File 'lib/passkit/base_pass.rb', line 210

def header_fields
  []
end

#label_colorObject

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

#languageObject



19
20
21
# File 'lib/passkit/base_pass.rb', line 19

def language
  nil
end

#last_updateObject



23
24
25
# File 'lib/passkit/base_pass.rb', line 23

def last_update
  @generator&.updated_at
end

#locationsObject

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_textObject

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_distanceObject

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

#nfcObject

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_nameObject

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_pathObject



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_typeObject



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_identifierObject



15
16
17
# File 'lib/passkit/base_pass.rb', line 15

def pass_type_identifier
  Passkit.configuration.pass_type_identifier
end

#primary_fieldsObject



214
215
216
# File 'lib/passkit/base_pass.rb', line 214

def primary_fields
  []
end

#relevant_dateObject

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_fieldsObject



218
219
220
# File 'lib/passkit/base_pass.rb', line 218

def secondary_fields
  []
end

#semanticsObject

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_prohibitedObject



230
231
232
# File 'lib/passkit/base_pass.rb', line 230

def sharing_prohibited
  false
end

#strip_colorObject

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_shineObject

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_infoObject

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 
end

#voidedObject



94
95
96
# File 'lib/passkit/base_pass.rb', line 94

def voided
  false
end

#web_service_urlObject



45
46
47
# File 'lib/passkit/base_pass.rb', line 45

def web_service_url
  "#{Passkit.configuration.web_service_host}/passkit/api"
end