Comparing version 0.2.1 to 0.3.0
14
index.js
@@ -50,2 +50,10 @@ /*! | ||
function massageDoc(doc) { | ||
if (Array.isArray(doc.metadata)) { // old format, used up to tDoc r13584 | ||
doc.lotto = +doc.lotto; | ||
doc.metadata = nameValue2Object(doc.metadata); | ||
} | ||
return doc; | ||
} | ||
function GET(me, method, data) { | ||
@@ -105,5 +113,3 @@ return restler.get(me.address + method, { | ||
data.document.warning = { message: data.warning.shift(), extra: data.warning }; | ||
data = data.document; | ||
data.metadata = nameValue2Object(data.metadata); | ||
return data; | ||
return massageDoc(data.document); | ||
} | ||
@@ -217,3 +223,3 @@ throw new Error('Unexpected return value: ' + JSON.stringify(data)); | ||
if (p.company) data.company = p.company; | ||
return GET(me, 'docs/' + (0|p.id) + '/meta', data); | ||
return GET(me, 'docs/' + (0|p.id) + '/meta', data).then(massageDoc); | ||
} | ||
@@ -220,0 +226,0 @@ |
{ | ||
"name": "tdoc-api", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Wrapper around tDoc REST-ful APIs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,2 +23,5 @@ tdoc-api | ||
- [`searchOne`](#searchone) | ||
- [`parcelCreate`](#parcelcreate) | ||
- [`parcelClose`](#parcelclose) | ||
- [`parcelDelete`](#parceldelete) | ||
- [`documentDelete`](#documentdelete) | ||
@@ -25,0 +28,0 @@ |
349
180
18683
7