vtb-appit 0.0.80 → 0.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/appit.js +40 -8
- package/package.json +1 -1
package/appit.js
CHANGED
|
@@ -813,9 +813,38 @@ class Appit {
|
|
|
813
813
|
return await this.request('PUT', `excursions/${id}`, data);
|
|
814
814
|
}
|
|
815
815
|
|
|
816
|
+
// async createTravel(data)
|
|
817
|
+
// {
|
|
818
|
+
// return await this.request('POST', `travels`, data);
|
|
819
|
+
// }
|
|
816
820
|
async createTravel(data)
|
|
817
821
|
{
|
|
818
|
-
|
|
822
|
+
const formData = new FormData();
|
|
823
|
+
|
|
824
|
+
Object.keys(data).forEach(key => {
|
|
825
|
+
if(key !== 'file') return;
|
|
826
|
+
formData.append(key, data[key]);
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
if(data.file) {
|
|
830
|
+
formData.append('files[id][]', '');
|
|
831
|
+
formData.append('files[title][]', data.title);
|
|
832
|
+
formData.append('files[file][]', fs.createReadStream(data.file));
|
|
833
|
+
}
|
|
834
|
+
let response = false;
|
|
835
|
+
try {
|
|
836
|
+
response = await axios.post('https://portal.appit4travel.com/api/v1/travels', formData, {
|
|
837
|
+
headers: {
|
|
838
|
+
'Content-Type': `multipart/form-data ${formData.getBoundary()}`,
|
|
839
|
+
Authorization: 'Bearer ' + this.token
|
|
840
|
+
},
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
console.log('Travel posted successfully:', response.data);
|
|
844
|
+
} catch (error) {
|
|
845
|
+
console.log('error');
|
|
846
|
+
}
|
|
847
|
+
return response.data;
|
|
819
848
|
}
|
|
820
849
|
|
|
821
850
|
async updateTravel(id, data)
|
|
@@ -928,12 +957,15 @@ class Appit {
|
|
|
928
957
|
formData.append('excursion_id', data.excursion_id);
|
|
929
958
|
if(data.content)
|
|
930
959
|
formData.append('content', data.content);
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
960
|
+
|
|
961
|
+
if(data.file) {
|
|
962
|
+
formData.append('files[id][]', '');
|
|
963
|
+
formData.append('files[title][]', data.title);
|
|
964
|
+
formData.append('files[file][]', fs.createReadStream(data.file));
|
|
965
|
+
}
|
|
966
|
+
let response = false;
|
|
935
967
|
try {
|
|
936
|
-
|
|
968
|
+
response = await axios.post('https://portal.appit4travel.com/api/v1/documents', formData, {
|
|
937
969
|
headers: {
|
|
938
970
|
'Content-Type': `multipart/form-data ${formData.getBoundary()}`,
|
|
939
971
|
Authorization: 'Bearer ' + this.token
|
|
@@ -944,7 +976,7 @@ class Appit {
|
|
|
944
976
|
} catch (error) {
|
|
945
977
|
console.log('error');
|
|
946
978
|
}
|
|
947
|
-
return
|
|
979
|
+
return response.data;
|
|
948
980
|
//return await this.request('POST', `documents`, data);
|
|
949
981
|
}
|
|
950
982
|
|
|
@@ -1023,4 +1055,4 @@ class Appit {
|
|
|
1023
1055
|
}
|
|
1024
1056
|
}
|
|
1025
1057
|
|
|
1026
|
-
module.exports = { Appit };
|
|
1058
|
+
module.exports = { Appit };
|