1- import _ from 'lodash'
21import { axiosInstance as axios } from './requestInterceptor'
32import { PROJECTS_API_URL , FILE_PICKER_SUBMISSION_CONTAINER_NAME } from '../config/constants'
43
54export function addProjectAttachment ( projectId , fileData ) {
65 // add s3 bucket prop
76 fileData . s3Bucket = FILE_PICKER_SUBMISSION_CONTAINER_NAME
8- return axios . post ( `${ PROJECTS_API_URL } /v4 /projects/${ projectId } /attachments` , { param : fileData } )
7+ return axios . post ( `${ PROJECTS_API_URL } /v5 /projects/${ projectId } /attachments` , fileData )
98 . then ( resp => {
10- resp . data . result . content . downloadUrl = `/projects/${ projectId } /attachments/${ resp . data . result . content . id } `
11- return _ . get ( resp . data , 'result.content' , { } )
9+ resp . data . downloadUrl = `/projects/${ projectId } /attachments/${ resp . data . id } `
10+ return resp . data
1211 } )
1312}
1413
@@ -19,56 +18,54 @@ export function updateProjectAttachment(projectId, attachmentId, attachment) {
1918 allowedUsers : null
2019 }
2120 }
22-
21+
2322 return axios . patch (
24- `${ PROJECTS_API_URL } /v4/projects/${ projectId } /attachments/${ attachmentId } ` ,
25- { param : attachment } )
23+ `${ PROJECTS_API_URL } /v5/projects/${ projectId } /attachments/${ attachmentId } ` , attachment )
2624 . then ( resp => {
27- resp . data . result . content . downloadUrl = `/projects/${ projectId } /attachments/${ attachmentId } `
28- return _ . get ( resp . data , 'result.content' , { } )
25+ resp . data . downloadUrl = `/projects/${ projectId } /attachments/${ attachmentId } `
26+ return resp . data
2927 } )
3028}
3129
3230export function removeProjectAttachment ( projectId , attachmentId ) {
3331 // return attachmentId so reducer knows which one to remove from list
34- return axios . delete ( `${ PROJECTS_API_URL } /v4 /projects/${ projectId } /attachments/${ attachmentId } ` )
32+ return axios . delete ( `${ PROJECTS_API_URL } /v5 /projects/${ projectId } /attachments/${ attachmentId } ` )
3533 . then ( ( ) => attachmentId )
3634}
3735
3836export function getProjectAttachment ( projectId , attachmentId ) {
3937 return axios . get (
40- `${ PROJECTS_API_URL } /v4 /projects/${ projectId } /attachments/${ attachmentId } ` )
41- . then ( resp => resp . data . result . content . url )
38+ `${ PROJECTS_API_URL } /v5 /projects/${ projectId } /attachments/${ attachmentId } ` )
39+ . then ( resp => resp . data . url )
4240}
4341
4442export function addProductAttachment ( projectId , phaseId , productId , fileData ) {
4543 // add s3 bucket prop
4644 fileData . s3Bucket = FILE_PICKER_SUBMISSION_CONTAINER_NAME
47- return axios . post ( `${ PROJECTS_API_URL } /v4 /projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments` , { param : fileData } )
45+ return axios . post ( `${ PROJECTS_API_URL } /v5 /projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments` , fileData )
4846 . then ( resp => {
49- resp . data . result . content . downloadUrl = `/projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments/${ resp . data . result . content . id } `
50- return _ . get ( resp . data , 'result.content' , { } )
47+ resp . data . downloadUrl = `/projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments/${ resp . data . id } `
48+ return resp . data
5149 } )
5250}
5351
5452export function updateProductAttachment ( projectId , phaseId , productId , attachmentId , attachment ) {
5553 return axios . patch (
56- `${ PROJECTS_API_URL } /v4/projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments/${ attachmentId } ` ,
57- { param : attachment } )
54+ `${ PROJECTS_API_URL } /v5/projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments/${ attachmentId } ` , attachment )
5855 . then ( resp => {
59- resp . data . result . content . downloadUrl = `/projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments/${ attachmentId } `
60- return _ . get ( resp . data , 'result.content' , { } )
56+ resp . data . downloadUrl = `/projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments/${ attachmentId } `
57+ return resp . data
6158 } )
6259}
6360
6461export function removeProductAttachment ( projectId , phaseId , productId , attachmentId ) {
6562 // return attachmentId so reducer knows which one to remove from list
66- return axios . delete ( `${ PROJECTS_API_URL } /v4 /projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments/${ attachmentId } ` )
63+ return axios . delete ( `${ PROJECTS_API_URL } /v5 /projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments/${ attachmentId } ` )
6764 . then ( ( ) => attachmentId )
6865}
6966
7067export function getProductAttachment ( projectId , phaseId , productId , attachmentId ) {
7168 return axios . get (
72- `${ PROJECTS_API_URL } /v4 /projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments/${ attachmentId } ` )
73- . then ( resp => resp . data . result . content . url )
69+ `${ PROJECTS_API_URL } /v5 /projects/${ projectId } /phases/${ phaseId } /products/${ productId } /attachments/${ attachmentId } ` )
70+ . then ( resp => resp . data . url )
7471}
0 commit comments