Skip to content

Commit

Permalink
make value generic and create fieldType enum for FieldValueDirectAnswer
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannzhou committed Aug 10, 2022
1 parent 1e9084a commit 4d3e77e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/models/searchservice/response/DirectAnswer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DirectAnswerType } from './DirectAnswerType';
*
* @public
*/
export interface DirectAnswer {
export interface DirectAnswer<T = unknown> {
/** The {@link DirectAnswerType}. */
type: DirectAnswerType,
/**
Expand All @@ -15,7 +15,7 @@ export interface DirectAnswer {
* @remarks
* A value will not be present if the {@link DirectAnswer.fieldType} is 'rich_text'.
*/
value?: string,
value?: T,
/** The entity associated with the direct answer. */
relatedResult: Result,
/** The vertical key of the direct answer. */
Expand Down
22 changes: 22 additions & 0 deletions src/models/searchservice/response/DirectAnswerFieldType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Type for value of DirectAnswer.
*
* @public
*/
export enum DirectAnswerFieldType {
Url = 'url',
ComplexUrl = 'complex_url',
IOSAppUrl = 'ios_app_url',
AndroidAppUrl = 'android_app_url',
FacebookUrl = 'facebook_url',
Email = 'email',
InstagramHandle = 'instagram_handle',
TwitterHandle = 'twitter_handle',
Phone = 'phone',
Address = 'address',
Hours = 'hours',
Decimal = 'decimal',
RichText = 'rich_text',
SingleLineText = 'single_line_text',
MultiLineText = 'multi_line_text'
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Snippet } from './Snippet';
*
* @public
*/
export interface FeaturedSnippetDirectAnswer extends DirectAnswer {
export interface FeaturedSnippetDirectAnswer extends DirectAnswer<string> {
/** {@link DirectAnswerType}.FeaturedSnippet. */
type: DirectAnswerType.FeaturedSnippet,
/** {@inheritDoc DirectAnswer.value} */
Expand Down
4 changes: 2 additions & 2 deletions src/models/searchservice/response/FieldValueDirectAnswer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { Result } from './Result';
*
* @public
*/
export interface FieldValueDirectAnswer extends DirectAnswer {
export interface FieldValueDirectAnswer<T = unknown> extends DirectAnswer<T> {
/** {@link DirectAnswerType}.FieldValue. */
type: DirectAnswerType.FieldValue,
/** {@inheritDoc DirectAnswer.value} */
value: string,
value: T,
/** {@inheritDoc DirectAnswer.relatedResult} */
relatedResult: Result,
/** {@inheritDoc DirectAnswer.verticalKey} */
Expand Down

0 comments on commit 4d3e77e

Please sign in to comment.