account working

This commit is contained in:
José Salazar
2026-01-26 13:57:04 -05:00
parent 42a11590f1
commit 1934d4caab
13 changed files with 19419 additions and 19282 deletions

View File

@@ -1,16 +1,16 @@
# Basic Usage # Basic Usage
```dart ```dart
ExampleConnector.instance.CreateUser(createUserVariables).execute(); ExampleConnector.instance.createWorkforce(createWorkforceVariables).execute();
ExampleConnector.instance.UpdateUser(updateUserVariables).execute(); ExampleConnector.instance.updateWorkforce(updateWorkforceVariables).execute();
ExampleConnector.instance.DeleteUser(deleteUserVariables).execute(); ExampleConnector.instance.deactivateWorkforce(deactivateWorkforceVariables).execute();
ExampleConnector.instance.listVendorRates().execute(); ExampleConnector.instance.listInvoices(listInvoicesVariables).execute();
ExampleConnector.instance.getVendorRateById(getVendorRateByIdVariables).execute(); ExampleConnector.instance.getInvoiceById(getInvoiceByIdVariables).execute();
ExampleConnector.instance.listApplications().execute(); ExampleConnector.instance.listInvoicesByVendorId(listInvoicesByVendorIdVariables).execute();
ExampleConnector.instance.getApplicationById(getApplicationByIdVariables).execute(); ExampleConnector.instance.listInvoicesByBusinessId(listInvoicesByBusinessIdVariables).execute();
ExampleConnector.instance.getApplicationsByShiftId(getApplicationsByShiftIdVariables).execute(); ExampleConnector.instance.listInvoicesByOrderId(listInvoicesByOrderIdVariables).execute();
ExampleConnector.instance.getApplicationsByShiftIdAndStatus(getApplicationsByShiftIdAndStatusVariables).execute(); ExampleConnector.instance.listInvoicesByStatus(listInvoicesByStatusVariables).execute();
ExampleConnector.instance.getApplicationsByStaffId(getApplicationsByStaffIdVariables).execute(); ExampleConnector.instance.filterInvoices(filterInvoicesVariables).execute();
``` ```
@@ -23,8 +23,8 @@ Optional fields can be discovered based on classes that have `Optional` object t
This is an example of a mutation with an optional field: This is an example of a mutation with an optional field:
```dart ```dart
await ExampleConnector.instance.listStaffAvailabilitiesByDay({ ... }) await ExampleConnector.instance.updateVendor({ ... })
.offset(...) .companyName(...)
.execute(); .execute();
``` ```

View File

