initial commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "db/database_manager.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace radiantwave::sync {
|
||||
|
||||
// Parse the JSON payload returned by the proclamations endpoint.
|
||||
// Strips HTML from the content body. Returns false on malformed input.
|
||||
bool parseProclamationsJson(const std::string& body,
|
||||
std::vector<radiantwave::db::ProclamationRecord>& out);
|
||||
|
||||
// Parse the JSON payload returned by the categories endpoint.
|
||||
bool parseCategoriesJson(const std::string& body,
|
||||
std::vector<radiantwave::db::ProclamationCategoryRecord>& out);
|
||||
|
||||
// Fetches proclamations + categories from the API and stores them in the DB,
|
||||
// preserving any existing selection and forcing `defaultProclamationId` to
|
||||
// stay selected. Returns true only if the API sync succeeded; on failure the
|
||||
// database is left untouched so the app can fall back to cached data.
|
||||
bool syncProclamationsFromApi(radiantwave::db::DatabaseManager& db,
|
||||
const std::string& defaultProclamationId);
|
||||
|
||||
// Parse color palettes embedded in the proclamations JSON payload. Each
|
||||
// proclamation object may carry a "colorPalette" array of "#RRGGBB" strings;
|
||||
// the palette is keyed by the proclamation's solfeggioFrequencyId. When
|
||||
// several proclamations share a frequency, the first occurrence wins. Returns
|
||||
// false on malformed input.
|
||||
bool parseProclamationPalettesJson(const std::string& body,
|
||||
std::vector<radiantwave::db::PaletteRecord>& out);
|
||||
|
||||
// Fetch the standalone /color-palettes route and replace the local palette
|
||||
// table (the portal is the source of truth). Returns true only on HTTP 2xx +
|
||||
// successful parse + successful replace.
|
||||
//
|
||||
// NOTE: not yet wired into the app flow — the portal does not expose the route
|
||||
// yet. Readiness code: palettes should be updated from the portal, not code
|
||||
// releases, so callers should treat this as a future sync step.
|
||||
bool syncColorPalettesFromApi(radiantwave::db::DatabaseManager& db,
|
||||
const std::string& apiKey = "");
|
||||
|
||||
// Alternative to syncColorPalettesFromApi: fetch proclamations and replace the
|
||||
// local palette table using the palettes embedded in each proclamation.
|
||||
// NOTE: not yet wired into the app flow; see syncColorPalettesFromApi.
|
||||
bool syncProclamationPalettesFromApi(radiantwave::db::DatabaseManager& db,
|
||||
const std::string& apiKey = "");
|
||||
|
||||
} // namespace radiantwave::sync
|
||||
Reference in New Issue
Block a user