Skip to content

Commit

Permalink
fix Pass object additional feilds
Browse files Browse the repository at this point in the history
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 coorasse#29
  • Loading branch information
annaswims committed May 16, 2024
1 parent 8be5e4a commit 2708cb8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
4 changes: 0 additions & 4 deletions app/models/passkit/pass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ class Pass < ActiveRecord::Base
:barcodes,
:beacons,
:boarding_pass,
:coupon,
:description,
:event_ticket,
:expiration_date,
:file_name,
:foreground_color,
:format_version,
:generic,
:grouping_identifier,
:header_fields,
:label_color,
Expand All @@ -42,7 +39,6 @@ class Pass < ActiveRecord::Base
:secondary_fields,
:semantics,
:sharing_prohibited,
:store_card,
:suppress_strip_shine,
:user_info,
:voided,
Expand Down
23 changes: 3 additions & 20 deletions lib/passkit/base_pass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,10 @@ def beacons

# Information specific to a boarding pass
# Returns a hash representing Pass.BoardingPass
# https://developer.apple.com/documentation/walletpasses/pass/boardingpass
# i.e {transitType: 'PKTransitTypeGeneric'}
def boarding_pass
end

# Information specific to a coupon
# Returns a hash representing Pass.Coupon
def coupon
end

# Information specific to an event ticket
# Returns a hash representing Pass.EventTicket
def event_ticket
{}
end

# Date and time the pass expires, must include
Expand All @@ -148,11 +141,6 @@ def event_ticket
def expiration_date
end

# Information specific to a generic pass
# Returns a hash representing Pass.Generic
def generic
end

# A key to identify group multiple passes together
# (e.g. a number of boarding passes for the same trip)
# Returns a String
Expand All @@ -178,11 +166,6 @@ def relevant_date
def semantics
end

# Information specific to a store card
# Returns a hash representing Pass.StoreCard
def store_card
end

# Display the strip image without a shine effect
# Returns a boolean
def suppress_strip_shine
Expand Down
8 changes: 2 additions & 6 deletions lib/passkit/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,14 @@ def generate_json_pass
else
pass[:barcodes] = @pass.barcodes
end

pass[:appLaunchURL] = @pass.app_launch_url if @pass.app_launch_url
pass[:associatedStoreIdentifiers] = @pass.associated_store_identifiers unless @pass.associated_store_identifiers.empty?
pass[:beacons] = @pass.beacons unless @pass.beacons.empty?
pass[:boardingPass] = @pass.boarding_pass if @pass.boarding_pass
pass[:coupon] = @pass.coupon if @pass.coupon
pass[:eventTicket] = @pass.event_ticket if @pass.event_ticket
pass[:expirationDate] = @pass.expiration_date if @pass.expiration_date
pass[:generic] = @pass.generic if @pass.generic
pass[:groupingIdentifier] = @pass.grouping_identifier if @pass.grouping_identifier
pass[:nfc] = @pass.nfc if @pass.nfc
pass[:relevantDate] = @pass.relevant_date if @pass.relevant_date
pass[:semantics] = @pass.semantics if @pass.semantics
pass[:store_card] = @pass.store_card if @pass.store_card
pass[:userInfo] = @pass.user_info if @pass.user_info

pass[@pass.pass_type] = {
Expand All @@ -99,6 +93,8 @@ def generate_json_pass
backFields: @pass.back_fields
}

pass[:boardingPass ].merge(@pass.boarding_pass) if @pass.pass_type == :boardingPass && @pass.boarding_pass

File.write(@temporary_path.join("pass.json"), pass.to_json)
end

Expand Down

0 comments on commit 2708cb8

Please sign in to comment.