-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
485 lines (468 loc) · 15.6 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
// Copyright 2017 Jon Williams -- See LICENSE
var fs = require('fs');
/**
* Sends an email with the given JSON-LD semantic markup included.
* @param {String} name
* @param {String} description
* @param {Object} ld
*/
const send = function (name, description, ld) {
var html = `<html><head><title>${name}</title></head><body>
<script type='application/ld+json'>${JSON.stringify(ld)}</script>
<h1>${name}</h1>
<p>${description}</p>
</body></html>`.replace(/\r?\n|\r/g, "");
console.log(`\n //${html}\n input = "${html.replace(/"/g, "\\\"")}";
MailApp.sendEmail({to: Session.getActiveUser().getEmail(), subject: 'Semantic Email Tester - ${name}', htmlBody: input});`);
}
console.log(`function sendSemanticEmailTests() {\n var input;`);
// https://developers.google.com/gmail/markup/reference/one-click-action
send('one-click-action', 'One Click Actions are those little buttons on the GMail that appear directly in the subject line.',
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ConfirmAction",
"name": "Approve Expense",
"handler": {
"@type": "HttpActionHandler",
"url": "https://jonathannen.com/semantic-email.html"
}
},
"description": "Approval request for John's $10.13 expense for office supplies"
}
);
// https://developers.google.com/gmail/markup/reference/article
send('article', 'Includes an Article',
{
"@context": "http://schema.org",
"@type": "Article",
"name": "NASA's Messenger Probe Comes To Fiery End On Mercury",
"url": "http://americanlivewire.com/2015-04-29-nasas-messenger-probe-comes-to-fiery-end-on-mercury/",
"description": "But besides small size and swift speed, little was known about this mysterious planet until (MErcury Surface, Space ENvironment, GEochemistry, and Ranging) spacecraft became the first man-made instrument to orbit Mercury in 2011.",
"image": "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRaDt8TQrRdsrSt_smjLiXZTIqEHjq0PjjzzuqLMOzPUqFbpeMqHcksY-gVnoc8bPpUSOcCj6aW",
"publisher": {
"@type": "Organization",
"name": "American Live Wire"
}
}
);
// https://developers.google.com/gmail/markup/reference/order
send('basic-order', 'Notification of an order',
{
"@context": "http://schema.org",
"@type": "Order",
"merchant": {
"@type": "Organization",
"name": "Amazon.com"
},
"orderNumber": "123-4567890-1234567",
"priceCurrency": "USD",
"price": "29.99",
"acceptedOffer": {
"@type": "Offer",
"itemOffered": {
"@type": "Product",
"name": "Google Chromecast"
},
"price": "29.99",
"priceCurrency": "USD",
"eligibleQuantity": {
"@type": "QuantitativeValue",
"value": "1"
}
}
}
);
// https://developers.google.com/gmail/markup/reference/order
send('view-order', 'Order with viewing information',
{
"@context": "http://schema.org",
"@type": "Order",
"merchant": {
"@type": "Organization",
"name": "Amazon.com"
},
"orderNumber": "123-4567890-1234567",
"orderStatus": "http://schema.org/OrderProcessing",
"priceCurrency": "USD",
"price": "29.99",
"priceSpecification": {
"@type": "PriceSpecification",
"validFrom": "2027-12-07T23:30:00-08:00"
},
"acceptedOffer": {
"@type": "Offer",
"itemOffered": {
"@type": "Product",
"name": "Google Chromecast",
"sku": "B00DR0PDNE",
"url": "http://www.amazon.com/Google-Chromecast-Streaming-Media-Player/dp/B00DR0PDNE/",
"image": "http://ecx.images-amazon.com/images/I/811nvG%2BLgML._SY550_.jpg"
},
"price": "29.99",
"priceCurrency": "USD",
"eligibleQuantity": {
"@type": "QuantitativeValue",
"value": "1"
}
},
"url": "https://www.amazon.ca/gp/css/summary/edit.html/orderID=123-4567890-1234567",
"potentialAction": {
"@type": "ViewAction",
"url": "https://www.amazon.ca/gp/css/summary/edit.html/orderID=123-4567890-1234567"
}
}
);
// https://developers.google.com/gmail/markup/reference/order
send('order-with-billing-details', 'An order with billing details included',
{
"@context": "http://schema.org",
"@type": "Order",
"merchant": {
"@type": "Organization",
"name": "Amazon.com"
},
"orderNumber": "123-4567890-1234567",
"priceCurrency": "USD",
"price": "539.00",
"priceSpecification": {
"@type": "PriceSpecification",
"validFrom": "2027-12-07T23:30:00-08:00"
},
"acceptedOffer": [
{
"@type": "Offer",
"itemOffered": {
"@type": "Product",
"name": "Samsung Chromebook",
"sku": "B009LL9VDG",
"url": "http://www.amazon.com/Samsung-XE303C12-A01US-Chromebook-Wi-Fi-11-6-Inch/dp/B009LL9VDG/",
"image": "http://ecx.images-amazon.com/images/I/81H-DO3qX0L._SX522_.jpg"
},
"price": "249.99",
"priceCurrency": "USD",
"eligibleQuantity": {
"@type": "QuantitativeValue",
"value": "2"
},
"seller": {
"@type": "Organization",
"name": "Samsung Marketplace Store"
}
},
{
"@type": "Offer",
"itemOffered": {
"@type": "Product",
"name": "Google Chromecast",
"sku": "B00DR0PDNE",
"url": "http://www.amazon.com/Google-Chromecast-Streaming-Media-Player/dp/B00DR0PDNE/",
"image": "http://ecx.images-amazon.com/images/I/811nvG%2BLgML._SY550_.jpg"
},
"price": "29.99",
"priceCurrency": "USD",
"eligibleQuantity": {
"@type": "QuantitativeValue",
"value": "1"
},
"seller": {
"@type": "Organization",
"name": "Google Store @ Amazon"
}
}
],
"url": "https://www.amazon.ca/gp/css/summary/edit.html/orderID=123-4567890-1234567",
"potentialAction": {
"@type": "ViewAction",
"url": "https://www.amazon.ca/gp/css/summary/edit.html/orderID=123-4567890-1234567"
},
"orderStatus": "http://schema.org/OrderProcessing",
"paymentMethod": {
"@type": "PaymentMethod",
"name": "http://schema.org/CreditCard"
},
"paymentMethodId": "**** **** **** 1234",
"orderDate": "2027-11-07T23:30:00-08:00",
"isGift": "false",
"discount": "0.97",
"discountCurrency": "USD",
"customer": {
"@type": "Person",
"name": "John Smith"
},
"billingAddress": {
"@type": "PostalAddress",
"name": "Google",
"streetAddress": "1600 Amphitheatre Pkwy",
"addressLocality": "Mountain View",
"addressRegion": "CA",
"addressCountry": "USA"
}
}
);
// https://developers.google.com/gmail/markup/reference/parcel-delivery
send('parcel-delivery', 'Parcel delivery confirmation',
{
"@context": "http://schema.org",
"@type": "ParcelDelivery",
"deliveryAddress": {
"@type": "PostalAddress",
"name": "Pickup Corner",
"streetAddress": "24 Willie Mays Plaza",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"addressCountry": "US",
"postalCode": "94107"
},
"expectedArrivalUntil": "2027-03-12T12:00:00-08:00",
"carrier": {
"@type": "Organization",
"name": "FedEx"
},
"itemShipped": {
"@type": "Product",
"name": "Google Chromecast"
},
"partOfOrder": {
"@type": "Order",
"orderNumber": "176057",
"merchant": {
"@type": "Organization",
"name": "Bob Dole"
}
}
}
)
// https://developers.google.com/gmail/markup/reference/invoice
send('invoice', 'Invoice for payment',
{
"@context": "http://schema.org",
"@type": "Invoice",
"accountId": "123-456-789",
"minimumPaymentDue": {
"@type": "PriceSpecification",
"price": "$70.00"
},
"paymentDue": "2015-11-22T08:00:00+00:00",
"paymentStatus": "PaymentAutomaticallyApplied",
"provider": {
"@type": "Organization",
"name": "Mountain View Utilities"
},
"totalPaymentDue": {
"@type": "PriceSpecification",
"price": "$70.00"
}
}
);
send('event', 'Event Reservation for Foo Fighters Concert',
{
"@context": "http://schema.org",
"@type": "EventReservation",
"reservationNumber": "E123456789",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "John Smith"
},
"reservationFor": {
"@type": "Event",
"name": "Foo Fighters Concert",
"startDate": "2027-03-06T19:30:00-08:00",
"location": {
"@type": "Place",
"name": "AT&T Park",
"address": {
"@type": "PostalAddress",
"streetAddress": "24 Willie Mays Plaza",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"postalCode": "94107",
"addressCountry": "US"
}
}
}
}
);
// https://developers.google.com/gmail/markup/reference/flight-reservation
send('flight', 'Includes an Flight Confirmation',
{
"@context": "http://schema.org",
"@type": "FlightReservation",
"reservationNumber": "RXJ34P",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "Eva Green"
},
"reservationFor": {
"@type": "Flight",
"flightNumber": "110",
"airline": {
"@type": "Airline",
"name": "United",
"iataCode": "UA"
},
"departureAirport": {
"@type": "Airport",
"name": "San Francisco Airport",
"iataCode": "SFO"
},
"departureTime": "2027-03-04T20:15:00-08:00",
"arrivalAirport": {
"@type": "Airport",
"name": "John F. Kennedy International Airport",
"iataCode": "JFK"
},
"arrivalTime": "2027-03-05T06:30:00-05:00"
}
}
);
// https://developers.google.com/gmail/markup/reference/hotel-reservation
send('hotel', 'A Hotel reservation',
{
"@context": "http://schema.org",
"@type": "LodgingReservation",
"reservationNumber": "abc456",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "John Smith"
},
"reservationFor": {
"@type": "LodgingBusiness",
"name": "Hilton San Francisco Union Square",
"address": {
"@type": "PostalAddress",
"streetAddress": "333 O'Farrell St",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"postalCode": "94102",
"addressCountry": "US"
},
"telephone": "415-771-1400"
},
"checkinDate": "2027-04-11T16:00:00-08:00",
"checkoutDate": "2027-04-13T11:00:00-08:00"
}
);
send('rental-car', 'A Rental Car reservation',
{
"@context": "http://schema.org",
"@type": "RentalCarReservation",
"reservationNumber": "546323",
"reservationStatus": "http://schema.org/Confirmed",
"url": "http://carrentals.com/view/546323",
"underName": {
"@type": "Person",
"name": "John Smith",
"email": "john@mail.com"
},
"programMembership": {
"@type": "ProgramMembership",
"memberNumber": "1234567",
"program": "AAA"
},
"bookingAgent": {
"@type": "Organization",
"name": "Car Rentals Internationaly",
"url": "http://carrentals.com/"
},
"bookingTime": "2027-01-14T13:05:00-05:00",
"modifiedTime": "2027-03-14T13:05:00-05:00",
"confirmReservationUrl": "http://carrentals.com/confirm?id=546323",
"cancelReservationUrl": "http://carrentals.com/cancel?id=546323",
"checkinUrl": "http://carrentals.com/checkin?id=546323",
"modifyReservationUrl": "http://carrentals.com/edit?id=546323",
"potentialAction": [
{
"@type": "ConfirmAction",
"target": "http://carrentals.com/confirm?id=546323"
},
{
"@type": "CancelAction",
"target": "http://carrentals.com/cancel?id=546323"
},
{
"@type": "EditAction",
"target": "http://carrentals.com/edit?id=546323"
},
{
"@type": "CheckInAction",
"target": "http://carrentals.com/checkin?id=546323"
}
],
"reservationFor": {
"@type": "RentalCar",
"name": "Economy Class Car",
"model": "Civic",
"brand": {
"@type": "Brand",
"name": "Honda"
},
"description": "Sedan 4 Door, 5 Seatbelts, Automatic transmission",
"rentalCompany": {
"@type": "Organization",
"name": "Hertz"
}
},
"pickupLocation": {
"@type": "Place",
"name": "Hertz San Diego Airport",
"address": {
"@type": "PostalAddress",
"streetAddress": "1500 Orange Avenue",
"addressLocality": "San Diego",
"addressRegion": "CA",
"postalCode": "94043",
"addressCountry": "US"
},
"telephone": "+1-800-123-4567"
},
"pickupTime": "2027-08-05T16:00:00-07:00",
"dropoffLocation": {
"@type": "Place",
"name": "Hertz LAX",
"address": {
"@type": "PostalAddress",
"streetAddress": "1234 First Street",
"addressLocality": "Los Angeles",
"addressRegion": "CA",
"postalCode": "94043",
"addressCountry": "US"
},
"telephone": "+1-800-123-4567"
},
"dropoffTime": "2027-08-06T20:00:00-07:00",
"price": "119.00",
"priceCurrency": "USD"
}
);
send('restaurant', 'A Restaurant reservation',
{
"@context": "http://schema.org",
"@type": "FoodEstablishmentReservation",
"reservationNumber": "OT12345",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "John Smith"
},
"reservationFor": {
"@type": "FoodEstablishment",
"name": "Wagamama",
"address": {
"@type": "PostalAddress",
"streetAddress": "1 Tavistock Street",
"addressLocality": "London",
"addressRegion": "Greater London",
"postalCode": "WC2E 7PG",
"addressCountry": "United Kingdom"
}
},
"startTime": "2027-04-10T08:00:00+00:00",
"partySize": "2"
}
);
console.log("}");