Set API page limit
This commit is contained in:
parent
74aabeddbd
commit
bc6a89e4b3
|
|
@ -1,4 +1,5 @@
|
||||||
// This version must be updated in tandem with the pubspec version.
|
// This version must be updated in tandem with the pubspec version.
|
||||||
const String kAppVersion = '0.0.1';
|
const String kAppVersion = '0.0.1';
|
||||||
|
|
||||||
|
const int kMaxRecordsPerApiPage = 5000;
|
||||||
const int kMillisecondsToRefreshData = 1000 * 60 * 15; // 15 minutes
|
const int kMillisecondsToRefreshData = 1000 * 60 * 15; // 15 minutes
|
||||||
|
|
@ -18,7 +18,7 @@ class ClientRepository {
|
||||||
Future<BuiltList<ClientEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
Future<BuiltList<ClientEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||||
|
|
||||||
final response = await webClient.get(
|
final response = await webClient.get(
|
||||||
auth.url + '/clients?per_page=500', company.token);
|
auth.url + '/clients', company.token);
|
||||||
|
|
||||||
ClientListResponse clientResponse = serializers.deserializeWith(
|
ClientListResponse clientResponse = serializers.deserializeWith(
|
||||||
ClientListResponse.serializer, response);
|
ClientListResponse.serializer, response);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class InvoiceRepository {
|
||||||
Future<BuiltList<InvoiceEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
Future<BuiltList<InvoiceEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||||
|
|
||||||
final response = await webClient.get(
|
final response = await webClient.get(
|
||||||
auth.url + '/invoices?include=invitations&per_page=500', company.token);
|
auth.url + '/invoices?include=invitations', company.token);
|
||||||
|
|
||||||
InvoiceListResponse invoiceResponse = serializers.deserializeWith(
|
InvoiceListResponse invoiceResponse = serializers.deserializeWith(
|
||||||
InvoiceListResponse.serializer, response);
|
InvoiceListResponse.serializer, response);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class ProductRepository {
|
||||||
Future<BuiltList<ProductEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
Future<BuiltList<ProductEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||||
|
|
||||||
final response = await webClient.get(
|
final response = await webClient.get(
|
||||||
auth.url + '/products?per_page=500', company.token);
|
auth.url + '/products', company.token);
|
||||||
|
|
||||||
ProductListResponse productResponse = serializers.deserializeWith(
|
ProductListResponse productResponse = serializers.deserializeWith(
|
||||||
ProductListResponse.serializer, response);
|
ProductListResponse.serializer, response);
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,17 @@ import 'dart:async';
|
||||||
import 'dart:core';
|
import 'dart:core';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:invoiceninja/constants.dart';
|
||||||
|
|
||||||
class WebClient {
|
class WebClient {
|
||||||
|
|
||||||
const WebClient();
|
const WebClient();
|
||||||
|
|
||||||
Future<dynamic> get(String url, String token) async {
|
Future<dynamic> get(String url, String token) async {
|
||||||
|
|
||||||
|
if (! url.contains('?')) url += '?';
|
||||||
|
url += '&per_page=${kMaxRecordsPerApiPage}';
|
||||||
|
|
||||||
final http.Response response = await http.Client().get(
|
final http.Response response = await http.Client().get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue