Skip to content

Commit

Permalink
feat(apple): return lastUpdated as string (#6)
Browse files Browse the repository at this point in the history
Return `lastUpdated` as string instead of number, adhering to the Apple documentation:  https://developer.apple.com/documentation/walletpasses/serialnumbers
  • Loading branch information
aahna-ashina committed Sep 11, 2022
1 parent 42ef3cf commit f722672
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server/TEMPLATE_UPDATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This document explains, step-by-step, how to update the template of a pass.
1. Commit the changes
1. Make your changes in the new folder
1. Commit the changes
1. Change the `appleTemplateVersion` in `utils/Config.ts`
1. Increase the `appleTemplateVersion` in `utils/Config.ts`
1. Test that the new pass is successfully generated by making a `[GET]` request to `http://localhost:3000/api/downloadPass` (see full request example in `cypress/e2e/api/apple/downloadPass.cy.ts`)
1. Test that it works to open the generated `.pkpass` file on an iOS device
1. Commit the changes
Expand Down
4 changes: 2 additions & 2 deletions server/cypress/e2e/api/apple/[passTypeIdentifier].cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('Get the List of Updatable Passes', () => {
}).then((response) => {
expect(response.status).to.eq(200)
expect(JSON.stringify(response.body)).to.contain('serialNumbers')
expect(JSON.stringify(response.body)).to.contain('lastUpdated')
// TODO: verify serial number value(s)
expect(JSON.stringify(response.body)).to.contain('lastUpdated')
})
})

Expand All @@ -42,8 +42,8 @@ describe('Get the List of Updatable Passes', () => {
}).then((response) => {
expect(response.status).to.eq(200)
expect(JSON.stringify(response.body)).to.contain('serialNumbers')
expect(JSON.stringify(response.body)).to.contain('lastUpdated')
// TODO: verify serial number value(s)
expect(JSON.stringify(response.body)).to.contain('lastUpdated')
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
error: 'Internal Server Error: ' + latest_updates_result.error.message
})
} else {
// Return matching passes (serial numbers) and their modification time
const latestUpdateDate: Date = new Date(latest_updates_result.data['time'])

// Return matching passes (serial numbers)
res.status(200).json({
serialNumbers: serialNumbers,
lastUpdated: Math.round(latestUpdateDate.getTime() / 1000)
lastUpdated: String(Math.round(latestUpdateDate.getTime() / 1000))
})
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
} else {
const latestUpdateDate: Date = new Date(latest_updates_result.data['time'])
const latestUpdateTitle: string = latest_updates_result.data['title']
const latestUpdateContent: string = latest_updates_result.data['content'] + '\r\n\r\n' + config.appleWebServiceUrl
const latestUpdateContent: string = latest_updates_result.data['content'] + '\r\n\r\nwebServiceURL: ' + config.appleWebServiceUrl

// Populate the pass template
const platform: Platform = Platform.Apple
Expand Down
2 changes: 1 addition & 1 deletion server/pages/api/downloadPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
} else {
const latestUpdateDate: Date = new Date(latest_updates_result.data['time'])
const latestUpdateTitle: string = latest_updates_result.data['title']
const latestUpdateContent: string = latest_updates_result.data['content'] + '\r\n\r\n' + config.appleWebServiceUrl
const latestUpdateContent: string = latest_updates_result.data['content'] + '\r\n\r\nwebServiceURL: ' + config.appleWebServiceUrl

// Populate the pass template
const filePath: string = Passes.generatePass(
Expand Down

0 comments on commit f722672

Please sign in to comment.