-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds support for Web spotlight API endpoints (activate/deactiva…
…te/get status)
- Loading branch information
Showing
25 changed files
with
407 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SharedContracts } from './shared-contracts'; | ||
|
||
export namespace WebSpotlightContracts { | ||
export interface IWebSpotlightStatus { | ||
enabled: boolean; | ||
root_type: SharedContracts.IIdReferenceContract | null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { IResponse } from '@kontent-ai/core-sdk'; | ||
|
||
import { WebSpotlightContracts } from '../contracts'; | ||
import { BaseMapper } from './base-mapper'; | ||
import { WebSpotlightResponses } from '../responses'; | ||
import { WebSpotlightModels } from '../models'; | ||
|
||
export class WebSpotlightMapper extends BaseMapper { | ||
mapWebSpotlightStatusResponse( | ||
response: IResponse<WebSpotlightContracts.IWebSpotlightStatus> | ||
): WebSpotlightResponses.WebSpotlightStatusResponse { | ||
return new WebSpotlightResponses.WebSpotlightStatusResponse( | ||
super.mapResponseDebug(response), | ||
response.data, | ||
this.mapWebSpotlightStatus(response.data) | ||
); | ||
} | ||
|
||
private mapWebSpotlightStatus( | ||
rawData: WebSpotlightContracts.IWebSpotlightStatus | ||
): WebSpotlightModels.WebSpotlightStatus { | ||
return new WebSpotlightModels.WebSpotlightStatus({ | ||
_raw: rawData, | ||
enabled: rawData.enabled, | ||
rootType: rawData.root_type ? this.mapIdReference(rawData.root_type) : undefined | ||
}); | ||
} | ||
} | ||
|
||
export const webSpotlightMapper = new WebSpotlightMapper(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { SharedModels } from '../shared/shared-models'; | ||
import { SharedContracts, WebSpotlightContracts } from '../../contracts'; | ||
|
||
export namespace WebSpotlightModels { | ||
export class WebSpotlightStatus implements SharedModels.IBaseModel<WebSpotlightContracts.IWebSpotlightStatus> { | ||
public enabled: boolean; | ||
public rootType?: SharedModels.IIdRefenceObject; | ||
public _raw: WebSpotlightContracts.IWebSpotlightStatus; | ||
|
||
constructor(data: { | ||
enabled: boolean; | ||
rootType?: SharedModels.IIdRefenceObject; | ||
_raw: WebSpotlightContracts.IWebSpotlightStatus; | ||
}) { | ||
this.enabled = data.enabled; | ||
this.rootType = data.rootType; | ||
this._raw = data._raw; | ||
} | ||
} | ||
|
||
export interface IActivateWebSpotlightData { | ||
root_type: SharedContracts.IReferenceObjectContract | null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
lib/queries/web-spotlight/activate-web-spotlight-query.class.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { WebSpotlightResponses } from '../../responses'; | ||
import { IManagementClientConfig } from '../../config'; | ||
import { ManagementQueryService } from '../../services'; | ||
import { BaseQuery } from '../base-query'; | ||
import { WebSpotlightModels } from '../../models'; | ||
|
||
export class ActivateWebSpotlightQuery extends BaseQuery<WebSpotlightResponses.WebSpotlightStatusResponse> { | ||
constructor( | ||
protected config: IManagementClientConfig, | ||
protected queryService: ManagementQueryService, | ||
public data: WebSpotlightModels.IActivateWebSpotlightData | ||
) { | ||
super(config, queryService); | ||
} | ||
|
||
toPromise(): Promise<WebSpotlightResponses.WebSpotlightStatusResponse> { | ||
return this.queryService.activateWebSpotlightAsync(this.getUrl(), this.queryConfig, this.data); | ||
} | ||
|
||
protected getAction(): string { | ||
return this.apiEndpoints.activateWebSpotlight(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
lib/queries/web-spotlight/check-web-spotlight-status-query.class.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { WebSpotlightResponses } from '../../responses'; | ||
import { IManagementClientConfig } from '../../config'; | ||
import { ManagementQueryService } from '../../services'; | ||
import { BaseQuery } from '../base-query'; | ||
|
||
export class CheckWebSpotlightStatusQuery extends BaseQuery<WebSpotlightResponses.WebSpotlightStatusResponse> { | ||
constructor(protected config: IManagementClientConfig, protected queryService: ManagementQueryService) { | ||
super(config, queryService); | ||
} | ||
|
||
toPromise(): Promise<WebSpotlightResponses.WebSpotlightStatusResponse> { | ||
return this.queryService.checkWebSpotlightStatusAsync(this.getUrl(), this.queryConfig); | ||
} | ||
|
||
protected getAction(): string { | ||
return this.apiEndpoints.checkWebSpotlightStatus(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
lib/queries/web-spotlight/deactivate-web-spotlight-query.class.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { WebSpotlightResponses } from '../../responses'; | ||
import { IManagementClientConfig } from '../../config'; | ||
import { ManagementQueryService } from '../../services'; | ||
import { BaseQuery } from '../base-query'; | ||
|
||
export class DeactivateWebSpotlightQuery extends BaseQuery<WebSpotlightResponses.WebSpotlightStatusResponse> { | ||
constructor(protected config: IManagementClientConfig, protected queryService: ManagementQueryService) { | ||
super(config, queryService); | ||
} | ||
|
||
toPromise(): Promise<WebSpotlightResponses.WebSpotlightStatusResponse> { | ||
return this.queryService.deactivateWebSpotlightAsync(this.getUrl(), this.queryConfig); | ||
} | ||
|
||
protected getAction(): string { | ||
return this.apiEndpoints.deactivateWebSpotlight(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './activate-web-spotlight-query.class'; | ||
export * from './deactivate-web-spotlight-query.class'; | ||
export * from './check-web-spotlight-status-query.class'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { WebSpotlightContracts } from '../../contracts'; | ||
import { WebSpotlightModels } from '../../models'; | ||
import { BaseResponses } from '../base-responses'; | ||
|
||
export namespace WebSpotlightResponses { | ||
export class WebSpotlightStatusResponse extends BaseResponses.BaseContentManagementResponse< | ||
WebSpotlightContracts.IWebSpotlightStatus, | ||
WebSpotlightModels.WebSpotlightStatus | ||
> { | ||
constructor( | ||
debug: BaseResponses.IContentManagementResponseDebug, | ||
rawData: WebSpotlightContracts.IWebSpotlightStatus, | ||
data: WebSpotlightModels.WebSpotlightStatus | ||
) { | ||
super(debug, rawData, data); | ||
} | ||
} | ||
} |
Oops, something went wrong.