From c9ce173efffa097594042ecc657d7acb4551ca22 Mon Sep 17 00:00:00 2001 From: Jay Horsfall Date: Thu, 8 Dec 2022 16:38:10 -0500 Subject: [PATCH 1/6] added query parameter to driver --- example/pubspec.lock | 35 +++++++++++++++++++++-------------- lib/src/pokemon_tcg.dart | 3 ++- pubspec.lock | 37 ++++++++++++++++++++++--------------- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 466ebdc..fdac08e 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,7 +21,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.1" charcode: dependency: transitive description: @@ -35,14 +35,14 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -87,21 +87,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" pedantic: dependency: transitive description: @@ -127,7 +134,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -148,21 +155,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.12" typed_data: dependency: transitive description: @@ -176,7 +183,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" sdks: - dart: ">=2.13.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=1.17.0" diff --git a/lib/src/pokemon_tcg.dart b/lib/src/pokemon_tcg.dart index 507ad52..707282e 100644 --- a/lib/src/pokemon_tcg.dart +++ b/lib/src/pokemon_tcg.dart @@ -24,11 +24,12 @@ class PokemonTcgApi { /// Gets a paginated list of all pokemon cards. Future> getCards({ int page = 0, + String query = '', }) async { http.Response response; if (page == 0) { response = await client.get( - Uri.parse('$_baseUrl/cards'), + Uri.parse('$_baseUrl/cards?q=$query'), headers: { 'x-api-key': apiKey, }, diff --git a/pubspec.lock b/pubspec.lock index f370283..9ee04dc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -14,7 +14,7 @@ packages: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "1.7.1" + version: "1.7.2" args: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.1" charcode: dependency: transitive description: @@ -84,7 +84,7 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" code_builder: dependency: transitive description: @@ -98,7 +98,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" convert: dependency: transitive description: @@ -126,7 +126,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" file: dependency: transitive description: @@ -185,14 +185,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.8.0" mockito: dependency: "direct dev" description: @@ -213,7 +220,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" pedantic: dependency: transitive description: @@ -246,7 +253,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -267,21 +274,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.12" typed_data: dependency: transitive description: @@ -295,7 +302,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" watcher: dependency: transitive description: @@ -311,5 +318,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.13.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=1.17.0" From 91c51921ea8a42c3df1219f2e16d43d0b76cda12 Mon Sep 17 00:00:00 2001 From: Jay Horsfall Date: Thu, 8 Dec 2022 16:39:36 -0500 Subject: [PATCH 2/6] added query parameter to driver --- lib/src/pokemon_tcg.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/pokemon_tcg.dart b/lib/src/pokemon_tcg.dart index 707282e..7c51f72 100644 --- a/lib/src/pokemon_tcg.dart +++ b/lib/src/pokemon_tcg.dart @@ -36,7 +36,7 @@ class PokemonTcgApi { ); } else { response = await client.get( - Uri.parse('$_baseUrl/cards?page=$page'), + Uri.parse('$_baseUrl/cards?q=$query&page=$page'), headers: { 'x-api-key': apiKey, }, From 6648d13daa840ffbbd56fc63cebae967661a10a2 Mon Sep 17 00:00:00 2001 From: Jay Horsfall Date: Thu, 8 Dec 2022 16:50:23 -0500 Subject: [PATCH 3/6] maybe error handling? --- lib/src/pokemon_tcg.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/pokemon_tcg.dart b/lib/src/pokemon_tcg.dart index 7c51f72..fb399bf 100644 --- a/lib/src/pokemon_tcg.dart +++ b/lib/src/pokemon_tcg.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:isolate'; import 'package:http/http.dart' as http; import 'package:pokemon_tcg/src/models/card.dart'; @@ -21,7 +22,7 @@ class PokemonTcgApi { static const _baseUrl = 'https://api.pokemontcg.io/v2'; static const _setsUrl = '$_baseUrl/sets'; - /// Gets a paginated list of all pokemon cards. + /// Gets a paginated list of all pokemon cards by default, with an optional search parameter. Future> getCards({ int page = 0, String query = '', @@ -44,6 +45,9 @@ class PokemonTcgApi { } JsonMap json = jsonDecode(response.body); + if (json['error']) { + throw RemoteError('Invalid search parameter', json['error']); + } final cards = []; List cardsJson = json['data']; cardsJson.forEach((element) { From e610a8537cda4334b3a3a005f4082929a4f69010 Mon Sep 17 00:00:00 2001 From: Jay Horsfall <56010637+JayHors@users.noreply.github.com> Date: Tue, 23 May 2023 03:56:16 -0400 Subject: [PATCH 4/6] Update lib/src/pokemon_tcg.dart Co-authored-by: Bart Ribbers --- lib/src/pokemon_tcg.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/pokemon_tcg.dart b/lib/src/pokemon_tcg.dart index fb399bf..8a470cd 100644 --- a/lib/src/pokemon_tcg.dart +++ b/lib/src/pokemon_tcg.dart @@ -45,7 +45,7 @@ class PokemonTcgApi { } JsonMap json = jsonDecode(response.body); - if (json['error']) { + if (json.containsKey("error")) { throw RemoteError('Invalid search parameter', json['error']); } final cards = []; From b12759b89c8c5a7ed00cf0c67431f225c2d85d4b Mon Sep 17 00:00:00 2001 From: Jay Horsfall <56010637+JayHors@users.noreply.github.com> Date: Tue, 23 May 2023 09:06:36 -0400 Subject: [PATCH 5/6] Update lib/src/pokemon_tcg.dart Co-authored-by: Bart Ribbers --- lib/src/pokemon_tcg.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/pokemon_tcg.dart b/lib/src/pokemon_tcg.dart index 8a470cd..e6406dd 100644 --- a/lib/src/pokemon_tcg.dart +++ b/lib/src/pokemon_tcg.dart @@ -46,7 +46,7 @@ class PokemonTcgApi { JsonMap json = jsonDecode(response.body); if (json.containsKey("error")) { - throw RemoteError('Invalid search parameter', json['error']); + throw RemoteError('Invalid search parameter', json['error']['message']); } final cards = []; List cardsJson = json['data']; From a72aa4cbdd378c8eb7801dc77a03e3afb8ebfd6c Mon Sep 17 00:00:00 2001 From: Jay Horsfall Date: Tue, 3 Oct 2023 15:45:03 -0400 Subject: [PATCH 6/6] bump version and add changelog --- CHANGELOG.md | 7 +++++++ example/pubspec.lock | 2 +- pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7724cad..e4a5b63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,19 @@ +## 1.0.2 + +* Added search parameter + ## 1.0.1 + * Refactor tests * Export data models ## 1.0.0 + * All endpoints implemented 🎉 * Make some fields nullable in card.dart ## 0.3.0 + * Add `getCard()` functions ## 0.2.0 diff --git a/example/pubspec.lock b/example/pubspec.lock index fdac08e..6cc3f05 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -122,7 +122,7 @@ packages: path: ".." relative: true source: path - version: "1.0.1" + version: "1.0.2" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index fa77cfa..8ee14f1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pokemon_tcg description: A Dart SDK for the Pokemon TCG Developers API. An API key is required to use. -version: 1.0.1 +version: 1.0.2 homepage: https://github.com/PokemonTCG/pokemon-tcg-sdk-dart issue_tracker: https://github.com/PokemonTCG/pokemon-tcg-sdk-dart/issues