parent
8ca151574a
commit
b92b1e73ce
@ -1,7 +1,9 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { MessageService } from 'primeng/api';
|
import { MessageService } from 'primeng/api';
|
||||||
|
import { lastValueFrom } from 'rxjs';
|
||||||
import { UserDataForm } from 'src/app/interface/data';
|
import { UserDataForm } from 'src/app/interface/data';
|
||||||
|
import { AppleWalletService } from 'src/app/services/apple-wallet.service';
|
||||||
import { JsonrpcService, RpcService } from 'src/app/services/jsonrpc.service';
|
import { JsonrpcService, RpcService } from 'src/app/services/jsonrpc.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -21,6 +23,8 @@ export class UserDataComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private jsonRpcService: JsonrpcService,
|
private jsonRpcService: JsonrpcService,
|
||||||
private messageService: MessageService,
|
private messageService: MessageService,
|
||||||
|
private appleWallet: AppleWalletService,
|
||||||
|
private jsonrpc: JsonrpcService,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -59,8 +63,29 @@ export class UserDataComponent implements OnInit {
|
|||||||
method: 'updateAdditionalInfo',
|
method: 'updateAdditionalInfo',
|
||||||
params: [this.userData]
|
params: [this.userData]
|
||||||
}, RpcService.authService, true).subscribe({
|
}, RpcService.authService, true).subscribe({
|
||||||
next: () => {
|
next: async () => {
|
||||||
this.messageService.add({severity:'custom', summary:'Данные успешно обновлены!'});
|
this.messageService.add({severity:'custom', summary:'Данные успешно обновлены!'});
|
||||||
|
const accountData = (await lastValueFrom(
|
||||||
|
this.jsonrpc
|
||||||
|
.rpc(
|
||||||
|
{
|
||||||
|
method: 'getTokenData',
|
||||||
|
params: [],
|
||||||
|
},
|
||||||
|
RpcService.authService,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
)).data
|
||||||
|
if (accountData.user_id) {
|
||||||
|
this.appleWallet.reloadCard(accountData.user_id).subscribe({
|
||||||
|
next: (value) => {
|
||||||
|
console.log(value);
|
||||||
|
},
|
||||||
|
error: (err) => {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: (err) => {
|
error: (err) => {
|
||||||
console.error('Error: ', err)
|
console.error('Error: ', err)
|
||||||
|
|||||||
@ -19,4 +19,17 @@ export class AppleWalletService {
|
|||||||
};
|
};
|
||||||
return this.http.get(`${this.url}/client/${environment.clientName}/passUrl/${user_id}/token/${token}`, options)
|
return this.http.get(`${this.url}/client/${environment.clientName}/passUrl/${user_id}/token/${token}`, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reloadCard(user_id:string) {
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.set('Authorization', environment.appleWalletSecret);
|
||||||
|
const options = {
|
||||||
|
headers: headers,
|
||||||
|
};
|
||||||
|
const body = {
|
||||||
|
text: '',
|
||||||
|
isUpdateCard: true
|
||||||
|
}
|
||||||
|
return this.http.post(`${this.url}/apns/api/sendNotification/${user_id}`, options)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user