Skip to content

Commit 3ecb8c1

Browse files
committed
[TU-13737] fix sonar-project paths p5
1 parent 983f6a3 commit 3ecb8c1

File tree

2 files changed

+82
-76
lines changed

2 files changed

+82
-76
lines changed

.github/workflows/pr.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ jobs:
8282
- name: Verify coverage file download
8383
run: find . | grep lcov.info
8484

85+
- name: Copy the coverage file to a proper location
86+
run: |
87+
mkdir -p coverage
88+
mv lcov.info coverage/lcov.info
89+
8590
- name: SonarCloud Scan
8691
uses: SonarSource/sonarcloud-github-action@v2
8792
with:

src/images.ts

Lines changed: 77 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,89 @@
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-
public add(args: {
7-
image?: string
8-
url?: string
9-
fileName: string
10-
}): Promise<Typeform.Image> {
11-
const { image, url, fileName } = args
4+
constructor(private _http: Typeform.HTTPClient) {
5+
}
126

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

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

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

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-
},
28+
return this._http.request({
29+
method: 'delete',
30+
url: `/images/${id}`,
31+
})
4632
}
4733

48-
const choiceImageSizes = [
49-
'default',
50-
'thumbnail',
51-
'supersize',
52-
'supermobile',
53-
'supersizefit',
54-
'supermobilefit',
55-
]
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+
}
5648

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-
}
77-
}
49+
const choiceImageSizes = [
50+
'default',
51+
'thumbnail',
52+
'supersize',
53+
'supermobile',
54+
'supersizefit',
55+
'supermobilefit',
56+
]
7857

79-
return this._http.request(requestQuery)
80-
}
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+
}
8179

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

0 commit comments

Comments
 (0)