Настроил использование внешнего апи.
проинтегрировал создание моков
This commit is contained in:
parent
5461b2241b
commit
47c51fb5fa
11
popup/src/api/Handlers/TokenRequestHandler.ts
Normal file
11
popup/src/api/Handlers/TokenRequestHandler.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { RequestHandler, RequestInterface } from '@/api/HttpClient'
|
||||||
|
|
||||||
|
export class TokenRequestHandler extends RequestHandler {
|
||||||
|
handle = (request: RequestInterface): void => {
|
||||||
|
request.headers = request.headers || {}
|
||||||
|
request.headers['x-token'] = 'GxwGRM'
|
||||||
|
console.log(request, 'DeviceIdHandler')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new TokenRequestHandler()
|
@ -43,9 +43,10 @@ export class HttpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
send (schema: SchemaInterface, data: any | null = null): Promise<AxiosResponse> {
|
send (schema: SchemaInterface, data: any | null = null): Promise<AxiosResponse> {
|
||||||
|
console.log(data, 'data')
|
||||||
const requestData = {
|
const requestData = {
|
||||||
method: schema.method as Method,
|
method: schema.method as Method,
|
||||||
url: schema.url,
|
url: this.baseUrl + schema.url,
|
||||||
data: data,
|
data: data,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json;charset=utf-8'
|
'Content-Type': 'application/json;charset=utf-8'
|
||||||
@ -65,7 +66,19 @@ export class HttpClient {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const stub = stubResolver.handle(schema.code)
|
const stub = stubResolver.handle(schema.code)
|
||||||
const response = stub || axios(requestData as AxiosRequestConfig)
|
const axiosData = requestData as AxiosRequestConfig
|
||||||
|
|
||||||
|
if (schema.prefix) {
|
||||||
|
const temp: any = {}
|
||||||
|
temp[schema.prefix] = axiosData.data
|
||||||
|
axiosData.data = temp
|
||||||
|
}
|
||||||
|
|
||||||
|
if (axiosData.method === 'GET') {
|
||||||
|
axiosData.params = axiosData.data
|
||||||
|
delete axiosData.data
|
||||||
|
}
|
||||||
|
const response = stub || axios(axiosData)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
.then((response: any) => {
|
.then((response: any) => {
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
import { HttpClient as BaseClient } from '../../api/HttpClient'
|
import { HttpClient as BaseClient } from '../../api/HttpClient'
|
||||||
import MocksSchema, { MockConfigurationsRequest } from '../../api/Main/Schemas/MocksSchema'
|
import MocksSchema, { MockConfigurationsRequest } from '../../api/Main/Schemas/MocksSchema'
|
||||||
import { SchemaInterface } from '@/api/SchemaInterface'
|
import { SchemaInterface } from '@/api/SchemaInterface'
|
||||||
|
import { TokenRequestHandler } from '@/api/Handlers/TokenRequestHandler'
|
||||||
|
import AddMockSchema, { AddMockConfigurationsRequest } from '@/api/Main/Schemas/AddMockSchema'
|
||||||
|
|
||||||
export class HttpClient extends BaseClient {
|
export class HttpClient extends BaseClient {
|
||||||
mockConfigurations (data: MockConfigurationsRequest): any {
|
mockConfigurations (data: MockConfigurationsRequest): any {
|
||||||
return this.send(MocksSchema as SchemaInterface, data)
|
return this.send(MocksSchema as SchemaInterface, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addMockConfigurations (data: AddMockConfigurationsRequest): any {
|
||||||
|
return this.send(AddMockSchema as SchemaInterface, data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new HttpClient('http://placetgroup.sipachev.sv')
|
export default new HttpClient('http://placetgroup.sipachev.sv')
|
||||||
|
.addHandler(new TokenRequestHandler())
|
||||||
|
17
popup/src/api/Main/Schemas/AddMockSchema.ts
Normal file
17
popup/src/api/Main/Schemas/AddMockSchema.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
export class MockConfiguration {
|
||||||
|
personalCode!: string
|
||||||
|
code!: string
|
||||||
|
value!: string
|
||||||
|
active!: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AddMockConfigurationsRequest {
|
||||||
|
items!: MockConfiguration[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
code: 'api_plugin_add_configurations',
|
||||||
|
method: 'POST',
|
||||||
|
url: '/plugin/mock-configurations',
|
||||||
|
prefix: 'mockConfigurations'
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
export class MockConfigurationsRequest {
|
export class MockConfigurationsRequest {
|
||||||
personalId!: string
|
personalCode!: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
code: 'api_plugin_get_configurations',
|
code: 'api_plugin_get_configurations',
|
||||||
method: 'POST',
|
method: 'GET',
|
||||||
url: '/plugin/mock-configurations'
|
url: '/plugin/mock-configurations'
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,5 @@ export interface SchemaInterface {
|
|||||||
method: string;
|
method: string;
|
||||||
url: string;
|
url: string;
|
||||||
stub: any;
|
stub: any;
|
||||||
|
prefix?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export class Registers {
|
export class Registers {
|
||||||
xteeMta = ''
|
xtee_mta = ''
|
||||||
xteePension = ''
|
xtee_pension = ''
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,5 @@ Vue.use(VueClipboard)
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class MocksTab extends Vue {
|
export default class MocksTab extends Vue {
|
||||||
personalId = ''
|
personalCode = ''
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<div>
|
<div>
|
||||||
<label>
|
<label>
|
||||||
Personal id
|
Personal id
|
||||||
<input type="text" v-model="personalId"/>
|
<input type="text" v-model="personalCode"/>
|
||||||
</label>
|
</label>
|
||||||
<div v-if="personalId">
|
<div v-if="personalCode">
|
||||||
<hr />
|
<hr />
|
||||||
<Mocks :personalId="personalId"></Mocks>
|
<Mocks :personalId="personalCode"></Mocks>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,13 +2,14 @@ import { Component, Prop, Vue } from 'vue-property-decorator'
|
|||||||
import VueClipboard from 'vue-clipboard2'
|
import VueClipboard from 'vue-clipboard2'
|
||||||
import { Registers } from '@/classes/DTO/Registers'
|
import { Registers } from '@/classes/DTO/Registers'
|
||||||
import httpClient from '@/api/Main/HttpClient'
|
import httpClient from '@/api/Main/HttpClient'
|
||||||
|
import { MockConfiguration } from '@/api/Main/Schemas/AddMockSchema'
|
||||||
|
|
||||||
Vue.use(VueClipboard)
|
Vue.use(VueClipboard)
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class Mocks extends Vue {
|
export default class Mocks extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
personalId!: string
|
personalCode!: string
|
||||||
|
|
||||||
registers = new Registers()
|
registers = new Registers()
|
||||||
|
|
||||||
@ -17,7 +18,20 @@ export default class Mocks extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveMocks () {
|
saveMocks () {
|
||||||
httpClient.mockConfigurations({ personalId: '48907031677' })
|
const mockConfigurations: MockConfiguration[] = []
|
||||||
|
for (const serviceCode in this.registers) {
|
||||||
|
const mockConfiguration = new MockConfiguration()
|
||||||
|
mockConfiguration.personalCode = this.personalCode
|
||||||
|
mockConfiguration.code = serviceCode
|
||||||
|
// @ts-ignore
|
||||||
|
mockConfiguration.value = this.registers[serviceCode]
|
||||||
|
if (!mockConfiguration.value) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
mockConfiguration.active = 'true'
|
||||||
|
mockConfigurations.push(mockConfiguration)
|
||||||
|
}
|
||||||
|
httpClient.addMockConfigurations({ items: mockConfigurations })
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
console.log('saveMocks')
|
console.log('saveMocks')
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<!-- 9 - выписка на хороший доход, в выписке есть выплаты, которые не учитываются в подсчёте среднего дохода-->
|
<!-- 9 - выписка на хороший доход, в выписке есть выплаты, которые не учитываются в подсчёте среднего дохода-->
|
||||||
<label>
|
<label>
|
||||||
XTEE MTA
|
XTEE MTA
|
||||||
<select class="option-select" v-model="registers.xteeMta">
|
<select class="option-select" v-model="registers.xtee_mta">
|
||||||
<option value="">-</option>
|
<option value="">-</option>
|
||||||
<option value="0">Не замокано (делать запрос)</option>
|
<option value="0">Не замокано (делать запрос)</option>
|
||||||
<option value="1">Выписка на хороший доход</option>
|
<option value="1">Выписка на хороший доход</option>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
<!-- <br /><br />-->
|
<!-- <br /><br />-->
|
||||||
<!-- <label>-->
|
<!-- <label>-->
|
||||||
<!-- XTEE Pension-->
|
<!-- XTEE Pension-->
|
||||||
<!-- <select class="option-select" v-model="registers.xteePension">-->
|
<!-- <select class="option-select" v-model="registers.xtee_pension">-->
|
||||||
<!-- <option value="">-</option>-->
|
<!-- <option value="">-</option>-->
|
||||||
<!-- <option value="0">Не замокано (делать запрос)</option>-->
|
<!-- <option value="0">Не замокано (делать запрос)</option>-->
|
||||||
<!-- <option value="2">Ошибка сервиса. (перезапросы)</option>-->
|
<!-- <option value="2">Ошибка сервиса. (перезапросы)</option>-->
|
||||||
|
@ -19,7 +19,7 @@ Vue.use(VueClipboard)
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class PersonTab extends Vue {
|
export default class PersonTab extends Vue {
|
||||||
personalId = ''
|
personalCode = ''
|
||||||
person = new Person()
|
person = new Person()
|
||||||
copyText = ''
|
copyText = ''
|
||||||
|
|
||||||
@ -40,21 +40,21 @@ export default class PersonTab extends Vue {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
copyPersonalId () {
|
copyPersonalCode () {
|
||||||
const personalId = personalIdGenerator.generate(this.person)
|
const personalCode = personalIdGenerator.generate(this.person)
|
||||||
this.personalId = personalId
|
this.personalCode = personalCode
|
||||||
this.copy(personalId)
|
this.copy(personalCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
copyIban () {
|
copyIban () {
|
||||||
const iban = ibanGenerator.generate(this.person.country)
|
const iban = ibanGenerator.generate(this.person.country)
|
||||||
this.personalId = ''
|
this.personalCode = ''
|
||||||
this.copy(iban)
|
this.copy(iban)
|
||||||
}
|
}
|
||||||
|
|
||||||
copyPhone () {
|
copyPhone () {
|
||||||
const phone = phoneGenerator.generate(this.person.country)
|
const phone = phoneGenerator.generate(this.person.country)
|
||||||
this.personalId = ''
|
this.personalCode = ''
|
||||||
this.copy(phone)
|
this.copy(phone)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,10 +64,10 @@ export default class PersonTab extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
autocomplete () {
|
autocomplete () {
|
||||||
const personalId = personalIdGenerator.generate(this.person)
|
const personalCode = personalIdGenerator.generate(this.person)
|
||||||
this.personalId = personalId
|
this.personalCode = personalCode
|
||||||
this.copy(personalId)
|
this.copy(personalCode)
|
||||||
this.insertValueToNode(Target.PERSONAL_ID, personalId)
|
this.insertValueToNode(Target.PERSONAL_ID, personalCode)
|
||||||
const iban = ibanGenerator.generate(this.person.country)
|
const iban = ibanGenerator.generate(this.person.country)
|
||||||
this.insertValueToNode(Target.IBAN, iban)
|
this.insertValueToNode(Target.IBAN, iban)
|
||||||
const phone = phoneGenerator.generate(this.person.country)
|
const phone = phoneGenerator.generate(this.person.country)
|
||||||
|
@ -42,9 +42,9 @@
|
|||||||
<button>Autocomplete</button>
|
<button>Autocomplete</button>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@click="copyPersonalId"
|
@click="copyPersonalCode"
|
||||||
class="form-row__item copy-button" data-clipboard-text="text2">
|
class="form-row__item copy-button" data-clipboard-text="text2">
|
||||||
<button>PersonalId</button>
|
<button>personalCode</button>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@click="copyIban"
|
@click="copyIban"
|
||||||
@ -58,8 +58,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="memory-panel">Memory: {{copyText}}</div>
|
<div class="memory-panel">Memory: {{copyText}}</div>
|
||||||
<div v-if="personalId">
|
<div v-if="personalCode">
|
||||||
<hr />
|
<hr />
|
||||||
<Mocks :personalId="personalId"></Mocks>
|
<Mocks :personalCode="personalCode"></Mocks>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { FlowEnum } from '@/stubs/FlowEnum'
|
import { FlowEnum } from '@/stubs/FlowEnum'
|
||||||
|
|
||||||
export const useStub = true
|
export const useStub = false
|
||||||
export const flow = FlowEnum.base
|
export const flow = FlowEnum.base
|
||||||
|
Loading…
Reference in New Issue
Block a user