Refactor
This commit is contained in:
parent
e87065613c
commit
9de2e83101
|
|
@ -75,7 +75,7 @@ class CompanyGatewayRepository {
|
||||||
var url = credentials.url +
|
var url = credentials.url +
|
||||||
'/company_gateways/${companyGateway.id}?include=gateway';
|
'/company_gateways/${companyGateway.id}?include=gateway';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class CreditRepository {
|
||||||
} else {
|
} else {
|
||||||
var url = '${credentials.url}/credits/${credit.id}?';
|
var url = '${credentials.url}/credits/${credit.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=$action';
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,9 @@ class DesignRepository {
|
||||||
credentials.url + '/designs', credentials.token,
|
credentials.url + '/designs', credentials.token,
|
||||||
data: json.encode(data));
|
data: json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = credentials.url + '/designs/' + design.id.toString();
|
var url = credentials.url + '/designs/${design.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -76,12 +76,12 @@ class DocumentRepository {
|
||||||
} else {
|
} else {
|
||||||
final data =
|
final data =
|
||||||
serializers.serializeWith(DocumentEntity.serializer, document);
|
serializers.serializeWith(DocumentEntity.serializer, document);
|
||||||
var url = '${credentials.url}/documents/${document.id}';
|
var url = '${credentials.url}/documents/${document.id}?';
|
||||||
if (action == EntityAction.delete) {
|
if (action == EntityAction.delete) {
|
||||||
response = await webClient.delete(url, credentials.token);
|
response = await webClient.delete(url, credentials.token);
|
||||||
} else {
|
} else {
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=$action';
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, credentials.token,
|
response = await webClient.put(url, credentials.token,
|
||||||
data: json.encode(data));
|
data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,9 @@ class ExpenseRepository {
|
||||||
credentials.url + '/expenses', credentials.token,
|
credentials.url + '/expenses', credentials.token,
|
||||||
data: json.encode(data));
|
data: json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = credentials.url + '/expenses/' + expense.id.toString();
|
var url = credentials.url + '/expenses/${expense.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,9 @@ class GroupRepository {
|
||||||
credentials.url + '/group_settings', credentials.token,
|
credentials.url + '/group_settings', credentials.token,
|
||||||
data: json.encode(data));
|
data: json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = credentials.url + '/group_settings/' + group.id.toString();
|
var url = credentials.url + '/group_settings/${group.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=$action';
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class InvoiceRepository {
|
||||||
Credentials credentials, List<String> ids, EntityAction action) async {
|
Credentials credentials, List<String> ids, EntityAction action) async {
|
||||||
var url = credentials.url + '/invoices/bulk?';
|
var url = credentials.url + '/invoices/bulk?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '&action=' + action.toString();
|
url += 'action=' + action.toString();
|
||||||
}
|
}
|
||||||
final dynamic response = await webClient.post(url, credentials.token,
|
final dynamic response = await webClient.post(url, credentials.token,
|
||||||
data: json.encode({'ids': ids}));
|
data: json.encode({'ids': ids}));
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,9 @@ class ProductRepository {
|
||||||
credentials.url + '/products', credentials.token,
|
credentials.url + '/products', credentials.token,
|
||||||
data: json.encode(data));
|
data: json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = credentials.url + '/products/' + product.id.toString();
|
var url = credentials.url + '/products/${product.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,9 @@ class ProjectRepository {
|
||||||
credentials.url + '/projects', credentials.token,
|
credentials.url + '/projects', credentials.token,
|
||||||
data: json.encode(data));
|
data: json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = credentials.url + '/projects/' + project.id.toString();
|
var url = credentials.url + '/projects/${project.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class QuoteRepository {
|
||||||
} else {
|
} else {
|
||||||
var url = '${credentials.url}/quotes/${quote.id}?';
|
var url = '${credentials.url}/quotes/${quote.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,9 @@ class TaskRepository {
|
||||||
credentials.url + '/tasks', credentials.token,
|
credentials.url + '/tasks', credentials.token,
|
||||||
data: json.encode(data));
|
data: json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = credentials.url + '/tasks/' + task.id.toString();
|
var url = credentials.url + '/tasks/${task.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,9 @@ class TaxRateRepository {
|
||||||
credentials.url + '/tax_rates', credentials.token,
|
credentials.url + '/tax_rates', credentials.token,
|
||||||
data: json.encode(data));
|
data: json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = credentials.url + '/tax_rates/' + taxRate.id.toString();
|
var url = credentials.url + '/tax_rates/${taxRate.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=$action';
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -83,9 +83,9 @@ class UserRepository {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
var url = credentials.url +
|
var url = credentials.url +
|
||||||
'/users/${user.id}?include=company_user&password=$password';
|
'/users/${user.id}?include=company_user';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=$action';
|
||||||
}
|
}
|
||||||
response = await webClient.put(
|
response = await webClient.put(
|
||||||
url,
|
url,
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,9 @@ class VendorRepository {
|
||||||
credentials.url + '/vendors', credentials.token,
|
credentials.url + '/vendors', credentials.token,
|
||||||
data: json.encode(data));
|
data: json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = credentials.url + '/vendors/' + vendor.id.toString();
|
var url = credentials.url + '/vendors/${vendor.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response =
|
response =
|
||||||
await webClient.put(url, credentials.token, data: json.encode(data));
|
await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
|
|
|
||||||
|
|
@ -503,7 +503,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
//return 'Currency Map: ${staticState.currencyMap}';
|
//return 'Currency Map: ${staticState.currencyMap}';
|
||||||
//return 'History: $historyList';
|
//return 'History: $historyList';
|
||||||
//return 'Use inclusive: ${invoiceUIState.editing.usesInclusiveTaxes}';
|
//return 'Use inclusive: ${invoiceUIState.editing.usesInclusiveTaxes}';
|
||||||
//return 'Invitations: ${invoiceUIState.editing.invitations}';
|
return 'Invitations: ${invoiceUIState.editing.invitations}';
|
||||||
//return 'Token: ${userCompanyStates.map((state) => state.token.token).where((name) => name.isNotEmpty).toList().join(', ')}';
|
//return 'Token: ${userCompanyStates.map((state) => state.token.token).where((name) => name.isNotEmpty).toList().join(', ')}';
|
||||||
//return 'Settings: ${company.settings.companyLogo}';
|
//return 'Settings: ${company.settings.companyLogo}';
|
||||||
//return 'Designs: ${company.designs}';
|
//return 'Designs: ${company.designs}';
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,9 @@ class StubRepository {
|
||||||
credentials.token,
|
credentials.token,
|
||||||
data: json.encode(data));
|
data: json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = credentials.url + '/stubs/' + stub.id.toString();
|
var url = '${credentials.url}/stubs/${stub.id}?';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '&action=$action';
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, credentials.token, data: json.encode(data));
|
response = await webClient.put(url, credentials.token, data: json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue