Set API page limit

This commit is contained in:
unknown 2018-06-26 11:08:55 -07:00
parent 74aabeddbd
commit bc6a89e4b3
5 changed files with 9 additions and 3 deletions

View File

@ -1,4 +1,5 @@
// This version must be updated in tandem with the pubspec version.
const String kAppVersion = '0.0.1';
const int kMaxRecordsPerApiPage = 5000;
const int kMillisecondsToRefreshData = 1000 * 60 * 15; // 15 minutes

View File

@ -18,7 +18,7 @@ class ClientRepository {
Future<BuiltList<ClientEntity>> loadList(CompanyEntity company, AuthState auth) async {
final response = await webClient.get(
auth.url + '/clients?per_page=500', company.token);
auth.url + '/clients', company.token);
ClientListResponse clientResponse = serializers.deserializeWith(
ClientListResponse.serializer, response);

View File

@ -18,7 +18,7 @@ class InvoiceRepository {
Future<BuiltList<InvoiceEntity>> loadList(CompanyEntity company, AuthState auth) async {
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.serializer, response);

View File

@ -18,7 +18,7 @@ class ProductRepository {
Future<BuiltList<ProductEntity>> loadList(CompanyEntity company, AuthState auth) async {
final response = await webClient.get(
auth.url + '/products?per_page=500', company.token);
auth.url + '/products', company.token);
ProductListResponse productResponse = serializers.deserializeWith(
ProductListResponse.serializer, response);

View File

@ -2,12 +2,17 @@ import 'dart:async';
import 'dart:core';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:invoiceninja/constants.dart';
class WebClient {
const WebClient();
Future<dynamic> get(String url, String token) async {
if (! url.contains('?')) url += '?';
url += '&per_page=${kMaxRecordsPerApiPage}';
final http.Response response = await http.Client().get(
url,
headers: {