Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Fix API endpoints for related media and provider stats #509

Merged
merged 3 commits into from
Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions src/data/api-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,59 @@ export const createApiService = (baseUrl = process.env.apiUrl) => {
)

return {
/**
* @param {string} resource The endpoint of the resource
* @param {import('axios').AxiosRequestConfig} params Url parameter object
* @returns {Promise<import('axios').AxiosResponse<any>>} response The API response object
*/
query(resource, params) {
return client.get(resource, { params })
},

/**
* @param {string} resource The endpoint of the resource
* @param {string} slug The sub-endpoint of the resource
* @returns {Promise<import('axios').AxiosResponse<any>>} Response The API response object
*/
get(resource, slug) {
return client.get(`${resource}/${slug}`)
},

/**
* @param {string} resource The endpoint of the resource
* @param {import('axios').AxiosRequestConfig} params Url parameter object
* @returns {Promise<import('axios').AxiosResponse<any>>} Response The API response object
*/
post(resource, params) {
return client.post(`${resource}`, params)
return client.post(resource, params)
},

/**
* @param {string} resource The endpoint of the resource
* @param {string} slug The sub-endpoint of the resource
* @param {import('axios').AxiosRequestConfig} params Url parameter object
* @param {import('axios').AxiosRequestConfig['headers']} headers Headers object
* @returns {Promise<import('axios').AxiosResponse<any>>} Response The API response object
*/
update(resource, slug, params, headers) {
return client.put(`${resource}/${slug}`, params, { headers })
},

/**
* @param {string} resource The endpoint of the resource
* @param {import('axios').AxiosRequestConfig} params Url parameter object
* @returns {Promise<import('axios').AxiosResponse<any>>} Response The API response object
*/
put(resource, params) {
return client.put(`${resource}`, params)
return client.put(resource, params)
},

/**
* @param {string} resource The endpoint of the resource
* @param {string} slug The sub-endpoint of the resource
* @param {import('axios').AxiosRequestConfig['headers']} headers Headers object
* @returns {Promise<import('axios').AxiosResponse<any>>} Response The API response object
*/
delete(resource, slug, headers) {
return client.delete(`${resource}/${slug}`, { headers })
},
Expand Down
13 changes: 5 additions & 8 deletions src/data/audio-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ const AudioService = {
const data = JSON.parse(JSON.stringify(sampleAudioResponses.search))
return Promise.resolve({ data })
}
return ApiService.query('audios', params)
},

getProviderCollection(params) {
return ApiService.query('audios', params)
return ApiService.query('audio', params)
},

/**
Expand All @@ -43,12 +39,12 @@ const AudioService = {

return config.dev
? Promise.resolve({ data: sampleAudioResponses.detail })
: ApiService.get('audios', params.id)
: ApiService.get('audio', params.id)
},

/**
* Retrieve related media
* @param params
* @param {object} params
* @param {string} params.id
* @return {Promise<{data: any}>}
*/
Expand All @@ -58,9 +54,10 @@ const AudioService = {
'[RWV] AudioService.getRelatedMedia() id parameter required to retrieve related audios.'
)
}

return config.dev
? Promise.resolve({ data: sampleAudioResponses.related })
: ApiService.get('recommendations/audios', params.id)
: ApiService.get('audio', `${params.id}/related`)
},
}

Expand Down
30 changes: 0 additions & 30 deletions src/data/existing-audio-providers.js

This file was deleted.

Loading