Skip to content

Commit 15f02b2

Browse files
authored
Merge pull request #221 from Aliyss/master
Added the ability to add an image to the itemDetails
2 parents 8686954 + 82c4bef commit 15f02b2

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

build/bring.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ declare class Bring {
110110
* returns an empty string and answerHttpStatus should contain 204. If not -> error
111111
*/
112112
saveItem(listUuid: string, itemName: string, specification: string): Promise<string>;
113+
/**
114+
* Save an image to an item
115+
*
116+
* @param formData The formdata you want to send.
117+
* @param itemUuid The itemUUID you want to update.
118+
* returns an imageUrl and answerHttpStatus should contain 204. If not -> error
119+
*/
120+
saveItemImage(itemUuid: string, formData: {
121+
[key: string]: any;
122+
} | undefined): Promise<{
123+
imageUrl: string;
124+
}>;
113125
/**
114126
* remove an item from your current shopping list
115127
*
@@ -118,6 +130,13 @@ declare class Bring {
118130
* should return an empty string and $answerHttpStatus should contain 204. If not -> error
119131
*/
120132
removeItem(listUuid: string, itemName: string): Promise<string>;
133+
/**
134+
* Remove the image from your item
135+
*
136+
* @param itemUuid The itemUUID you want to remove the image from.
137+
* returns an empty string and answerHttpStatus should contain 204. If not -> error
138+
*/
139+
removeItemImage(itemUuid: string): Promise<string>;
121140
/**
122141
* move an item to recent items list
123142
*

build/bring.js

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/bring.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bring.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,25 @@ class Bring {
217217
} // endCatch
218218
} // endSaveItem
219219

220+
/**
221+
* Save an image to an item
222+
*
223+
* @param formData The formdata you want to send.
224+
* @param itemUuid The itemUUID you want to update.
225+
* returns an imageUrl and answerHttpStatus should contain 204. If not -> error
226+
*/
227+
async saveItemImage(itemUuid: string, formData: { [key: string]: any } | undefined): Promise<{ imageUrl: string }> {
228+
try {
229+
const data = await request.put(`${this.url}bringlistitemdetails/${itemUuid}/image`, {
230+
headers: this.putHeaders,
231+
formData: formData
232+
});
233+
return JSON.parse(data);
234+
} catch (e: any) {
235+
throw new Error(`Cannot save item image ${itemUuid}: ${e.message}`);
236+
} // endCatch
237+
} // endSaveItemImage
238+
220239
/**
221240
* remove an item from your current shopping list
222241
*
@@ -236,6 +255,20 @@ class Bring {
236255
} // endCatch
237256
} // endRemoveItem
238257

258+
/**
259+
* Remove the image from your item
260+
*
261+
* @param itemUuid The itemUUID you want to remove the image from.
262+
* returns an empty string and answerHttpStatus should contain 204. If not -> error
263+
*/
264+
async removeItemImage(itemUuid: string): Promise<string> {
265+
try {
266+
return await request.delete(`${this.url}bringlistitemdetails/${itemUuid}/image`);
267+
} catch (e: any) {
268+
throw new Error(`Cannot remove item image ${itemUuid}: ${e.message}`);
269+
} // endCatch
270+
} // endRemoveItemImage
271+
239272
/**
240273
* move an item to recent items list
241274
*

0 commit comments

Comments
 (0)