Skip to content

Commit

Permalink
[TU-13737] fix sonar-project paths p5
Browse files Browse the repository at this point in the history
  • Loading branch information
vrybas committed Jul 23, 2024
1 parent 983f6a3 commit 3ecb8c1
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 76 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ jobs:
- name: Verify coverage file download
run: find . | grep lcov.info

- name: Copy the coverage file to a proper location
run: |
mkdir -p coverage
mv lcov.info coverage/lcov.info
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@v2
with:
Expand Down
153 changes: 77 additions & 76 deletions src/images.ts
Original file line number Diff line number Diff line change
@@ -1,88 +1,89 @@
import { Typeform } from './typeform-types'
import {Typeform} from './typeform-types'

export class Images {
constructor(private _http: Typeform.HTTPClient) {}

public add(args: {
image?: string
url?: string
fileName: string
}): Promise<Typeform.Image> {
const { image, url, fileName } = args
constructor(private _http: Typeform.HTTPClient) {
}

return this._http.request({
method: 'post',
url: `/images`,
data: {
image,
file_name: fileName,
url,
},
})
}
public add(args: {
image?: string
url?: string
fileName: string
}): Promise<Typeform.Image> {
const {image, url, fileName} = args

public delete(args: { id: string }): Promise<null> {
const { id } = args
return this._http.request({
method: 'post',
url: `/images`,
data: {
image,
file_name: fileName,
url,
},
})
}

return this._http.request({
method: 'delete',
url: `/images/${id}`,
})
}
public delete(args: { id: string }): Promise<null> {
const {id} = args

public get(args: {
id: string
size?: string
backgroundSize?: string
choiceSize?: string
}): Promise<Typeform.Image> {
const { id, size, backgroundSize, choiceSize } = args
const requestQuery: Typeform.Request = {
method: 'get',
url: `/images/${id}`,
headers: {
Accept: 'application/json',
},
return this._http.request({
method: 'delete',
url: `/images/${id}`,
})
}

const choiceImageSizes = [
'default',
'thumbnail',
'supersize',
'supermobile',
'supersizefit',
'supermobilefit',
]
public get(args: {
id: string
size?: string
backgroundSize?: string
choiceSize?: string
}): Promise<Typeform.Image> {
const {id, size, backgroundSize, choiceSize} = args
const requestQuery: Typeform.Request = {
method: 'get',
url: `/images/${id}`,
headers: {
Accept: 'application/json',
},
}

if (size) {
if (['default', 'thumbnail', 'mobile'].includes(size)) {
requestQuery.url += `/image/${size}`
} else {
throw new Error(`Image size doesn't exist`)
}
} else if (backgroundSize) {
if (
['default', 'thumbnail', 'mobile', 'tablet'].includes(backgroundSize)
) {
requestQuery.url += `/background/${backgroundSize}`
} else {
throw new Error(`Image background size doesn't exist`)
}
} else if (choiceSize) {
if (choiceImageSizes.includes(choiceSize)) {
requestQuery.url += `/choice/${choiceSize}`
} else {
throw new Error(`Image choice size doesn't exist`)
}
}
const choiceImageSizes = [
'default',
'thumbnail',
'supersize',
'supermobile',
'supersizefit',
'supermobilefit',
]

return this._http.request(requestQuery)
}
if (size) {
if (['default', 'thumbnail', 'mobile'].includes(size)) {
requestQuery.url += `/image/${size}`
} else {
throw new Error(`Image size doesn't exist`)
}
} else if (backgroundSize) {
if (
['default', 'thumbnail', 'mobile', 'tablet'].includes(backgroundSize)
) {
requestQuery.url += `/background/${backgroundSize}`
} else {
throw new Error(`Image background size doesn't exist`)
}
} else if (choiceSize) {
if (choiceImageSizes.includes(choiceSize)) {
requestQuery.url += `/choice/${choiceSize}`
} else {
throw new Error(`Image choice size doesn't exist`)
}
}

public list(): Promise<Typeform.Image[]> {
return this._http.request({
method: 'get',
url: '/images',
})
}
return this._http.request(requestQuery)
}

public list(): Promise<Typeform.Image[]> {
return this._http.request({
method: 'get',
url: '/images',
})
}
}

0 comments on commit 3ecb8c1

Please sign in to comment.