@@ -6,11 +6,21 @@ class CreateAccountVariablesBuilder {
String last4; String last4;
Optional<bool> _isPrimary = Optional.optional(nativeFromJson, nativeToJson); Optional<bool> _isPrimary = Optional.optional(nativeFromJson, nativeToJson);
String ownerId; String ownerId;
Optional<String> _accountNumber = Optional.optional(nativeFromJson, nativeToJson);
Optional<String> _routeNumber = Optional.optional(nativeFromJson, nativeToJson);
final FirebaseDataConnect _dataConnect; CreateAccountVariablesBuilder isPrimary(bool? t) { final FirebaseDataConnect _dataConnect; CreateAccountVariablesBuilder isPrimary(bool? t) {
_isPrimary.value = t; _isPrimary.value = t;
return this; return this;
} }
CreateAccountVariablesBuilder accountNumber(String? t) {
_accountNumber.value = t;
return this;
}
CreateAccountVariablesBuilder routeNumber(String? t) {
_routeNumber.value = t;
return this;
}
CreateAccountVariablesBuilder(this._dataConnect, {required this.bank,required this.type,required this.last4,required this.ownerId,}); CreateAccountVariablesBuilder(this._dataConnect, {required this.bank,required this.type,required this.last4,required this.ownerId,});
Deserializer<CreateAccountData> dataDeserializer = (dynamic json) => CreateAccountData.fromJson(jsonDecode(json)); Deserializer<CreateAccountData> dataDeserializer = (dynamic json) => CreateAccountData.fromJson(jsonDecode(json));
@@ -20,7 +30,7 @@ class CreateAccountVariablesBuilder {
} }
MutationRef<CreateAccountData, CreateAccountVariables> ref() { MutationRef<CreateAccountData, CreateAccountVariables> ref() {
CreateAccountVariables vars= CreateAccountVariables(bank: bank,type: type,last4: last4,isPrimary: _isPrimary,ownerId: ownerId,); CreateAccountVariables vars= CreateAccountVariables(bank: bank,type: type,last4: last4,isPrimary: _isPrimary,ownerId: ownerId,accountNumber: _accountNumber,routeNumber: _routeNumber,);
return _dataConnect.mutation("createAccount", dataDeserializer, varsSerializer, vars); return _dataConnect.mutation("createAccount", dataDeserializer, varsSerializer, vars);
} }
} }
@@ -100,6 +110,8 @@ class CreateAccountVariables {
final String last4; final String last4;
late final Optional<bool>isPrimary; late final Optional<bool>isPrimary;
final String ownerId; final String ownerId;
late final Optional<String>accountNumber;
late final Optional<String>routeNumber;
@Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.')
CreateAccountVariables.fromJson(Map<String, dynamic> json): CreateAccountVariables.fromJson(Map<String, dynamic> json):
@@ -116,6 +128,14 @@ class CreateAccountVariables {
isPrimary.value = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']); isPrimary.value = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']);
accountNumber = Optional.optional(nativeFromJson, nativeToJson);
accountNumber.value = json['accountNumber'] == null ? null : nativeFromJson<String>(json['accountNumber']);
routeNumber = Optional.optional(nativeFromJson, nativeToJson);
routeNumber.value = json['routeNumber'] == null ? null : nativeFromJson<String>(json['routeNumber']);
} }
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
@@ -131,11 +151,13 @@ class CreateAccountVariables {
type == otherTyped.type && type == otherTyped.type &&
last4 == otherTyped.last4 && last4 == otherTyped.last4 &&
isPrimary == otherTyped.isPrimary && isPrimary == otherTyped.isPrimary &&
ownerId == otherTyped.ownerId; ownerId == otherTyped.ownerId &&
accountNumber == otherTyped.accountNumber &&
routeNumber == otherTyped.routeNumber;
} }
@override @override
int get hashCode => Object.hashAll([bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode]); int get hashCode => Object.hashAll([bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode, accountNumber.hashCode, routeNumber.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -149,6 +171,12 @@ class CreateAccountVariables {
json['isPrimary'] = isPrimary.toJson(); json['isPrimary'] = isPrimary.toJson();
} }
json['ownerId'] = nativeToJson<String>(ownerId); json['ownerId'] = nativeToJson<String>(ownerId);
if(accountNumber.state == OptionalState.set) {
json['accountNumber'] = accountNumber.toJson();
}
if(routeNumber.state == OptionalState.set) {
json['routeNumber'] = routeNumber.toJson();
}
return json; return json;
} }
@@ -158,6 +186,8 @@ class CreateAccountVariables {
required this.last4, required this.last4,
required this.isPrimary, required this.isPrimary,
required this.ownerId, required this.ownerId,
required this.accountNumber,
required this.routeNumber,
}); });
} }

View File

