Add json tags to types

This commit is contained in:
2024-08-19 10:51:31 +02:00
parent de7c2cc82c
commit c17e25c358
5 changed files with 157 additions and 21 deletions

View File

@@ -3,6 +3,10 @@
import {main} from '../models';
import {time} from '../models';
export function EmptyBill():Promise<main.Bill>;
export function EmptyPayment():Promise<main.Payment>;
export function GetBills():Promise<main.WailsBills>;
export function GetPaymentsForMonth(arg1:time.Time):Promise<main.WailsPayments>;

View File

@@ -2,6 +2,14 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
export function EmptyBill() {
return window['go']['main']['App']['EmptyBill']();
}
export function EmptyPayment() {
return window['go']['main']['App']['EmptyPayment']();
}
export function GetBills() {
return window['go']['main']['App']['GetBills']();
}

View File

@@ -1,7 +1,59 @@
export namespace main {
export class WailsBills {
export class Bill {
id: number;
name: string;
static createFrom(source: any = {}) {
return new Bill(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.id = source["id"];
this.name = source["name"];
}
}
export class Payment {
id: number;
billId: number;
monthFor: time.Time;
paymentDate: time.Time;
static createFrom(source: any = {}) {
return new Payment(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.id = source["id"];
this.billId = source["billId"];
this.monthFor = this.convertValues(source["monthFor"], time.Time);
this.paymentDate = this.convertValues(source["paymentDate"], time.Time);
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
}
if (a.slice && a.map) {
return (a as any[]).map(elem => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
}
export class WailsBills {
data: Bill[];
success: boolean;
error: string;
static createFrom(source: any = {}) {
return new WailsBills(source);
@@ -9,11 +61,33 @@ export namespace main {
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.data = this.convertValues(source["data"], Bill);
this.success = source["success"];
this.error = source["error"];
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
}
if (a.slice && a.map) {
return (a as any[]).map(elem => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
}
export class WailsPayment {
data: Payment;
success: boolean;
error: string;
static createFrom(source: any = {}) {
return new WailsPayment(source);
@@ -21,11 +95,33 @@ export namespace main {
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.data = this.convertValues(source["data"], Payment);
this.success = source["success"];
this.error = source["error"];
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
}
if (a.slice && a.map) {
return (a as any[]).map(elem => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
}
export class WailsPayments {
data: Payment[];
success: boolean;
error: string;
static createFrom(source: any = {}) {
return new WailsPayments(source);
@@ -33,8 +129,28 @@ export namespace main {
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.data = this.convertValues(source["data"], Payment);
this.success = source["success"];
this.error = source["error"];
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
}
if (a.slice && a.map) {
return (a as any[]).map(elem => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
}
}