Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/enhancement/passbook nfc #67

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions passbook/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ def __init__(self):
class Pass(object):

def __init__(self, passInformation, json='', passTypeIdentifier='',
organizationName='', teamIdentifier=''):
organizationName='', teamIdentifier='',
nfc_message=None,
encryption_public_key=None,
sharingProhibited=None,
requiresAuthentication=False):

self._files = {} # Holds the files to include in the .pkpass
self._hashes = {} # Holds the SHAs of the files array
Expand Down Expand Up @@ -298,6 +302,17 @@ def __init__(self, passInformation, json='', passTypeIdentifier='',

self.passInformation = passInformation

# Create an NFC pass
self.nfc_message = nfc_message
# Public encryption key
self.encryption_public_key = encryption_public_key

# This one prevents users from sharing passes with older iOS versions and bypassing the authentication requirement.
self.sharingProhibited = sharingProhibited

# It's a Boolean value that indicates whether the NFC pass requires authentication.
self.requiresAuthentication = requiresAuthentication

# Adds file to the file array
def addFile(self, name, fd):
self._files[name] = fd.read()
Expand Down Expand Up @@ -405,7 +420,7 @@ def json_dict(self):
if self.logoText:
d.update({'logoText': self.logoText})
if self.locations:
d.update({'locations': self.locations})
d['locations'] = self.locations
if self.ibeacons:
d.update({'beacons': self.ibeacons})
if self.userInfo:
Expand All @@ -423,6 +438,15 @@ def json_dict(self):
if self.webServiceURL:
d.update({'webServiceURL': self.webServiceURL,
'authenticationToken': self.authenticationToken})
if self.nfc_message:
d['nfc'] = {
'message': self.nfc_message,
"encryptionPublicKey": self.encryption_public_key,
"requiresAuthentication": self.requiresAuthentication
}
if self.sharingProhibited:
d.update({"sharingProhibited": self.sharingProhibited})

return d


Expand Down