Correct calls to xero endpoint

This commit is contained in:
Rene Vergara 2023-05-10 11:05:15 -05:00
parent e0e8c60af4
commit 1f2510f522
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
5 changed files with 49 additions and 46 deletions

View file

@ -1,6 +1,6 @@
{
"name": "zgo",
"version": "2.1.0",
"version": "2.2.0",
"scripts": {
"ng": "ng",
"start": "ng serve",

View file

@ -45,7 +45,7 @@
style="margin-top: 10px;
margin-bottom: 20px;">
<div >&copy; 2023 Vergara Technologies LLC</div>
<div class="tiny">Version 2.1.0</div>
<div class="tiny">Version 2.2.0</div>
<div class="tiny">{{ vE.mainPriceData }}</div>
</div>
<div></div>

View file

@ -161,7 +161,7 @@ export class SettingsComponent implements OnInit {
xeroService.getXeroAccountCode(this.owner.address);
this.accCodeUpdate.subscribe(accData => {
this.xeroAccCod = accData;
console.log("xeroAccCod -> [" + this.xeroAccCod + "]");
//console.log("xeroAccCod -> [" + this.xeroAccCod + "]");
this.accCodForm.get('xAcc')!.setValue(this.xeroAccCod);
});
this.wooOwnerUpdate = wooService.ownerUpdate;
@ -185,7 +185,7 @@ export class SettingsComponent implements OnInit {
this.settingsForm.get('vKey')!.disable();
//
this.chgUILanguage();
console.log('SETTINGS: Return from chgUILanguage()');
//console.log('SETTINGS: Return from chgUILanguage()');
//
this.languageRdy.subscribe (
data => {
@ -334,21 +334,21 @@ export class SettingsComponent implements OnInit {
saveAccCod() {
this.xeroAccCod = this.accCodForm.value.xAcc;
console.log(">>> " + this.xeroAccCod);
//console.log(">>> " + this.xeroAccCod);
if ( this.xeroAccCod.length <= 10 ) {
const obs = this.xeroService
.setXeroAccountCode(this.owner.address,
this.xeroAccCod);
obs.subscribe(responseData => {
obs.subscribe({ next: responseData => {
if (responseData.status == 202) {
console.log('Account saved');
//console.log('Account saved');
this.notifierService
.showNotification(this.vE.settingsAcodeSaved,
this.vE.settingsNotservClose,
"success",
this.vE.settingsNotservSuccess);
} else {
console.log('Account not saved -> status[' + responseData.status + ']');
//console.log('Account not saved -> status[' + responseData.status + ']');
this.notifierService
.showNotification(
this.vE.settingsAcodeNotsaved,
@ -357,9 +357,10 @@ export class SettingsComponent implements OnInit {
this.vE.settingsNotservError);
}
}, error => {
console.log('Error saving Account Code -> ' + error.msg)
});
},
error: error => {
//console.log('Error saving Account Code -> ' + error.msg)
}});
} else {
this.notifierService
@ -378,19 +379,19 @@ export class SettingsComponent implements OnInit {
}
*/
checkStatus( arg : any ) {
console.log('onChange - checkStatus');
console.log(arg.target.value);
//console.log('onChange - checkStatus');
//console.log(arg.target.value);
this.saveAccOk = (arg.target.value != this.xeroAccCod );
}
chgUILanguage(){
console.log('SETTINGS.chgUILanguage Called ');
this.languageService.getViewElements('settings').subscribe(
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
//console.log('SETTINGS.chgUILanguage Called ');
this.languageService.getViewElements('settings').subscribe({
next: response => {
//console.log('Received >> ', response );
//console.log('Language Code : ', response.language);
//console.log('Component Name : ',response.component);
//console.log('Language data : ',response.data);
this.vE.settingsViewTitle = response.data.settings_view_title;
this.vE.settingsTabMainlbl = response.data.settings_tab_mainlbl;
@ -434,7 +435,7 @@ export class SettingsComponent implements OnInit {
//
this.languageRdy.next(true);
},
error => { console.log('Error >> ',error); }
);
error: error => { console.log('Error >> ',error); }
});
}
}

View file

@ -1,17 +1,15 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { UserService } from '../user.service';
import { FullnodeService } from '../fullnode.service';
import { ItemService } from '../items/items.service';
import { Subscription, Observable } from 'rxjs';
import { Observable } from 'rxjs';
import { SettingsComponent } from '../settings/settings.component';
import {Owner} from '../owner.model';
import {User} from '../user.model';
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
@Component({
selector: 'app-viewer',
@ -116,7 +114,7 @@ export class ViewerComponent implements OnInit {
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;
dialogConfig.data = this.owner;
dialogConfig.data = {o: this.owner, v: ''};
const dialogRef = this.dialog.open(SettingsComponent, dialogConfig);
dialogRef.afterClosed().subscribe((val) => {

View file

@ -37,17 +37,21 @@ export class XeroService {
public readonly tokenUpdate: Observable<any> = this._tokenUpdated.asObservable();
public readonly accCodeUpdate: Observable<string> = this._accCodeUpdated.asObservable();
private reqHeaders: HttpHeaders;
private reqParams: HttpParams;
private session: null | string;
constructor(
private http: HttpClient
) {
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
this.session = localStorage.getItem('s4z_token');
this.reqParams = new HttpParams().append('session', this.session!);
this.getXeroConfig();
}
getXeroConfig(){
let obs = this.http.get<{message: string, xeroConfig: any}>(this.beUrl+'api/xero', { headers:this.reqHeaders, observe: 'response'});
let obs = this.http.get<{message: string, xeroConfig: any}>(this.beUrl+'api/xero', { headers:this.reqHeaders, observe: 'response', params: this.reqParams});
obs.subscribe(xeroDataResponse => {
if (xeroDataResponse.status == 200) {
@ -64,13 +68,13 @@ export class XeroService {
}
getXeroAccessToken(code: string, address: string){
const params = new HttpParams().append('code', code).append('address', address);
const params = this.reqParams.append('code', code).append('address', address);
let obs = this.http.get(this.beUrl + 'api/xerotoken' , {headers: this.reqHeaders, params: params, observe: 'response'});
return obs;
}
getXeroAccountCode(address: string){
const params = new HttpParams().append('address', address);
const params = this.reqParams.append('address', address);
let obs = this.http.get<{message: string, code: string}>(this.beUrl + 'api/xeroaccount', {headers: this.reqHeaders, params: params, observe: 'response'});
obs.subscribe(accountResponse => {
if (accountResponse.status == 200) {
@ -85,7 +89,7 @@ export class XeroService {
setXeroAccountCode(address: string, code: string) {
const params = new HttpParams().append('address', address).append('code', code);
const params = this.reqParams.append('address', address).append('code', code);
let obs = this.http.post(this.beUrl + 'api/xeroaccount', {}, {headers: this.reqHeaders, params: params, observe: 'response'});
/*
obs.subscribe(responseData => {