From 0477ab5349e972b84c3efa38d9b2296ec570580e Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Tue, 16 Nov 2021 15:57:57 -0800 Subject: [PATCH] Adding preferences. --- src/storage/storage_preferences.cpp | 6 +++--- test_scripts/curl/cli | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/storage/storage_preferences.cpp b/src/storage/storage_preferences.cpp index 3df146e..9c4478a 100644 --- a/src/storage/storage_preferences.cpp +++ b/src/storage/storage_preferences.cpp @@ -9,13 +9,13 @@ namespace OpenWifi { void Convert(const PreferencesRecord &R,SecurityObjects::Preferences &P ) { P.id = R.get<0>(); P.modified = R.get<1>(); - P.data = RESTAPI_utils::to_stringpair_array(R.get<2>()); + OpenWifi::Types::from_string(R.get<2>(), P.data); } void Convert(const SecurityObjects::Preferences &P, PreferencesRecord &R ) { R.set<0>(P.id); R.set<1>(P.modified); - R.set<2>(RESTAPI_utils::to_string(P.data)); + R.set<2>(OpenWifi::Types::to_string(P.data)); } bool Storage::GetPreferences(std::string &Id, SecurityObjects::Preferences &P) { @@ -51,7 +51,7 @@ namespace OpenWifi { }; P.modified = time(nullptr); - std::string Data = RESTAPI_utils::to_string(P.data); + std::string Data = OpenWifi::Types::to_string(P.data); InsertOrUpdate << ConvertParams(InsertOrReplace), Poco::Data::Keywords::use(P.id), diff --git a/test_scripts/curl/cli b/test_scripts/curl/cli index 0ba9a00..8e25bb6 100755 --- a/test_scripts/curl/cli +++ b/test_scripts/curl/cli @@ -263,7 +263,7 @@ sendsms() { } setpreferences() { - payload="{ \"data\" : [ { \"name\" : \"$1\" , \"value\" : \"$2\" }] }" + payload="{ \"data\" : [ [ \"$1\" , \"$2\" ] ] }" curl ${FLAGS} -X PUT "https://${OWSEC}/api/v1/preferences" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${token}" \ @@ -274,7 +274,7 @@ setpreferences() { getpreferences() { curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/preferences" \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer ${token}" ${result_file} + -H "Authorization: Bearer ${token}" > ${result_file} jq < ${result_file} }