aboutsummaryrefslogtreecommitdiff
path: root/oop2eindopdr/PokemonTCGAPIClient.h
blob: 991042538011965e80c76191831f8fd2dfa6ff0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include <nlohmann/json.hpp>
#include <cpr/cpr.h>

#include "PokemonCard.h"

/** @brief direct api access class */
class PokemonTCGAPIClient {
public:
	PokemonTCGAPIClient();
	virtual ~PokemonTCGAPIClient();

private:
	const char* API_URL = "https://api.pokemontcg.io/v2";
	/**
	 * @brief send http(s) GET request to `endpoint` with `params` and return the
	 * response as parsed JSON
	 */
	virtual nlohmann::json raw_request(const char* endpoint, cpr::Parameters params);
	/** @brief get minimal card info for parsing into card (no trading value) */
	virtual nlohmann::json raw_get_cards(const char* query);
	/** @brief get full card info by card id */
	virtual nlohmann::json raw_get_card(const char* id);
	/** @brief get list of valid sets */
	virtual nlohmann::json raw_get_sets(const char* query);

public:
	/** @brief get list of cards that contain `query` in name or id field */
	virtual std::vector<PokemonCard*> get_cards_by_query(const char* query);
	/** @brief get list of cards in set */
	virtual std::vector<PokemonCard*> get_set_cards(const char* set_name);
	/** @brief get full card info by card id */
	virtual PokemonCard* get_full_card(const char* id);
	/** @brief get list of valid sets */
	virtual std::vector<std::string> get_sets();
};