@@ -45,6 +45,8 @@ class FilterAccountsAccounts {
final String last4; final String last4;
final bool? isPrimary; final bool? isPrimary;
final String ownerId; final String ownerId;
final String? accountNumber;
final String? routeNumber;
FilterAccountsAccounts.fromJson(dynamic json): FilterAccountsAccounts.fromJson(dynamic json):
id = nativeFromJson<String>(json['id']), id = nativeFromJson<String>(json['id']),
@@ -52,7 +54,9 @@ class FilterAccountsAccounts {
type = accountTypeDeserializer(json['type']), type = accountTypeDeserializer(json['type']),
last4 = nativeFromJson<String>(json['last4']), last4 = nativeFromJson<String>(json['last4']),
isPrimary = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']), isPrimary = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']),
ownerId = nativeFromJson<String>(json['ownerId']); ownerId = nativeFromJson<String>(json['ownerId']),
accountNumber = json['accountNumber'] == null ? null : nativeFromJson<String>(json['accountNumber']),
routeNumber = json['routeNumber'] == null ? null : nativeFromJson<String>(json['routeNumber']);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
if(identical(this, other)) { if(identical(this, other)) {
@@ -68,11 +72,13 @@ class FilterAccountsAccounts {
type == otherTyped.type && type == otherTyped.type &&
last4 == otherTyped.last4 && last4 == otherTyped.last4 &&
isPrimary == otherTyped.isPrimary && isPrimary == otherTyped.isPrimary &&
ownerId == otherTyped.ownerId; ownerId == otherTyped.ownerId &&
accountNumber == otherTyped.accountNumber &&
routeNumber == otherTyped.routeNumber;
} }
@override @override
int get hashCode => Object.hashAll([id.hashCode, bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode]); int get hashCode => Object.hashAll([id.hashCode, bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode, accountNumber.hashCode, routeNumber.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -87,6 +93,12 @@ class FilterAccountsAccounts {
json['isPrimary'] = nativeToJson<bool?>(isPrimary); json['isPrimary'] = nativeToJson<bool?>(isPrimary);
} }
json['ownerId'] = nativeToJson<String>(ownerId); json['ownerId'] = nativeToJson<String>(ownerId);
if (accountNumber != null) {
json['accountNumber'] = nativeToJson<String?>(accountNumber);
}
if (routeNumber != null) {
json['routeNumber'] = nativeToJson<String?>(routeNumber);
}
return json; return json;
} }
@@ -97,6 +109,8 @@ class FilterAccountsAccounts {
required this.last4, required this.last4,
this.isPrimary, this.isPrimary,
required this.ownerId, required this.ownerId,
this.accountNumber,
this.routeNumber,
}); });
} }

View File

@@ -25,9 +25,9 @@ class GetAccountByIdAccount {
final String last4; final String last4;
final bool? isPrimary; final bool? isPrimary;
final String ownerId; final String ownerId;
final String? accountNumber;
final String? routeNumber;
final Timestamp? createdAt; final Timestamp? createdAt;
final Timestamp? updatedAt;
final String? createdBy;
GetAccountByIdAccount.fromJson(dynamic json): GetAccountByIdAccount.fromJson(dynamic json):
id = nativeFromJson<String>(json['id']), id = nativeFromJson<String>(json['id']),
@@ -36,9 +36,9 @@ class GetAccountByIdAccount {
last4 = nativeFromJson<String>(json['last4']), last4 = nativeFromJson<String>(json['last4']),
isPrimary = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']), isPrimary = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']),
ownerId = nativeFromJson<String>(json['ownerId']), ownerId = nativeFromJson<String>(json['ownerId']),
createdAt = json['createdAt'] == null ? null : Timestamp.fromJson(json['createdAt']), accountNumber = json['accountNumber'] == null ? null : nativeFromJson<String>(json['accountNumber']),
updatedAt = json['updatedAt'] == null ? null : Timestamp.fromJson(json['updatedAt']), routeNumber = json['routeNumber'] == null ? null : nativeFromJson<String>(json['routeNumber']),
createdBy = json['createdBy'] == null ? null : nativeFromJson<String>(json['createdBy']); createdAt = json['createdAt'] == null ? null : Timestamp.fromJson(json['createdAt']);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
if(identical(this, other)) { if(identical(this, other)) {
@@ -55,13 +55,13 @@ class GetAccountByIdAccount {
last4 == otherTyped.last4 && last4 == otherTyped.last4 &&
isPrimary == otherTyped.isPrimary && isPrimary == otherTyped.isPrimary &&
ownerId == otherTyped.ownerId && ownerId == otherTyped.ownerId &&
createdAt == otherTyped.createdAt && accountNumber == otherTyped.accountNumber &&
updatedAt == otherTyped.updatedAt && routeNumber == otherTyped.routeNumber &&
createdBy == otherTyped.createdBy; createdAt == otherTyped.createdAt;
} }
@override @override
int get hashCode => Object.hashAll([id.hashCode, bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode, createdAt.hashCode, updatedAt.hashCode, createdBy.hashCode]); int get hashCode => Object.hashAll([id.hashCode, bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode, accountNumber.hashCode, routeNumber.hashCode, createdAt.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -76,15 +76,15 @@ class GetAccountByIdAccount {
json['isPrimary'] = nativeToJson<bool?>(isPrimary); json['isPrimary'] = nativeToJson<bool?>(isPrimary);
} }
json['ownerId'] = nativeToJson<String>(ownerId); json['ownerId'] = nativeToJson<String>(ownerId);
if (accountNumber != null) {
json['accountNumber'] = nativeToJson<String?>(accountNumber);
}
if (routeNumber != null) {
json['routeNumber'] = nativeToJson<String?>(routeNumber);
}
if (createdAt != null) { if (createdAt != null) {
json['createdAt'] = createdAt!.toJson(); json['createdAt'] = createdAt!.toJson();
} }
if (updatedAt != null) {
json['updatedAt'] = updatedAt!.toJson();
}
if (createdBy != null) {
json['createdBy'] = nativeToJson<String?>(createdBy);
}
return json; return json;
} }
@@ -95,9 +95,9 @@ class GetAccountByIdAccount {
required this.last4, required this.last4,
this.isPrimary, this.isPrimary,
required this.ownerId, required this.ownerId,
this.accountNumber,
this.routeNumber,
this.createdAt, this.createdAt,
this.updatedAt,
this.createdBy,
}); });
} }

