@@ -11,7 +11,7 @@ You will also need the 'Apple Worldwide Developer Relations Certification
11
11
Authority' certificate and to conver the ` .p12 ` files into ` .pem ` files. You
12
12
can do both using the ` node-passbook prepare-keys ` command:
13
13
14
- ```
14
+ ``` sh
15
15
node-passbook prepare-keys -p keys
16
16
```
17
17
@@ -23,7 +23,7 @@ This is the same directory into which you placet the `.p12` files.
23
23
Start with a template. A template has all the common data fields that will be
24
24
shared between your passes, and also defines the keys to use for signing it.
25
25
26
- ```
26
+ ``` js
27
27
var createTemplate = require (" passbook" );
28
28
29
29
var template = createTemplate (" coupon" , {
@@ -38,7 +38,7 @@ second optional argument has any fields you want to set on the template.
38
38
39
39
You can access template fields directly, or from chained accessor methods, e.g:
40
40
41
- ```
41
+ ``` js
42
42
template .fields .passTypeIdentifier = " pass.com.example.passbook" ;
43
43
44
44
console .log (template .passTypeIdentifier ());
@@ -58,7 +58,7 @@ Optional fields that you can set on the template (or pass): `backgroundColor`,
58
58
In addition, you need to tell the template where to find the key files and where
59
59
to load images from:
60
60
61
- ```
61
+ ``` js
62
62
template .keys (" /etc/passbook/keys" , " secret" );
63
63
template .loadImagesFrom (" images" );
64
64
```
@@ -71,7 +71,7 @@ you may want to specify them once in the template.
71
71
72
72
To create a new pass from a template:
73
73
74
- ```
74
+ ``` js
75
75
var pass = template .createPass ({
76
76
serialNumber: " 123456" ,
77
77
description: " 20% off"
@@ -81,7 +81,7 @@ var pass = template.createPass({
81
81
Just like template, you can access pass fields directly, or from chained
82
82
accessor methods, e.g:
83
83
84
- ```
84
+ ``` js
85
85
pass .fields .serialNumber = " 12345" ;
86
86
console .log (pass .serialNumber ());
87
87
pass .serialNumber (" 12345" ).
95
95
To make it easier, you can use methods like ` add ` , ` get ` and ` remove ` that
96
96
will do the logical thing. For example, to add a primary field:
97
97
98
- ```
98
+ ``` js
99
99
pass .primaryFields .add (" date" , " Date" , " Nov 1" );
100
100
pass .primaryFields .add ({ key: " time" , label: " Time" , value: " 10:00AM" );
101
101
` ` `
@@ -104,21 +104,21 @@ You can also call `add` with an array of triplets or array of objects.
104
104
105
105
To get one or all fields:
106
106
107
- ```
107
+ ` ` ` js
108
108
var dateField = pass .primaryFields .get (" date" );
109
109
var allFields = pass .primaryFields .all ();
110
110
` ` `
111
111
112
112
To remove one or all fields:
113
113
114
- ```
114
+ ` ` ` js
115
115
pass .primaryFields .remove (" date" );
116
116
pass .primaryFields .clear ();
117
117
` ` `
118
118
119
119
Adding images to a pass is the same as adding images to a template:
120
120
121
- ```
121
+ ` ` ` js
122
122
pass .images .icon = iconFilename;
123
123
pass .icon (iconFilename);
124
124
pass .loadImagesFrom (" images" );
@@ -134,7 +134,7 @@ and a buffer to its callback.
134
134
135
135
To generate a file:
136
136
137
- ```
137
+ ` ` ` js
138
138
var file = fs .createWriteStream (" mypass.pkpass" );
139
139
pass .on (" error" , function (error ) {
140
140
console .error (error);
@@ -151,7 +151,7 @@ You can pipe to any writeable stream. When working with HTTP, the `render`
151
151
method will set the content type, pipe to the HTTP response, and make use of a
152
152
callback (if supplied).
153
153
154
- ```
154
+ ` ` ` js
155
155
server .get (" /mypass" , function (request , response ) {
156
156
pass .render (response, function (error ) {
157
157
if (error)
0 commit comments