This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest-api-code-snippet.html
728 lines (690 loc) · 27.2 KB
/
rest-api-code-snippet.html
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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../syntax-highlight/syntax-highlight.html">
<link rel="stylesheet" href="https://highlightjs.org/static/demo/styles/github-gist.css">
<!--
`rest-api-code-snippet` injects a code snippet of the desired language into your page.
Example:
<rest-api-code-snippet base-url="https://example.com" endpoint="[[endpoint]]" language="python"></rest-api-code-snippet>
-->
<dom-module id="rest-api-code-snippet">
<template>
<style>
:host {
display: block;
position: relative;
}
code#code {
border-radius: 2px;
}
code#code::-webkit-scrollbar {
height: 4px;
}
code#code::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.4);
border-radius: 2px;
}
textarea#codeToCopy {
position: fixed;
top: -7px;
left: -7px;
width: 1px;
height: 1px;
}
paper-button {
position: absolute;
top: 2em;
right: 0;
background: var(--accent-color);
}
</style>
<pre>
<code id="code" class$="[[language]]"></code>
</pre>
<paper-button raised on-tap="copySnippet">Copy</paper-button>
<textarea id="codeToCopy" value="[[snippet]]"></textarea>
</template>
<script src="highlight.js"></script>
<script src="string_includes_polyfill.js"></script>
<script src="node_modules/form-urlencoded/form-urlencoded.js"></script>
<script>
(function () {
'use strict';
const GET = 'GET';
const HEAD = 'HEAD';
const POST = 'POST';
const PUT = 'PUT';
const DELETE = 'DELETE';
const TRACE = 'TRACE';
const OPTIONS = 'OPTIONS';
const CONNECT = 'CONNECT';
const PATCH = 'PATCH';
const CURL = 'curl';
const JS = 'js';
const PYTHON = 'python';
const SWIFT = 'swift';
const GO = 'go';
const RUBY = 'ruby';
const PHP = 'php';
const JAVA = 'java';
Polymer({
is: 'rest-api-code-snippet',
properties: {
/**
* The base URL of the API
*/
baseUrl: String,
/**
* Information about the endpoint
* @type {{title: string, endpoint: string, params: Array<HTMLElement>, headers: Array<HTMLElement>, body: Array<HTMLElement>}}
*/
endpoint: Object,
/**
* The language of the code snippet
*/
language: {
type: String,
observer: '_languageChanged'
},
snippet: String
},
observers: ['_updateSnippet(endpoint.*, language, baseUrl)'],
copySnippet: function() {
var copyText = this.$.codeToCopy;
copyText.select();
document.execCommand("Copy");
},
/**
* Parse a string value into a Boolean, Number or String
* @param val The value to parse
* @returns {boolean | number | string} Parsed value
*/
parseValue: function (val) {
if (typeof val === 'string' && val.length > 0) {
// Try parsing booleans and numbers
try {
return JSON.parse(val);
} catch (e) {
return val;
}
}
return val;
},
/**
* Called when endpoint, language or baseUrl are changed
* @private
*/
_updateSnippet: function () {
var snippet;
// Get/Parse needed values
var method = this.endpoint.method;
var url = this.baseUrl + this.endpoint.endpoint;
var paramObjects = this.endpoint.params;
var params = {};
var headerObjects = this.endpoint.headers;
var headers = {};
var bodyObjects = this.endpoint.body;
var body;
for (var p = 0; p < paramObjects.length; p++) {
params[paramObjects[p].key] = paramObjects[p]['values'][0];
}
for (var h = 0; h < headerObjects.length; h++) {
headers[headerObjects[h].key] = headerObjects[h]['values'][0];
}
if (bodyObjects instanceof Array) {
body = {};
for (var b = 0; b < bodyObjects.length; b++) {
body[bodyObjects[b].key] = this.parseValue(bodyObjects[b].values[0]);
}
} else {
body = bodyObjects;
}
// Get code snippet based on language
switch (this.language) {
case CURL:
snippet = this.getCurlSnippet(method, url, params, headers, body);
break;
case JS:
snippet = this.getJsSnippet(method, url, params, headers, body);
break;
case PYTHON:
snippet = this.getPythonSnippet(method, url, params, headers, body);
break;
case SWIFT:
snippet = this.getSwiftSnippet(method, url, params, headers, body);
break;
case GO:
snippet = this.getGoSnippet(method, url, params, headers, body);
break;
case RUBY:
snippet = this.getRubySnippet(method, url, params, headers, body);
break;
case PHP:
snippet = this.getPhpSnippet(method, url, params, headers, body);
break;
case JAVA:
snippet = this.getJavaSnippet(method, url, params, headers, body);
break;
default:
snippet = 'Language currently not supported. Unfortunately there are no current plans to implement it ' +
':( PR are welcome';
}
// Display code snippet and highlight it
this.snippet = snippet;
this.$.code.innerText = this.snippet;
hljs.highlightBlock(this.$.code);
},
/**
* Get a curl snippet
* @param method The request method
* @param url The full url: base URL + endpoint
* @param params Param object
* @param headers Header object
* @param body Body object
* @returns {string} A curl snippet
*/
getCurlSnippet: function (method, url, params, headers, body) {
var formData = new FormData();
for (var param in params) {
formData.append(param, params[param]);
}
var snippet = `curl -X ${method} \\\n '${url}${
!this.isEmptyObject(params)?`?${formurlencoded(params)}`:''
}' \\\n`;
if (!this.isEmptyObject(headers)) {
for(var header in headers) {
snippet += ` -H '${header}: ${headers[header]}' \\\n`;
}
}
// Construct body
if (body) {
var contentType = headers['Content-Type'];
if (contentType && contentType.includes('application/json')) {
// Construct as JSON body
snippet += ` -d '${JSON.stringify(body, null, '\t')}' \\\n`;
} else if (contentType && contentType.includes('application/x-www-form-urlencoded')) {
// Construct as x-www-form-urlencode body
snippet += ` -d '${formurlencoded(body)} \\\n`;
} else if (contentType && contentType.includes('multipart/form-data')) {
// Construct as multipart/form-data body
for(var key in body) {
snippet += ` -F ${key}=${body[key]} \\\n`
}
} else if (body && body.length > 0) {
// Construct as raw string body
bodyString = ` -d '${body}' \\\n`;
}
}
return snippet.substr(0, snippet.length - 2);
},
/**
* Get a javascript snippet
* @param method The request method
* @param url The full url: base URL + endpoint
* @param params Param object
* @param headers Header object
* @param body Body object
* @returns {string} A javascript snippet
*/
getJsSnippet: function (method, url, params, headers, body) {
var snippet = '';
var requestString = '', headerString = '', bodyString = '';
var value, key;
// Add params to URL
if (!this.isEmptyObject(params)) {
url += '?';
for (var param in params) {
if (params.hasOwnProperty(param)) {
url += param + '=' + params[param] + '&';
}
}
url = url.substr(0, url.length - 1);
}
// Construct header object as snippet
if (!this.isEmptyObject(headers)) {
headerString += 'var headers = new Headers();\n';
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
headerString += `headers.append('${header}', '${headers[header]}');\n`;
}
}
headerString += '\n';
}
// Construct body as snippet
var contentType = headers['Content-Type'];
if (contentType && contentType.includes('application/json')) {
// Construct as JSON body
bodyString = `var body = ${JSON.stringify(body, null, '\t')};\n\n`;
} else if (contentType && contentType.includes('application/x-www-form-urlencoded')) {
// Construct as x-www-form-urlencode body
bodyString = 'body = new URLSearchParams();\n';
for (var bUrl in body) {
if (body.hasOwnProperty(bUrl)) {
value = body[bUrl];
key = bUrl;
bodyString += `body.append('${key}', ${typeof value === 'string' ? `'${value}'` : value});\n`;
}
}
bodyString += '\n';
} else if (contentType && contentType.includes('multipart/form-data')) {
// Construct as multipart/form-data body
bodyString = 'body = new FormData();\n';
for (var bForm in body) {
if (body.hasOwnProperty(bForm)) {
value = body[bForm];
key = bForm;
bodyString += `body.append('${key}', ${typeof value === 'string' ? `'${value}'` : value});\n`;
}
}
bodyString += '\n';
} else if (body && body.length > 0) {
// Construct as raw string body
bodyString = `var body = '${body};\n\n`;
}
// Construct init and fetch code snippet
var init = "var init = {" +
`\n\tmethod: '${method}'` +
`${!this.isEmptyObject(headers) ? `,\n\theaders: headers` : ''}` +
`${body ? `,\n\tbody: body` : ''}` +
'\n};';
requestString += `${init}\n\n`;
requestString += `var request = fetch(\n\t'${url}', init);\n`;
requestString += `request.then(result => {\n\tconsole.log(result);\n});`;
switch (method) {
case GET:
snippet += headerString + requestString;
break;
case HEAD:
snippet += headerString + requestString;
break;
case POST:
snippet += headerString + bodyString + requestString;
break;
case PUT:
snippet += headerString + bodyString + requestString;
break;
case DELETE:
snippet += headerString + bodyString + requestString;
break;
case TRACE:
snippet += headerString + requestString;
break;
case OPTIONS:
snippet += headerString + requestString;
break;
case CONNECT:
snippet += headerString + requestString;
break;
case PATCH:
snippet += headerString + bodyString + requestString;
break;
}
return snippet;
},
/**
* Get a python snippet
* @param method The request method
* @param url The full url: base URL + endpoint
* @param params Param object
* @param headers Header object
* @param body Body object
* @returns {string} A python snippet
*/
getPythonSnippet: function (method, url, params, headers, body) {
var snippet ='import requests\n\n';
var requestString = '', paramString = '', headerString = '', bodyString = '';
var key, value;
// Start request string
requestString = `response = request.get('${url}'`;
// Construct params payload object as snippet
if (!this.isEmptyObject(params)) {
paramString = `payload = ${JSON.stringify(params, null, '\t')}\n\n`;
requestString += ',\n\t\t\tparams=payload';
}
// Construct header object as snippet
if (!this.isEmptyObject(headers)) {
headerString = `headers = ${JSON.stringify(headers, null, '\t')}\n\n`;
requestString += ', headers=headers';
}
// Construct body as snippet
var contentType = headers['Content-Type'];
if (contentType &&
(contentType.includes('application/json') || contentType.includes('application/x-www-form-urlencode'))) {
// Construct as json or x-www-form-urlencode body
bodyString = `body = ${JSON.stringify(body, null, '\t')}\n\n`;
requestString += ', data=body';
} else if (contentType && contentType.includes('multipart/form-data')) {
// Construct as snippet multipart/form-data
bodyString = 'body = (';
for (var bForm in body) {
if (body.hasOwnProperty(bForm)) {
value = body[bForm];
key = bForm;
bodyString += `\n\t('${key}', ${typeof value === 'string' ? `'${value}'` : value}),`;
}
}
bodyString = bodyString.substr(0, bodyString.length - 1);
bodyString += '\n)\n\n';
requestString += ', files=body';
} else if (body && body.length > 0) {
// Construct as raw string body
bodyString = `body = '${body}';\n\n`;
requestString += ', data=body';
}
// Replace `true` and `false` with Pythons `True` and `False`
bodyString = bodyString.split('true').join('True').split('false').join('False');
// Close request string
requestString += ')\n';
switch (method) {
case GET:
snippet += paramString + headerString + requestString;
break;
case HEAD:
snippet += paramString + headerString + requestString;
break;
case POST:
snippet += paramString + headerString + bodyString + requestString;
break;
case PUT:
snippet += paramString + headerString + bodyString + requestString;
break;
case DELETE:
snippet += paramString + headerString + bodyString + requestString;
break;
case TRACE:
snippet += paramString + headerString + requestString;
break;
case OPTIONS:
snippet += paramString + headerString + requestString;
break;
case CONNECT:
snippet += paramString + headerString + requestString;
break;
case PATCH:
snippet += paramString + headerString + bodyString + requestString;
break;
}
return snippet;
},
/**
* Get a swift snippet
* @param method The request method
* @param url The full url: base URL + endpoint
* @param params Param object
* @param headers Header object
* @param body Body object
* @returns {string} A swift snippet
*/
getSwiftSnippet: function (method, url, params, headers, body) {
var headerString = '', bodyString = '';
if (!this.isEmptyObject(headers)) {
headerString += 'let headers = [\n';
for(var header in headers) {
headerString += `\t"${header}": "${headers[header]}",\n`
}
headerString = headerString.substr(0, headerString.length - 2);
headerString += '\n]';
}
if (body) {
var contentType = headers['Content-Type'];
if (contentType && contentType.includes('application/json')) {
// Construct as JSON body
bodyString += 'let parameters = [\n';
for(var key in body) {
bodyString += `\t"${key}": "${body[key]}",\n`;
}
bodyString = bodyString.substr(0, bodyString.length - 2);
bodyString += '] as [String : Any]\n\n';
bodyString += 'let postData = JSONSerialization.data(withJSONObject: parameters, options: [])';
} else if (contentType && contentType.includes('application/x-www-form-urlencoded')) {
// Construct as x-www-form-urlencode body
const bodyKeys = body.keys();
console.log(bodyKeys);
if (bodyKeys.length > 0) {
bodyString += `let postData = NSMutableData(data: "${bodyKeys[0]}=${body[bodyKeys[0]]}".data(using: String.Encoding.utf8)!)\n`;
for(let i=1; i<bodyKeys.length; i++) {
bodyString += `postData.append("&${bodyKeys[i]}=${body[bodyKeys[i]]}".data(using: String.Encoding.utf8)!)\n`;
}
}
} else if (contentType && contentType.includes('multipart/form-data')) {
// Construct as multipart/form-data body
bodyString += '// Currently unsupported Content-Type :/ PR\'s are welcomd :) ';
} else if (body && body.length > 0) {
// Construct as raw string body
bodyString = ` -d '${body}' \\\n`;
}
}
var snippet = `import Foundation\n\n${headerString}\n\n${bodyString}\n\n`
snippet+=`let request = NSMutableURLRequest(url: NSURL(string: "${url}${
!this.isEmptyObject(params)?`?${formurlencoded(params)}`:''
}")! as URL,
\tcachePolicy: .useProtocolCachePolicy,
\ttimeoutInterval: 10.0)
request.httpMethod = "${method}"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()`;
return snippet
},
/**
* Get a go snippet
* @param method The request method
* @param url The full url: base URL + endpoint
* @param params Param object
* @param headers Header object
* @param body Body object
* @returns {string} A go snippet
*/
getGoSnippet: function (method, url, params, headers, body) {
var snippet = '';
switch (method) {
case GET:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case HEAD:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case POST:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case PUT:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case DELETE:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case TRACE:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case OPTIONS:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case CONNECT:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case PATCH:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
}
return snippet;
},
/**
* Get a ruby snippet
* @param method The request method
* @param url The full url: base URL + endpoint
* @param params Param object
* @param headers Header object
* @param body Body object
* @returns {string} A ruby snippet
*/
getRubySnippet: function (method, url, params, headers, body) {
var snippet = 'require \'rest-client\'\n\n';
var requestString = '', headerString = '', bodyString = '';
requestString += `response = RestClient.${method.toLowerCase()} '${url}' `;
if (!this.isEmptyObject(params)) {
url += '?';
for (var param in params) {
if (params.hasOwnProperty(param)) {
url += param + '=' + params[param] + '&';
}
}
url = url.substr(0, url.length - 1);
}
if (!this.isEmptyObject(headers)) {
headerString += 'headers = {';
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
headerString += '\n\t\'' + header + '\': ' + headers[header] + ',';
}
}
headerString = headerString.substr(0, headerString.length - 1);
headerString += '\n}\n\n';
requestString += 'headers=headers ';
}
switch (method) {
case GET:
snippet += headerString + requestString;
snippet = 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case HEAD:
snippet += headerString + requestString;
snippet = 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case POST:
snippet = 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case PUT:
snippet = 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case DELETE:
snippet += headerString + requestString;
snippet = 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case TRACE:
snippet += headerString + requestString;
snippet = 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case OPTIONS:
snippet += headerString + requestString;
snippet = 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case CONNECT:
snippet += headerString + requestString;
snippet = 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case PATCH:
snippet = 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
}
return snippet;
},
/**
* Get a php snippet
* @param method The request method
* @param url The full url: base URL + endpoint
* @param params Param object
* @param headers Header object
* @param body Body object
* @returns {string} A php snippet
*/
getPhpSnippet: function (method, url, params, headers, body) {
var snippet = '';
switch (method) {
case GET:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case HEAD:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case POST:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case PUT:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case DELETE:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case TRACE:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case OPTIONS:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case CONNECT:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case PATCH:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
}
return snippet;
},
/**
* Get a java snippet
* @param method The request method
* @param url The full url: base URL + endpoint
* @param params Param object
* @param headers Header object
* @param body Body object
* @returns {string} A java snippet
*/
getJavaSnippet: function (method, url, params, headers, body) {
var snippet = '';
switch (method) {
case GET:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case HEAD:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case POST:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case PUT:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case DELETE:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case TRACE:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case OPTIONS:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case CONNECT:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
case PATCH:
snippet += 'Currently not supported by the doc :( Stay tuned ;) PR\'s are welcome';
break;
}
return snippet;
},
/**
* Check if object is empty
* @param obj The object to check
* @returns {boolean} Is empty
*/
isEmptyObject: function (obj) {
for (var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
return false;
}
}
return true;
}
});
})();
</script>
</dom-module>