11import { handleFeedResponse } from '../../helpers/feed' ;
22import { compactDefined } from '../../helpers/fp' ;
33import * as Query from '../../helpers/query' ;
4- import { createRequestHandler } from '../../helpers/request' ;
4+ import { createRequestHandler , makeEndpoint } from '../../helpers/request' ;
55import { castResponse } from '../../helpers/response' ;
66import { OrientationParam , PaginationParams } from '../../types/request' ;
77
@@ -14,7 +14,7 @@ const COLLECTIONS_PATH_PREFIX = '/collections';
1414export const getPhotos = ( ( ) => {
1515 const getPathname = ( { collectionId } : CollectionId ) =>
1616 `${ COLLECTIONS_PATH_PREFIX } /${ collectionId } /photos` ;
17- return {
17+ return makeEndpoint ( {
1818 getPathname,
1919 handleRequest : createRequestHandler (
2020 ( {
@@ -27,25 +27,25 @@ export const getPhotos = (() => {
2727 } ) ,
2828 ) ,
2929 handleResponse : handleFeedResponse < any > ( ) ,
30- } ;
30+ } ) ;
3131} ) ( ) ;
3232
3333export const get = ( ( ) => {
3434 const getPathname = ( { collectionId } : CollectionId ) =>
3535 `${ COLLECTIONS_PATH_PREFIX } /${ collectionId } ` ;
36- return {
36+ return makeEndpoint ( {
3737 getPathname,
3838 handleRequest : createRequestHandler ( ( { collectionId } : CollectionId ) => ( {
3939 pathname : getPathname ( { collectionId } ) ,
4040 query : { } ,
4141 } ) ) ,
4242 handleResponse : castResponse < any > ( ) ,
43- } ;
43+ } ) ;
4444} ) ( ) ;
4545
4646export const list = ( ( ) => {
4747 const getPathname = ( ) => COLLECTIONS_PATH_PREFIX ;
48- return {
48+ return makeEndpoint ( {
4949 getPathname,
5050 handleRequest : createRequestHandler (
5151 ( paginationParams : Pick < PaginationParams , 'page' | 'perPage' > = { } ) => ( {
@@ -54,18 +54,18 @@ export const list = (() => {
5454 } ) ,
5555 ) ,
5656 handleResponse : handleFeedResponse < any > ( ) ,
57- } ;
57+ } ) ;
5858} ) ( ) ;
5959
6060export const getRelated = ( ( ) => {
6161 const getPathname = ( { collectionId } : CollectionId ) =>
6262 `${ COLLECTIONS_PATH_PREFIX } /${ collectionId } /related` ;
63- return {
63+ return makeEndpoint ( {
6464 getPathname,
6565 handleRequest : createRequestHandler ( ( { collectionId } : CollectionId ) => ( {
6666 pathname : getPathname ( { collectionId } ) ,
6767 query : { } ,
6868 } ) ) ,
6969 handleResponse : castResponse < any > ( ) ,
70- } ;
70+ } ) ;
7171} ) ( ) ;
0 commit comments