Skip to content

Commit 2394300

Browse files
authored
Merge pull request #216 from KenEucker/develop
adds headers to return
2 parents ca82d8d + e37e6eb commit 2394300

11 files changed

Lines changed: 43 additions & 1 deletion

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ The progress object looks like the following:
128128
Requires an image hash or delete hash, which are obtained in an image upload response
129129

130130
```ts
131-
client.delete('someImageHash');
131+
client.deleteImage('someImageHash');
132132
```
133133

134134
### Update image information

src/album/getAlbum.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ test('returns an album response', async () => {
3131
],
3232
"title": "Meme album",
3333
},
34+
"headers": Object {
35+
"content-type": "application/json",
36+
"x-powered-by": "msw",
37+
},
3438
"status": 200,
3539
"success": true,
3640
}

src/common/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export interface AlbumData extends CommonData {
120120
include_album_ads: boolean;
121121
images: ImageData[];
122122
images_count: number;
123+
deletehash: string;
123124
}
124125

125126
export interface AccountData {
@@ -158,6 +159,7 @@ export interface ImgurApiResponse<
158159
| AlbumData
159160
| AccountData
160161
> {
162+
headers: Record<string, string>;
161163
data: T;
162164
status: number;
163165
success: boolean;

src/common/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function getImgurApiResponseFromResponse(
3636
response: AxiosResponse
3737
): ImgurApiResponse {
3838
let success = true;
39+
let headers: Record<string, string>;
3940
let data;
4041
let status = 200;
4142
const responseIsValid =
@@ -63,6 +64,7 @@ export function getImgurApiResponseFromResponse(
6364
success = false;
6465
} else if (responseIsSuccess) {
6566
status = response.data.status;
67+
headers = response.headers;
6668
data = response.data.data.error
6769
? response.data.data.error
6870
: response.data.data;
@@ -72,6 +74,7 @@ export function getImgurApiResponseFromResponse(
7274
response.data.data?.error?.code ??
7375
response.status ??
7476
response.data.status;
77+
headers = response.headers;
7578
data = getResponseData(
7679
responseIsError
7780
? response.data.errors ??
@@ -82,6 +85,7 @@ export function getImgurApiResponseFromResponse(
8285
}
8386

8487
return {
88+
headers,
8589
data,
8690
status,
8791
success,

src/gallery/getGallery.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ test('returns an image response', async () => {
6060
"title": "gallery-title",
6161
},
6262
],
63+
"headers": Object {
64+
"content-type": "application/json",
65+
"x-powered-by": "msw",
66+
},
6367
"status": 200,
6468
"success": true,
6569
}

src/gallery/getSubredditGallery.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ test('returns a gallery response', async () => {
6262
"title": "gallery-title",
6363
},
6464
],
65+
"headers": Object {
66+
"content-type": "application/json",
67+
"x-powered-by": "msw",
68+
},
6569
"status": 200,
6670
"success": true,
6771
}

src/gallery/searchGallery.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ test('returns an gallery response', async () => {
6060
"title": "gallery-title",
6161
},
6262
],
63+
"headers": Object {
64+
"content-type": "application/json",
65+
"x-powered-by": "msw",
66+
},
6367
"status": 200,
6468
"success": true,
6569
}

src/image/deleteImage.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ test('delete works successfully', async () => {
88
expect(response).toMatchInlineSnapshot(`
99
Object {
1010
"data": true,
11+
"headers": Object {
12+
"content-type": "application/json",
13+
"x-powered-by": "msw",
14+
},
1115
"status": 200,
1216
"success": true,
1317
}

src/image/favoriteImage.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ test('favorite works successfully', async () => {
88
expect(response).toMatchInlineSnapshot(`
99
Object {
1010
"data": "favorited",
11+
"headers": Object {
12+
"content-type": "application/json",
13+
"x-powered-by": "msw",
14+
},
1115
"status": 200,
1216
"success": true,
1317
}

src/image/getImage.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ test('returns an image response', async () => {
1212
"id": "CEddrgP",
1313
"title": "image-title",
1414
},
15+
"headers": Object {
16+
"content-type": "application/json",
17+
"x-powered-by": "msw",
18+
},
1519
"status": 200,
1620
"success": true,
1721
}

0 commit comments

Comments
 (0)