View File

@@ -25,9 +25,9 @@ class GetAccountsByOwnerIdAccounts {
final String last4; final String last4;
final bool? isPrimary; final bool? isPrimary;
final String ownerId; final String ownerId;
final String? accountNumber;
final String? routeNumber;
final Timestamp? createdAt; final Timestamp? createdAt;
final Timestamp? updatedAt;
final String? createdBy;
GetAccountsByOwnerIdAccounts.fromJson(dynamic json): GetAccountsByOwnerIdAccounts.fromJson(dynamic json):
id = nativeFromJson<String>(json['id']), id = nativeFromJson<String>(json['id']),
@@ -36,9 +36,9 @@ class GetAccountsByOwnerIdAccounts {
last4 = nativeFromJson<String>(json['last4']), last4 = nativeFromJson<String>(json['last4']),
isPrimary = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']), isPrimary = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']),
ownerId = nativeFromJson<String>(json['ownerId']), ownerId = nativeFromJson<String>(json['ownerId']),
createdAt = json['createdAt'] == null ? null : Timestamp.fromJson(json['createdAt']), accountNumber = json['accountNumber'] == null ? null : nativeFromJson<String>(json['accountNumber']),
updatedAt = json['updatedAt'] == null ? null : Timestamp.fromJson(json['updatedAt']), routeNumber = json['routeNumber'] == null ? null : nativeFromJson<String>(json['routeNumber']),
createdBy = json['createdBy'] == null ? null : nativeFromJson<String>(json['createdBy']); createdAt = json['createdAt'] == null ? null : Timestamp.fromJson(json['createdAt']);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
if(identical(this, other)) { if(identical(this, other)) {
@@ -55,13 +55,13 @@ class GetAccountsByOwnerIdAccounts {
last4 == otherTyped.last4 && last4 == otherTyped.last4 &&
isPrimary == otherTyped.isPrimary && isPrimary == otherTyped.isPrimary &&
ownerId == otherTyped.ownerId && ownerId == otherTyped.ownerId &&
createdAt == otherTyped.createdAt && accountNumber == otherTyped.accountNumber &&
updatedAt == otherTyped.updatedAt && routeNumber == otherTyped.routeNumber &&
createdBy == otherTyped.createdBy; createdAt == otherTyped.createdAt;
} }
@override @override
int get hashCode => Object.hashAll([id.hashCode, bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode, createdAt.hashCode, updatedAt.hashCode, createdBy.hashCode]); int get hashCode => Object.hashAll([id.hashCode, bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode, accountNumber.hashCode, routeNumber.hashCode, createdAt.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -76,15 +76,15 @@ class GetAccountsByOwnerIdAccounts {
json['isPrimary'] = nativeToJson<bool?>(isPrimary); json['isPrimary'] = nativeToJson<bool?>(isPrimary);
} }
json['ownerId'] = nativeToJson<String>(ownerId); json['ownerId'] = nativeToJson<String>(ownerId);
if (accountNumber != null) {
json['accountNumber'] = nativeToJson<String?>(accountNumber);
}
if (routeNumber != null) {
json['routeNumber'] = nativeToJson<String?>(routeNumber);
}
if (createdAt != null) { if (createdAt != null) {
json['createdAt'] = createdAt!.toJson(); json['createdAt'] = createdAt!.toJson();
} }
if (updatedAt != null) {
json['updatedAt'] = updatedAt!.toJson();
}
if (createdBy != null) {
json['createdBy'] = nativeToJson<String?>(createdBy);
}
return json; return json;
} }
@@ -95,9 +95,9 @@ class GetAccountsByOwnerIdAccounts {
required this.last4, required this.last4,
this.isPrimary, this.isPrimary,
required this.ownerId, required this.ownerId,
this.accountNumber,
this.routeNumber,
this.createdAt, this.createdAt,
this.updatedAt,
this.createdBy,
}); });
} }

