Skip to content

Commit 45abcd3

Browse files
committed
[TU-13737] reset modified files
1 parent 69682cd commit 45abcd3

File tree

2 files changed

+156
-158
lines changed

2 files changed

+156
-158
lines changed

src/images.ts

Lines changed: 76 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,88 @@
1-
import {Typeform} from './typeform-types'
1+
import { Typeform } from './typeform-types'
22

33
export class Images {
4-
constructor(private _http: Typeform.HTTPClient) {
5-
}
6-
7-
public add(args: {
8-
image?: string
9-
url?: string
10-
fileName: string
11-
}): Promise<Typeform.Image> {
12-
const {image, url, fileName} = args
4+
constructor(private _http: Typeform.HTTPClient) {}
135

14-
return this._http.request({
15-
method: 'post',
16-
url: `/images`,
17-
data: {
18-
image,
19-
file_name: fileName,
20-
url,
21-
},
22-
})
23-
}
6+
public add(args: {
7+
image?: string
8+
url?: string
9+
fileName: string
10+
}): Promise<Typeform.Image> {
11+
const { image, url, fileName } = args
2412

25-
public delete(args: { id: string }): Promise<null> {
26-
const {id} = args
13+
return this._http.request({
14+
method: 'post',
15+
url: `/images`,
16+
data: {
17+
image,
18+
file_name: fileName,
19+
url,
20+
},
21+
})
22+
}
2723

28-
return this._http.request({
29-
method: 'delete',
30-
url: `/images/${id}`,
31-
})
32-
}
24+
public delete(args: { id: string }): Promise<null> {
25+
const { id } = args
3326

34-
public get(args: {
35-
id: string
36-
size?: string
37-
backgroundSize?: string
38-
choiceSize?: string
39-
}): Promise<Typeform.Image> {
40-
const {id, size, backgroundSize, choiceSize} = args
41-
const requestQuery: Typeform.Request = {
42-
method: 'get',
43-
url: `/images/${id}`,
44-
headers: {
45-
Accept: 'application/json',
46-
},
47-
}
27+
return this._http.request({
28+
method: 'delete',
29+
url: `/images/${id}`,
30+
})
31+
}
4832

49-
const choiceImageSizes = [
50-
'default',
51-
'thumbnail',
52-
'supersize',
53-
'supermobile',
54-
'supersizefit',
55-
'supermobilefit',
56-
]
33+
public get(args: {
34+
id: string
35+
size?: string
36+
backgroundSize?: string
37+
choiceSize?: string
38+
}): Promise<Typeform.Image> {
39+
const { id, size, backgroundSize, choiceSize } = args
40+
const requestQuery: Typeform.Request = {
41+
method: 'get',
42+
url: `/images/${id}`,
43+
headers: {
44+
Accept: 'application/json',
45+
},
46+
}
5747

58-
if (size) {
59-
if (['default', 'thumbnail', 'mobile'].includes(size)) {
60-
requestQuery.url += `/image/${size}`
61-
} else {
62-
throw new Error(`Image size doesn't exist`)
63-
}
64-
} else if (backgroundSize) {
65-
if (
66-
['default', 'thumbnail', 'mobile', 'tablet'].includes(backgroundSize)
67-
) {
68-
requestQuery.url += `/background/${backgroundSize}`
69-
} else {
70-
throw new Error(`Image background size doesn't exist`)
71-
}
72-
} else if (choiceSize) {
73-
if (choiceImageSizes.includes(choiceSize)) {
74-
requestQuery.url += `/choice/${choiceSize}`
75-
} else {
76-
throw new Error(`Image choice size doesn't exist`)
77-
}
78-
}
48+
const choiceImageSizes = [
49+
'default',
50+
'thumbnail',
51+
'supersize',
52+
'supermobile',
53+
'supersizefit',
54+
'supermobilefit',
55+
]
7956

80-
return this._http.request(requestQuery)
57+
if (size) {
58+
if (['default', 'thumbnail', 'mobile'].includes(size)) {
59+
requestQuery.url += `/image/${size}`
60+
} else {
61+
throw new Error(`Image size doesn't exist`)
62+
}
63+
} else if (backgroundSize) {
64+
if (
65+
['default', 'thumbnail', 'mobile', 'tablet'].includes(backgroundSize)
66+
) {
67+
requestQuery.url += `/background/${backgroundSize}`
68+
} else {
69+
throw new Error(`Image background size doesn't exist`)
70+
}
71+
} else if (choiceSize) {
72+
if (choiceImageSizes.includes(choiceSize)) {
73+
requestQuery.url += `/choice/${choiceSize}`
74+
} else {
75+
throw new Error(`Image choice size doesn't exist`)
76+
}
8177
}
8278

83-
public list(): Promise<Typeform.Image[]> {
84-
return this._http.request({
85-
method: 'get',
86-
url: '/images',
87-
})
88-
}
79+
return this._http.request(requestQuery)
80+
}
81+
82+
public list(): Promise<Typeform.Image[]> {
83+
return this._http.request({
84+
method: 'get',
85+
url: '/images',
86+
})
87+
}
8988
}

src/webhooks.ts

Lines changed: 80 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,99 @@
1-
import {Typeform} from './typeform-types'
1+
import { Typeform } from './typeform-types'
22

33
export class Webhooks {
4-
constructor(private _http: Typeform.HTTPClient) {
5-
}
4+
constructor(private _http: Typeform.HTTPClient) {}
65

7-
public create(args: {
8-
uid: string
9-
tag: string
10-
url: string
11-
enabled?: boolean
12-
secret?: string
13-
verifySSL?: boolean
14-
}): Promise<Typeform.Webhook> {
15-
return createOrUpdateWebhook(this._http, args)
16-
}
6+
public create(args: {
7+
uid: string
8+
tag: string
9+
url: string
10+
enabled?: boolean
11+
secret?: string
12+
verifySSL?: boolean
13+
}): Promise<Typeform.Webhook> {
14+
return createOrUpdateWebhook(this._http, args)
15+
}
1716

18-
public delete(args: { uid: string; tag: string }): Promise<null> {
19-
const {uid, tag} = args
17+
public delete(args: { uid: string; tag: string }): Promise<null> {
18+
const { uid, tag } = args
2019

21-
return this._http.request({
22-
method: 'delete',
23-
url: `/forms/${uid}/webhooks/${tag}`,
24-
})
25-
}
26-
27-
public get(args: { uid: string; tag: string }): Promise<Typeform.Webhook> {
28-
const {uid, tag} = args
20+
return this._http.request({
21+
method: 'delete',
22+
url: `/forms/${uid}/webhooks/${tag}`,
23+
})
24+
}
2925

30-
return this._http.request({
31-
method: 'get',
32-
url: `/forms/${uid}/webhooks/${tag}`,
33-
})
34-
}
26+
public get(args: { uid: string; tag: string }): Promise<Typeform.Webhook> {
27+
const { uid, tag } = args
3528

36-
public list(args: { uid: string }): Promise<Typeform.API.Webhooks.List> {
37-
const {uid} = args
29+
return this._http.request({
30+
method: 'get',
31+
url: `/forms/${uid}/webhooks/${tag}`,
32+
})
33+
}
3834

39-
return this._http.request({
40-
method: 'get',
41-
url: `/forms/${uid}/webhooks`,
42-
})
43-
}
35+
public list(args: { uid: string }): Promise<Typeform.API.Webhooks.List> {
36+
const { uid } = args
4437

45-
public toggle(args: { uid: string, tag: string, enabled: boolean }): Promise<Typeform.API.Webhooks.List> {
46-
const {uid, tag, enabled} = args
38+
return this._http.request({
39+
method: 'get',
40+
url: `/forms/${uid}/webhooks`,
41+
})
42+
}
43+
44+
public toggle (args: { uid: string, tag: string, enabled: boolean }): Promise<Typeform.API.Webhooks.List> {
45+
const { uid, tag, enabled } = args
4746

48-
return this._http.request({
49-
method: 'put',
50-
url: `/forms/${uid}/webhooks/${tag}`,
51-
data: {
52-
enabled
53-
}
54-
})
55-
}
47+
return this._http.request({
48+
method: 'put',
49+
url: `/forms/${uid}/webhooks/${tag}`,
50+
data: {
51+
enabled
52+
}
53+
})
54+
}
5655

57-
update(args: {
58-
uid: string
59-
tag: string
60-
url: string
61-
enabled?: boolean
62-
secret?: string
63-
verifySSL?: boolean
64-
}): Promise<Typeform.Webhook> {
65-
return createOrUpdateWebhook(this._http, args)
66-
}
56+
update(args: {
57+
uid: string
58+
tag: string
59+
url: string
60+
enabled?: boolean
61+
secret?: string
62+
verifySSL?: boolean
63+
}): Promise<Typeform.Webhook> {
64+
return createOrUpdateWebhook(this._http, args)
65+
}
6766
}
6867

6968
const createOrUpdateWebhook = (
70-
http: Typeform.HTTPClient,
71-
args: {
72-
uid: string
73-
tag: string
74-
url: string
75-
enabled?: boolean
76-
secret?: string
77-
verifySSL?: boolean
78-
}
69+
http: Typeform.HTTPClient,
70+
args: {
71+
uid: string
72+
tag: string
73+
url: string
74+
enabled?: boolean
75+
secret?: string
76+
verifySSL?: boolean
77+
}
7978
): Promise<Typeform.Webhook> => {
80-
const {uid, tag, url, enabled = false, secret, verifySSL} = args
79+
const { uid, tag, url, enabled = false, secret, verifySSL } = args
8180

82-
if (!url) {
83-
throw new Error(`Please provide a url for ${tag}`)
84-
}
81+
if (!url) {
82+
throw new Error(`Please provide an url for ${tag}`)
83+
}
8584

86-
if (!tag) {
87-
throw new Error(`Please provide a tag name for the webhook`)
88-
}
85+
if (!tag) {
86+
throw new Error(`Please provide a tag name for the webhook`)
87+
}
8988

90-
return http.request({
91-
method: 'put',
92-
url: `/forms/${uid}/webhooks/${tag}`,
93-
data: {
94-
url,
95-
enabled,
96-
secret,
97-
verify_ssl: verifySSL ? true : undefined,
98-
},
99-
})
89+
return http.request({
90+
method: 'put',
91+
url: `/forms/${uid}/webhooks/${tag}`,
92+
data: {
93+
url,
94+
enabled,
95+
secret,
96+
verify_ssl: verifySSL ? true : undefined,
97+
},
98+
})
10099
}

0 commit comments

Comments
 (0)