Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Add Plus search param #202

Merged
merged 2 commits into from
May 8, 2023
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
3 changes: 2 additions & 1 deletion src/methods/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { compactDefined } from '../../helpers/fp';
import * as Query from '../../helpers/query';
import { createRequestHandler, makeEndpoint } from '../../helpers/request';
import { castResponse } from '../../helpers/response';
import { OrientationParam, PaginationParams } from '../../types/request';
import { OrientationParam, PaginationParams, Plus } from '../../types/request';
import { ColorId, ContentFilter, Language, SearchOrderBy } from './types/request';
import * as SearchResponse from './types/response';

Expand All @@ -19,6 +19,7 @@ type SearchPhotosParams = SearchParams &
*/
orderBy?: SearchOrderBy;
color?: ColorId;
plus?: Plus;
/**
* API defaults to `en` (English) if no value is provided
*/
Expand Down
1 change: 1 addition & 0 deletions src/types/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type Orientation = 'landscape' | 'portrait' | 'squarish';
export type OrientationParam = {
orientation?: Orientation;
};
export type Plus = 'mixed' | 'only' | 'none';
Copy link

@astlouisf astlouisf May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a mixed variant? If we look at the Orientation filter the mixed variant is implied by the absence of the orientation value. Shouldn't we mirror this "convention" for the Plus param?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I think we should keep mixed here because it matches API's behaviour as in mixed or undefined equals mixed. Orientation doesn't have any value encapsulating all orientations so we have to use undefined. I think it's a difference in design

Copy link

@astlouisf astlouisf May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense that we want to mirror API. Should this be raised to API to ensure a more consistent api before making it widely available?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the relevant slack thread: https://crewlabs.slack.com/archives/C4LRBSTG9/p1683568502846389 — I think third party apps already use the plus query params (we can track this because it needs special permissions) so any changes would be a breaking change.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! So the plus parameter was already available when you added the filter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're talking about unsplash.com filter, then it was about during the same time.


export type PaginationParams = {
/**
Expand Down