View File

@@ -24,9 +24,9 @@ class ListAccountsAccounts {
final String last4; final String last4;
final bool? isPrimary; final bool? isPrimary;
final String ownerId; final String ownerId;
final String? accountNumber;
final String? routeNumber;
final Timestamp? createdAt; final Timestamp? createdAt;
final Timestamp? updatedAt;
final String? createdBy;
ListAccountsAccounts.fromJson(dynamic json): ListAccountsAccounts.fromJson(dynamic json):
id = nativeFromJson<String>(json['id']), id = nativeFromJson<String>(json['id']),
@@ -35,9 +35,9 @@ class ListAccountsAccounts {
last4 = nativeFromJson<String>(json['last4']), last4 = nativeFromJson<String>(json['last4']),
isPrimary = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']), isPrimary = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']),
ownerId = nativeFromJson<String>(json['ownerId']), ownerId = nativeFromJson<String>(json['ownerId']),
createdAt = json['createdAt'] == null ? null : Timestamp.fromJson(json['createdAt']), accountNumber = json['accountNumber'] == null ? null : nativeFromJson<String>(json['accountNumber']),
updatedAt = json['updatedAt'] == null ? null : Timestamp.fromJson(json['updatedAt']), routeNumber = json['routeNumber'] == null ? null : nativeFromJson<String>(json['routeNumber']),
createdBy = json['createdBy'] == null ? null : nativeFromJson<String>(json['createdBy']); createdAt = json['createdAt'] == null ? null : Timestamp.fromJson(json['createdAt']);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
if(identical(this, other)) { if(identical(this, other)) {
@@ -54,13 +54,13 @@ class ListAccountsAccounts {
last4 == otherTyped.last4 && last4 == otherTyped.last4 &&
isPrimary == otherTyped.isPrimary && isPrimary == otherTyped.isPrimary &&
ownerId == otherTyped.ownerId && ownerId == otherTyped.ownerId &&
createdAt == otherTyped.createdAt && accountNumber == otherTyped.accountNumber &&
updatedAt == otherTyped.updatedAt && routeNumber == otherTyped.routeNumber &&
createdBy == otherTyped.createdBy; createdAt == otherTyped.createdAt;
} }
@override @override
int get hashCode => Object.hashAll([id.hashCode, bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode, createdAt.hashCode, updatedAt.hashCode, createdBy.hashCode]); int get hashCode => Object.hashAll([id.hashCode, bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, ownerId.hashCode, accountNumber.hashCode, routeNumber.hashCode, createdAt.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -75,15 +75,15 @@ class ListAccountsAccounts {
json['isPrimary'] = nativeToJson<bool?>(isPrimary); json['isPrimary'] = nativeToJson<bool?>(isPrimary);
} }
json['ownerId'] = nativeToJson<String>(ownerId); json['ownerId'] = nativeToJson<String>(ownerId);
if (accountNumber != null) {
json['accountNumber'] = nativeToJson<String?>(accountNumber);
}
if (routeNumber != null) {
json['routeNumber'] = nativeToJson<String?>(routeNumber);
}
if (createdAt != null) { if (createdAt != null) {
json['createdAt'] = createdAt!.toJson(); json['createdAt'] = createdAt!.toJson();
} }
if (updatedAt != null) {
json['updatedAt'] = updatedAt!.toJson();
}
if (createdBy != null) {
json['createdBy'] = nativeToJson<String?>(createdBy);
}
return json; return json;
} }
@@ -94,9 +94,9 @@ class ListAccountsAccounts {
required this.last4, required this.last4,
this.isPrimary, this.isPrimary,
required this.ownerId, required this.ownerId,
this.accountNumber,
this.routeNumber,
this.createdAt, this.createdAt,
this.updatedAt,
this.createdBy,
}); });
} }

