MagicTheGathering / mtg-sdk-java

Magic: The Gathering SDK - Java
MIT License
69 stars 24 forks source link

Fix queries with results spanning multiple pages #17

Closed BeMacized closed 7 years ago

BeMacized commented 7 years ago

CardAPI.getAllCards() can throw an error when using filters and the results span multiple "pages", due to incorrect parsing of the "page" parameter.

Parsing the URL correctly fixes this issue.

This issue is reproducible as follows:

import io.magicthegathering.javasdk.api.CardAPI;
import io.magicthegathering.javasdk.resource.Card;

import java.util.ArrayList;
import java.util.List;

public class Test {

    public static void main(String[] args) {
        List<String> filters = new ArrayList<>();
        filters.add("types=artifact,creature");
        List<Card> cards = CardAPI.getAllCards(filters);
        System.out.println(String.format("Found %s cards", cards.size()));
    }

}