本文整理汇总了TypeScript中integration-test/helpers/clients/base/request.request函数的典型用法代码示例。如果您正苦于以下问题:TypeScript request函数的具体用法?TypeScript request怎么用?TypeScript request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了request函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getPin
static getPin (letterHolderId: string): Promise<string> {
const options = {
uri: `${baseURL}/testing-support/accounts/pin/${letterHolderId}`,
resolveWithFullResponse: true,
rejectUnauthorized: false,
json: false
}
return request(options).then(function (response) {
return response.body
})
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:11,代码来源:idamClient.ts
示例2: retrieveUser
/**
* Retrieves uses details
*
* @param {string} jwt
* @returns {Promise<User>}
*/
static retrieveUser (jwt: string): Promise<User> {
const options = {
uri: `${baseURL}/details`,
headers: {
Authorization: `Bearer ${jwt}`
}
}
return request(options).then(function (response) {
return response
})
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:17,代码来源:idamClient.ts
示例3: addRoleToUser
static addRoleToUser (bearerToken: string, role: string): Promise<void> {
if (!bearerToken) {
return Promise.reject(new Error('bearerToken is required'))
}
const options = {
method: 'POST',
uri: `${baseURL}/user/roles`,
body: { role: role },
headers: {
Authorization: `Bearer ${bearerToken}`
}
}
return request(options).then()
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:15,代码来源:claimStoreClient.ts
示例4: exchangeCode
static exchangeCode (code: string): Promise<string> {
const options = {
method: 'POST',
uri: `${baseURL}/oauth2/token`,
auth: {
username: oauth2.client_id,
password: oauth2.client_secret
},
form: { grant_type: 'authorization_code', code: code, redirect_uri: oauth2.redirect_uri }
}
return request(options).then(function (response) {
return response['access_token']
})
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:16,代码来源:idamClient.ts
示例5: linkDefendant
/**
* Links defendant to claim in the claim store
*
* @param {string} defendant - defendant ID
* @returns {Promise<Claim>}
*/
static linkDefendant (defendant: User): Promise<Claim> {
if (!defendant) {
return Promise.reject('Defendant is required')
}
const options = {
method: 'PUT',
uri: `${baseURL}/claims/defendant/link`,
headers: {
Authorization: `Bearer ${defendant.bearerToken}`
}
}
return request(options).then(function (response) {
return response
})
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:23,代码来源:claimStoreClient.ts
示例6: retrieveByReferenceNumber
/**
* Retrieves claim from the claim store by claim reference number
*
* @param {string} referenceNumber - claim reference number
* @param {User} owner - claim owner
* @returns {Promise<Claim>}
*/
static retrieveByReferenceNumber (referenceNumber: string, owner: User): Promise<Claim> {
if (!referenceNumber) {
return Promise.reject('Claim reference number is required')
}
if (!owner) {
return Promise.reject('Claim owner is required')
}
const options = {
uri: `${baseURL}/claims/${referenceNumber}`,
headers: {
Authorization: `Bearer ${owner.bearerToken}`
}
}
return request(options).then(function (response) {
return response
})
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:25,代码来源:claimStoreClient.ts
示例7: authenticateUser
/**
* Authenticate user
*
* @param {string} username the username to authenticate
* @param password the users password (optional, default will be used if none provided)
* @returns {Promise<string>} the users access token
*/
static async authenticateUser (username: string, password: string = undefined): Promise<string> {
const base64Authorisation: string = IdamClient.toBase64(`${username}:${password || defaultPassword}`)
const oauth2Params: string = IdamClient.toUrlParams(oauth2)
const options = {
method: 'POST',
uri: `${baseURL}/oauth2/authorize?response_type=code&${oauth2Params}`,
headers: {
Authorization: `Basic ${base64Authorisation}`,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
return request(options).then(function (response) {
return response.code
}).then(function (response) {
return IdamClient.exchangeCode(response).then(function (response) {
return response
})
})
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:27,代码来源:idamClient.ts
示例8: createUser
/**
* Creates user with default password
*
* @param {string} email
* @param {string} userGroupCode
* @param password the user's password, will use a default if undefined
* @returns {Promise<void>}
*/
static createUser (email: string, userGroupCode: string, password: string = undefined): Promise<void> {
const options = {
method: 'POST',
uri: `${baseURL}/testing-support/accounts`,
body: {
email: email,
forename: 'John',
surname: 'Smith',
levelOfAccess: 0,
userGroup: {
code: userGroupCode
},
activationDate: '',
lastAccess: '',
password: password ? password : defaultPassword
}
}
return request(options).then(function () {
return Promise.resolve()
})
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:29,代码来源:idamClient.ts
示例9: authenticatePinUser
/**
* Authorizes pin user
*
* @param {string} pin
* @returns {Promise<string>} bearer token
*/
static async authenticatePinUser (pin: string): Promise<string> {
const oauth2Params: string = IdamClient.toUrlParams(oauth2)
const options = {
uri: `${baseURL}/pin?${oauth2Params}`,
headers: {
pin,
'Content-Type': 'application/x-www-form-urlencoded'
},
simple: false,
followRedirect: false,
json: false,
resolveWithFullResponse: true
}
return request(options).then(function (response) {
return response
}).then(function (response) {
const code: any = url.parse(response.headers.location, true).query.code
return IdamClient.exchangeCode(code).then(function (response) {
return response
})
})
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:28,代码来源:idamClient.ts
示例10: respond
/**
* Saves response to a claim identified by the ID in the claim store
*
* @param {number} externalId - claim external ID
* @param {any} responseData - response data
* @param {User} defendant - user that makes response
* @returns {Promise<Claim>}
*/
static respond (externalId: string, responseData: ResponseData, defendant: User): Promise<Claim> {
if (!externalId) {
return Promise.reject('Claim ID is required')
}
if (!responseData) {
return Promise.reject('Response data is required')
}
if (!defendant) {
return Promise.reject('Defendant is required')
}
const options = {
method: 'POST',
uri: `${baseURL}/responses/claim/${externalId}/defendant/${defendant.id}`,
body: responseData,
headers: {
Authorization: `Bearer ${defendant.bearerToken}`
}
}
return request(options).then(function (response) {
return response
})
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:32,代码来源:claimStoreClient.ts
注:本文中的integration-test/helpers/clients/base/request.request函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论