View File

@@ -6,6 +6,8 @@ class UpdateAccountVariablesBuilder {
Optional<AccountType> _type = Optional.optional((data) => AccountType.values.byName(data), enumSerializer); Optional<AccountType> _type = Optional.optional((data) => AccountType.values.byName(data), enumSerializer);
Optional<String> _last4 = Optional.optional(nativeFromJson, nativeToJson); Optional<String> _last4 = Optional.optional(nativeFromJson, nativeToJson);
Optional<bool> _isPrimary = Optional.optional(nativeFromJson, nativeToJson); Optional<bool> _isPrimary = Optional.optional(nativeFromJson, nativeToJson);
Optional<String> _accountNumber = Optional.optional(nativeFromJson, nativeToJson);
Optional<String> _routeNumber = Optional.optional(nativeFromJson, nativeToJson);
final FirebaseDataConnect _dataConnect; UpdateAccountVariablesBuilder bank(String? t) { final FirebaseDataConnect _dataConnect; UpdateAccountVariablesBuilder bank(String? t) {
_bank.value = t; _bank.value = t;
@@ -23,6 +25,14 @@ class UpdateAccountVariablesBuilder {
_isPrimary.value = t; _isPrimary.value = t;
return this; return this;
} }
UpdateAccountVariablesBuilder accountNumber(String? t) {
_accountNumber.value = t;
return this;
}
UpdateAccountVariablesBuilder routeNumber(String? t) {
_routeNumber.value = t;
return this;
}
UpdateAccountVariablesBuilder(this._dataConnect, {required this.id,}); UpdateAccountVariablesBuilder(this._dataConnect, {required this.id,});
Deserializer<UpdateAccountData> dataDeserializer = (dynamic json) => UpdateAccountData.fromJson(jsonDecode(json)); Deserializer<UpdateAccountData> dataDeserializer = (dynamic json) => UpdateAccountData.fromJson(jsonDecode(json));
@@ -32,7 +42,7 @@ class UpdateAccountVariablesBuilder {
} }
MutationRef<UpdateAccountData, UpdateAccountVariables> ref() { MutationRef<UpdateAccountData, UpdateAccountVariables> ref() {
UpdateAccountVariables vars= UpdateAccountVariables(id: id,bank: _bank,type: _type,last4: _last4,isPrimary: _isPrimary,); UpdateAccountVariables vars= UpdateAccountVariables(id: id,bank: _bank,type: _type,last4: _last4,isPrimary: _isPrimary,accountNumber: _accountNumber,routeNumber: _routeNumber,);
return _dataConnect.mutation("updateAccount", dataDeserializer, varsSerializer, vars); return _dataConnect.mutation("updateAccount", dataDeserializer, varsSerializer, vars);
} }
} }
@@ -114,6 +124,8 @@ class UpdateAccountVariables {
late final Optional<AccountType>type; late final Optional<AccountType>type;
late final Optional<String>last4; late final Optional<String>last4;
late final Optional<bool>isPrimary; late final Optional<bool>isPrimary;
late final Optional<String>accountNumber;
late final Optional<String>routeNumber;
@Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.')
UpdateAccountVariables.fromJson(Map<String, dynamic> json): UpdateAccountVariables.fromJson(Map<String, dynamic> json):
@@ -136,6 +148,14 @@ class UpdateAccountVariables {
isPrimary = Optional.optional(nativeFromJson, nativeToJson); isPrimary = Optional.optional(nativeFromJson, nativeToJson);
isPrimary.value = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']); isPrimary.value = json['isPrimary'] == null ? null : nativeFromJson<bool>(json['isPrimary']);
accountNumber = Optional.optional(nativeFromJson, nativeToJson);
accountNumber.value = json['accountNumber'] == null ? null : nativeFromJson<String>(json['accountNumber']);
routeNumber = Optional.optional(nativeFromJson, nativeToJson);
routeNumber.value = json['routeNumber'] == null ? null : nativeFromJson<String>(json['routeNumber']);
} }
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
@@ -151,11 +171,13 @@ class UpdateAccountVariables {
bank == otherTyped.bank && bank == otherTyped.bank &&
type == otherTyped.type && type == otherTyped.type &&
last4 == otherTyped.last4 && last4 == otherTyped.last4 &&
isPrimary == otherTyped.isPrimary; isPrimary == otherTyped.isPrimary &&
accountNumber == otherTyped.accountNumber &&
routeNumber == otherTyped.routeNumber;
} }
@override @override
int get hashCode => Object.hashAll([id.hashCode, bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode]); int get hashCode => Object.hashAll([id.hashCode, bank.hashCode, type.hashCode, last4.hashCode, isPrimary.hashCode, accountNumber.hashCode, routeNumber.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -173,6 +195,12 @@ class UpdateAccountVariables {
if(isPrimary.state == OptionalState.set) { if(isPrimary.state == OptionalState.set) {
json['isPrimary'] = isPrimary.toJson(); json['isPrimary'] = isPrimary.toJson();
} }
if(accountNumber.state == OptionalState.set) {
json['accountNumber'] = accountNumber.toJson();
}
if(routeNumber.state == OptionalState.set) {
json['routeNumber'] = routeNumber.toJson();
}
return json; return json;
} }
@@ -182,6 +210,8 @@ class UpdateAccountVariables {
required this.type, required this.type,
required this.last4, required this.last4,
required this.isPrimary, required this.isPrimary,
required this.accountNumber,
required this.routeNumber,
}); });
} }

