Skip to content

Commit 3522c16

Browse files
annaswimscoorasse
andauthored
fix Pass object additional feilds (#31)
* fix Pass object additional feilds Pass.Coupon, Pass.EventTicket, Pass.EventTicket, and Pass.Generic don't have any additional feilds availabe so we don't need to provide methods for additional feilds. boardingPass was being overwritten by the additonal feild method, now fixed. resolves #29 * Update lib/passkit/generator.rb Co-authored-by: Alessandro Rodi <[email protected]> --------- Co-authored-by: Alessandro Rodi <[email protected]>
1 parent a698506 commit 3522c16

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

app/models/passkit/pass.rb

-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ class Pass < ActiveRecord::Base
1717
:barcodes,
1818
:beacons,
1919
:boarding_pass,
20-
:coupon,
2120
:description,
22-
:event_ticket,
2321
:expiration_date,
2422
:file_name,
2523
:foreground_color,
2624
:format_version,
27-
:generic,
2825
:grouping_identifier,
2926
:header_fields,
3027
:label_color,
@@ -42,7 +39,6 @@ class Pass < ActiveRecord::Base
4239
:secondary_fields,
4340
:semantics,
4441
:sharing_prohibited,
45-
:store_card,
4642
:suppress_strip_shine,
4743
:user_info,
4844
:voided,

lib/passkit/base_pass.rb

+3-20
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,10 @@ def beacons
129129

130130
# Information specific to a boarding pass
131131
# Returns a hash representing Pass.BoardingPass
132+
# https://developer.apple.com/documentation/walletpasses/pass/boardingpass
133+
# i.e {transitType: 'PKTransitTypeGeneric'}
132134
def boarding_pass
133-
end
134-
135-
# Information specific to a coupon
136-
# Returns a hash representing Pass.Coupon
137-
def coupon
138-
end
139-
140-
# Information specific to an event ticket
141-
# Returns a hash representing Pass.EventTicket
142-
def event_ticket
135+
{}
143136
end
144137

145138
# Date and time the pass expires, must include
@@ -149,11 +142,6 @@ def event_ticket
149142
def expiration_date
150143
end
151144

152-
# Information specific to a generic pass
153-
# Returns a hash representing Pass.Generic
154-
def generic
155-
end
156-
157145
# A key to identify group multiple passes together
158146
# (e.g. a number of boarding passes for the same trip)
159147
# Returns a String
@@ -179,11 +167,6 @@ def relevant_date
179167
def semantics
180168
end
181169

182-
# Information specific to a store card
183-
# Returns a hash representing Pass.StoreCard
184-
def store_card
185-
end
186-
187170
# Display the strip image without a shine effect
188171
# Returns a boolean
189172
def suppress_strip_shine

lib/passkit/generator.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,14 @@ def generate_json_pass
8888
else
8989
pass[:barcodes] = @pass.barcodes
9090
end
91-
9291
pass[:appLaunchURL] = @pass.app_launch_url if @pass.app_launch_url
9392
pass[:associatedStoreIdentifiers] = @pass.associated_store_identifiers unless @pass.associated_store_identifiers.empty?
9493
pass[:beacons] = @pass.beacons unless @pass.beacons.empty?
95-
pass[:boardingPass] = @pass.boarding_pass if @pass.boarding_pass
96-
pass[:coupon] = @pass.coupon if @pass.coupon
97-
pass[:eventTicket] = @pass.event_ticket if @pass.event_ticket
9894
pass[:expirationDate] = @pass.expiration_date if @pass.expiration_date
99-
pass[:generic] = @pass.generic if @pass.generic
10095
pass[:groupingIdentifier] = @pass.grouping_identifier if @pass.grouping_identifier
10196
pass[:nfc] = @pass.nfc if @pass.nfc
10297
pass[:relevantDate] = @pass.relevant_date if @pass.relevant_date
10398
pass[:semantics] = @pass.semantics if @pass.semantics
104-
pass[:store_card] = @pass.store_card if @pass.store_card
10599
pass[:userInfo] = @pass.user_info if @pass.user_info
106100

107101
pass[@pass.pass_type] = {
@@ -112,6 +106,8 @@ def generate_json_pass
112106
backFields: @pass.back_fields
113107
}
114108

109+
pass[:boardingPass].merge(@pass.boarding_pass) if @pass.pass_type == :boardingPass && @pass.boarding_pass
110+
115111
File.write(@temporary_path.join("pass.json"), pass.to_json)
116112
end
117113

0 commit comments

Comments
 (0)