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", "name": "zgo",
"version": "2.1.0", "version": "2.2.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve", "start": "ng serve",

View file

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

View file

@ -161,7 +161,7 @@ export class SettingsComponent implements OnInit {
xeroService.getXeroAccountCode(this.owner.address); xeroService.getXeroAccountCode(this.owner.address);
this.accCodeUpdate.subscribe(accData => { this.accCodeUpdate.subscribe(accData => {
this.xeroAccCod = accData; this.xeroAccCod = accData;
console.log("xeroAccCod -> [" + this.xeroAccCod + "]"); //console.log("xeroAccCod -> [" + this.xeroAccCod + "]");
this.accCodForm.get('xAcc')!.setValue(this.xeroAccCod); this.accCodForm.get('xAcc')!.setValue(this.xeroAccCod);
}); });
this.wooOwnerUpdate = wooService.ownerUpdate; this.wooOwnerUpdate = wooService.ownerUpdate;
@ -185,7 +185,7 @@ export class SettingsComponent implements OnInit {
this.settingsForm.get('vKey')!.disable(); this.settingsForm.get('vKey')!.disable();
// //
this.chgUILanguage(); this.chgUILanguage();
console.log('SETTINGS: Return from chgUILanguage()'); //console.log('SETTINGS: Return from chgUILanguage()');
// //
this.languageRdy.subscribe ( this.languageRdy.subscribe (
data => { data => {
@ -334,21 +334,21 @@ export class SettingsComponent implements OnInit {
saveAccCod() { saveAccCod() {
this.xeroAccCod = this.accCodForm.value.xAcc; this.xeroAccCod = this.accCodForm.value.xAcc;
console.log(">>> " + this.xeroAccCod); //console.log(">>> " + this.xeroAccCod);
if ( this.xeroAccCod.length <= 10 ) { if ( this.xeroAccCod.length <= 10 ) {
const obs = this.xeroService const obs = this.xeroService
.setXeroAccountCode(this.owner.address, .setXeroAccountCode(this.owner.address,
this.xeroAccCod); this.xeroAccCod);
obs.subscribe(responseData => { obs.subscribe({ next: responseData => {
if (responseData.status == 202) { if (responseData.status == 202) {
console.log('Account saved'); //console.log('Account saved');
this.notifierService this.notifierService
.showNotification(this.vE.settingsAcodeSaved, .showNotification(this.vE.settingsAcodeSaved,
this.vE.settingsNotservClose, this.vE.settingsNotservClose,
"success", "success",
this.vE.settingsNotservSuccess); this.vE.settingsNotservSuccess);
} else { } else {
console.log('Account not saved -> status[' + responseData.status + ']'); //console.log('Account not saved -> status[' + responseData.status + ']');
this.notifierService this.notifierService
.showNotification( .showNotification(
this.vE.settingsAcodeNotsaved, this.vE.settingsAcodeNotsaved,
@ -357,9 +357,10 @@ export class SettingsComponent implements OnInit {
this.vE.settingsNotservError); this.vE.settingsNotservError);
} }
}, error => { },
console.log('Error saving Account Code -> ' + error.msg) error: error => {
}); //console.log('Error saving Account Code -> ' + error.msg)
}});
} else { } else {
this.notifierService this.notifierService
@ -378,19 +379,19 @@ export class SettingsComponent implements OnInit {
} }
*/ */
checkStatus( arg : any ) { checkStatus( arg : any ) {
console.log('onChange - checkStatus'); //console.log('onChange - checkStatus');
console.log(arg.target.value); //console.log(arg.target.value);
this.saveAccOk = (arg.target.value != this.xeroAccCod ); this.saveAccOk = (arg.target.value != this.xeroAccCod );
} }
chgUILanguage(){ chgUILanguage(){
console.log('SETTINGS.chgUILanguage Called '); //console.log('SETTINGS.chgUILanguage Called ');
this.languageService.getViewElements('settings').subscribe( this.languageService.getViewElements('settings').subscribe({
response => { next: response => {
console.log('Received >> ', response ); //console.log('Received >> ', response );
console.log('Language Code : ', response.language); //console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component); //console.log('Component Name : ',response.component);
console.log('Language data : ',response.data); //console.log('Language data : ',response.data);
this.vE.settingsViewTitle = response.data.settings_view_title; this.vE.settingsViewTitle = response.data.settings_view_title;
this.vE.settingsTabMainlbl = response.data.settings_tab_mainlbl; this.vE.settingsTabMainlbl = response.data.settings_tab_mainlbl;
@ -434,7 +435,7 @@ export class SettingsComponent implements OnInit {
// //
this.languageRdy.next(true); 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 { Component, OnInit } from '@angular/core';
import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'; import { Router } from '@angular/router';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { UserService } from '../user.service'; import { UserService } from '../user.service';
import { FullnodeService } from '../fullnode.service'; import { FullnodeService } from '../fullnode.service';
import { ItemService } from '../items/items.service'; import { Observable } from 'rxjs';
import { Subscription, Observable } from 'rxjs';
import { SettingsComponent } from '../settings/settings.component'; import { SettingsComponent } from '../settings/settings.component';
import {Owner} from '../owner.model'; import {Owner} from '../owner.model';
import {User} from '../user.model'; import {User} from '../user.model';
import { LanguageService } from '../language.service'; import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
@Component({ @Component({
selector: 'app-viewer', selector: 'app-viewer',
@ -116,7 +114,7 @@ export class ViewerComponent implements OnInit {
dialogConfig.disableClose = true; dialogConfig.disableClose = true;
dialogConfig.autoFocus = true; dialogConfig.autoFocus = true;
dialogConfig.data = this.owner; dialogConfig.data = {o: this.owner, v: ''};
const dialogRef = this.dialog.open(SettingsComponent, dialogConfig); const dialogRef = this.dialog.open(SettingsComponent, dialogConfig);
dialogRef.afterClosed().subscribe((val) => { dialogRef.afterClosed().subscribe((val) => {

View file

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