53 lines
1.9 KiB
C++
53 lines
1.9 KiB
C++
#ifndef Pudding_h_
|
|
#define Pudding_h_
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <type_traits>
|
|
#include <filesystem>
|
|
#include <curl/curl.h>
|
|
#include "SDL.h"
|
|
#include "json/json.hpp"
|
|
#include "glm/vec2.hpp"
|
|
#include "Game.hpp"
|
|
#include "Sprite.hpp"
|
|
#include "Color.hpp"
|
|
#include "extension.hpp"
|
|
#include "Item.hpp"
|
|
|
|
struct Pudding : Game
|
|
{
|
|
|
|
const std::string OPEN_FOOD_API_URL = "https://world.openfoodfacts.org/api/v0/product/";
|
|
const std::string NUTRONIX_API_URL = "https://trackapi.nutritionix.com/v2/search/item?upc=";
|
|
const std::string EDAMAM_API_URL = "https://api.edamam.com/api/food-database/v2/parser?upc=&app_id=&app_key=";
|
|
const std::string BARCODE_MONSTER_API_URL = "https://barcode.monster/api/";
|
|
const std::string BEST_BUY_API_URL = "https://api.bestbuy.com/v1/products(upc=)?format=json&apiKey=";
|
|
const std::string NUTRONIX_NOT_FOUND = "resource not found";
|
|
|
|
/*
|
|
* images, ingredients, protein weight, nutrition grade, popularity, "serving unit", item name, brand name, keywords,
|
|
* allergens, calories, fat, saturated fat, cholesterol, sodium, carbohydrates, fiber, sugar, potassium
|
|
*/
|
|
|
|
typedef Game super;
|
|
std::string current_barcode;
|
|
std::vector<Item> items;
|
|
|
|
Pudding();
|
|
void load_sdl_context();
|
|
void add_item(const std::string&);
|
|
void incorporate_open_food_api(Item&);
|
|
void incorporate_nutronix_api(Item&);
|
|
void save_item_json(const nlohmann::json&, const Item&, const std::string&);
|
|
nlohmann::json json_from_url(const std::string&, const std::vector<std::string>& = {});
|
|
void curl_get_bytes(const std::string& url, std::vector<std::uint8_t>&, const std::vector<std::string>& = {});
|
|
static size_t curl_write_response(std::uint8_t*, size_t, size_t, std::vector<std::uint8_t>*);
|
|
SDL_Texture* texture_from_image_url(const std::string&);
|
|
void update();
|
|
std::string get_class_name() { return "Pudding"; }
|
|
|
|
};
|
|
|
|
#endif
|