View File

@@ -95,6 +95,8 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
).execute(); ).execute();
final GetUserByIdUser? user = response.data.user; final GetUserByIdUser? user = response.data.user;
GetStaffByUserIdStaffs? staffRecord;
if (mode == AuthMode.signup) { if (mode == AuthMode.signup) {
if (user == null) { if (user == null) {
await dataConnect await dataConnect
@@ -140,6 +142,7 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
'Your account is not registered yet. Please register first.', 'Your account is not registered yet. Please register first.',
); );
} }
staffRecord = staffResponse.data.staffs.first;
} }
final String email = user?.email ?? ''; final String email = user?.email ?? '';
@@ -152,8 +155,21 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
phone: firebaseUser.phoneNumber, phone: firebaseUser.phoneNumber,
role: user?.role.stringValue ?? 'USER', role: user?.role.stringValue ?? 'USER',
); );
final domain.Staff? domainStaff = staffRecord == null
? null
: domain.Staff(
id: staffRecord.id,
authProviderId: staffRecord.userId,
name: staffRecord.fullName,
email: staffRecord.email ?? '',
phone: staffRecord.phone,
status: domain.StaffStatus.completedProfile,
address: staffRecord.addres,
avatar: staffRecord.photoUrl,
livePhoto: null,
);
StaffSessionStore.instance.setSession( StaffSessionStore.instance.setSession(
StaffSession(user: domainUser, staff: null), StaffSession(user: domainUser, staff: domainStaff),
); );
return domainUser; return domainUser;
} }

View File

