import * as playwright from "playwright" ; import { RethrownError } from "../utils/RethrownError" ; import { EnsureXrmGetter } from "./Global" ; import { XrmUiTest } from "./XrmUITest" ; /**
 * Module for interacting with D365 Web API
 */ export class WebApi { private _page : playwright . Page ; constructor ( private xrmUiTest ) { this . _page = xrmUiTest . page ; this . xrmUiTest = xrmUiTest ; } param entityLogicalName param data returns createRecord = async ( entityLogicalName , data ) : Promise < Xrm . CreateResponse > => { await EnsureXrmGetter ( this . _page ) ; return this . _page . evaluate ( ( [ entityLogicalName , data ] ) => { const xrm = window . oss_FindXrm ( ) ; return xrm . WebApi . createRecord ( entityLogicalName , data ) ; } , [ entityLogicalName , data ] ) ; } ; param entityLogicalName param id param options returns retrieveRecord = async ( entityLogicalName , id , options ? ) : Promise < any > => { await EnsureXrmGetter ( this . _page ) ; return this . _page . evaluate ( ( [ entityLogicalName , id , options ] ) => { const xrm = window . oss_FindXrm ( ) ; return xrm . WebApi . retrieveRecord ( entityLogicalName , id , options ) ; } , [ entityLogicalName , id , options ] ) ; } ; param entityLogicalName param options param maxPageSize returns retrieveMultipleRecords = async ( entityLogicalName , options ? , maxPageSize ? ) : Promise < Xrm . RetrieveMultipleResult > => { await EnsureXrmGetter ( this . _page ) ; return this . _page . evaluate ( ( [ entityLogicalName , options , maxPageSize ] ) => { const xrm = window . oss_FindXrm ( ) ; return xrm . WebApi . retrieveMultipleRecords ( entityLogicalName , options , maxPageSize ) ; } , [ entityLogicalName , options , maxPageSize ] as [ string , string ? , number ? ] ) ; } ; param entityLogicalName param id param data returns updateRecord = async ( entityLogicalName , id , data ) : Promise < any > => { await EnsureXrmGetter ( this . _page ) ; return this . _page . evaluate ( ( [ entityLogicalName , id , data ] ) => { const xrm = window . oss_FindXrm ( ) ; return xrm . WebApi . updateRecord ( entityLogicalName , id , data ) ; } , [ entityLogicalName , id , data ] ) ; } ; param entityLogicalName param id returns deleteRecord = async ( entityLogicalName , id ) : Promise < any > => { await EnsureXrmGetter ( this . _page ) ; return this . _page . evaluate ( ( [ entityLogicalName , id ] ) => { const xrm = window . oss_FindXrm ( ) ; return xrm . WebApi . deleteRecord ( entityLogicalName , id ) ; } , [ entityLogicalName , id ] ) ; } ; }