@@ -21,6 +21,7 @@ class BankAccountRepositoryImpl implements BankAccountRepository {
if (user == null) throw Exception('User not authenticated'); if (user == null) throw Exception('User not authenticated');
final String? staffId = StaffSessionStore.instance.session?.staff?.id; final String? staffId = StaffSessionStore.instance.session?.staff?.id;
if (staffId == null || staffId.isEmpty) { if (staffId == null || staffId.isEmpty) {
print('BankAccount getAccounts: missing staffId userId=${user.uid} session=${StaffSessionStore.instance.session}');
throw Exception('Staff profile is missing.'); throw Exception('Staff profile is missing.');
} }
@@ -34,9 +35,10 @@ class BankAccountRepositoryImpl implements BankAccountRepository {
id: account.id, id: account.id,
userId: account.ownerId, userId: account.ownerId,
bankName: account.bank, bankName: account.bank,
accountNumber: account.last4, // Using last4 as account number representation for now accountNumber: account.accountNumber ?? '',
last4: account.last4, last4: account.last4,
accountName: '', // Not returned by API accountName: '', // Not returned by API
sortCode: account.routeNumber,
type: _mapAccountType(account.type), type: _mapAccountType(account.type),
isPrimary: account.isPrimary ?? false, isPrimary: account.isPrimary ?? false,
); );
@@ -49,15 +51,23 @@ class BankAccountRepositoryImpl implements BankAccountRepository {
if (user == null) throw Exception('User not authenticated'); if (user == null) throw Exception('User not authenticated');
final String? staffId = StaffSessionStore.instance.session?.staff?.id; final String? staffId = StaffSessionStore.instance.session?.staff?.id;
if (staffId == null || staffId.isEmpty) { if (staffId == null || staffId.isEmpty) {
print('BankAccount addAccount: missing staffId userId=${user.uid} session=${StaffSessionStore.instance.session}');
throw Exception('Staff profile is missing.'); throw Exception('Staff profile is missing.');
} }
final QueryResult<GetAccountsByOwnerIdData, GetAccountsByOwnerIdVariables>
existingAccounts = await dataConnect
.getAccountsByOwnerId(ownerId: staffId)
.execute();
final bool hasAccounts = existingAccounts.data.accounts.isNotEmpty;
final bool isPrimary = !hasAccounts;
await dataConnect.createAccount( await dataConnect.createAccount(
bank: account.bankName, bank: account.bankName,
type: _mapDomainType(account.type), type: _mapDomainType(account.type),
last4: account.last4 ?? account.accountNumber.substring(account.accountNumber.length - 4), last4: _safeLast4(account.last4, account.accountNumber),
ownerId: staffId, ownerId: staffId,
).isPrimary(account.isPrimary).execute(); ).isPrimary(isPrimary).accountNumber(account.accountNumber).routeNumber(account.sortCode).execute();
} }
BankAccountType _mapAccountType(EnumValue<AccountType> type) { BankAccountType _mapAccountType(EnumValue<AccountType> type) {
@@ -82,4 +92,16 @@ class BankAccountRepositoryImpl implements BankAccountRepository {
return AccountType.CHECKING; // Default fallback return AccountType.CHECKING; // Default fallback
} }
} }
String _safeLast4(String? last4, String accountNumber) {
if (last4 != null && last4.isNotEmpty) {
return last4;
}
if (accountNumber.isEmpty) {
return '';
}
return accountNumber.length > 4
? accountNumber.substring(accountNumber.length - 4)
: accountNumber;
}
} }

View File

@@ -51,6 +51,7 @@ class BankAccountCubit extends Cubit<BankAccountState> {
bankName: 'New Bank', // Mock bankName: 'New Bank', // Mock
accountNumber: accountNumber, accountNumber: accountNumber,
accountName: '', accountName: '',
sortCode: routingNumber,
type: type == 'CHECKING' ? BankAccountType.checking : BankAccountType.savings, type: type == 'CHECKING' ? BankAccountType.checking : BankAccountType.savings,
last4: accountNumber.length > 4 ? accountNumber.substring(accountNumber.length - 4) : accountNumber, last4: accountNumber.length > 4 ? accountNumber.substring(accountNumber.length - 4) : accountNumber,
isPrimary: false, isPrimary: false,

View File

@@ -206,7 +206,11 @@ class BankAccountPage extends StatelessWidget {
), ),
), ),
Text( Text(
strings.account_ending(last4: account.last4), strings.account_ending(
last4: account.last4?.isNotEmpty == true
? account.last4!
: '----',
),
style: UiTypography.body2r.copyWith( // Was body2 style: UiTypography.body2r.copyWith( // Was body2
color: UiColors.textSecondary, color: UiColors.textSecondary,
), ),