M module-services/service-desktop/endpoints/contacts/ContactHelper.cpp => module-services/service-desktop/endpoints/contacts/ContactHelper.cpp +8 -0
@@ 41,9 41,13 @@ auto ContactHelper::to_json(const ContactRecord &record) -> json11::Json
auto recordEntry = json11::Json::object{{json::contacts::primaryName, record.primaryName.c_str()},
{json::contacts::alternativeName, record.alternativeName.c_str()},
{json::contacts::address, record.address.c_str()},
+ {json::contacts::mail, record.mail.c_str()},
+ {json::contacts::note, record.note.c_str()},
{json::contacts::id, static_cast<int>(record.ID)},
{json::contacts::isBlocked, record.isOnBlocked()},
{json::contacts::isFavourite, record.isOnFavourites()},
+ {json::contacts::isICE, record.isOnIce()},
+ {json::contacts::speedDial, record.speeddial.c_str()},
{json::contacts::numbers, numberArray}};
return recordEntry;
}
@@ 55,6 59,9 @@ auto ContactHelper::from_json(const json11::Json &contactJSON) -> ContactRecord
newRecord.ID = contactJSON[json::contacts::id].int_value();
newRecord.alternativeName = UTF8(contactJSON[json::contacts::alternativeName].string_value());
newRecord.address = UTF8(contactJSON[json::contacts::address].string_value());
+ newRecord.mail = UTF8(contactJSON[json::contacts::mail].string_value());
+ newRecord.note = UTF8(contactJSON[json::contacts::note].string_value());
+ newRecord.speeddial = UTF8(contactJSON[json::contacts::speedDial].string_value());
for (const auto &num : contactJSON[json::contacts::numbers].array_items()) {
utils::PhoneNumber phoneNumber(num.string_value());
@@ 64,6 71,7 @@ auto ContactHelper::from_json(const json11::Json &contactJSON) -> ContactRecord
newRecord.addToBlocked(contactJSON[json::contacts::isBlocked].bool_value());
newRecord.addToFavourites(contactJSON[json::contacts::isFavourite].bool_value());
+ newRecord.addToIce(contactJSON[json::contacts::isICE].bool_value());
return newRecord;
}
M module-services/service-desktop/endpoints/contacts/ContactHelper.hpp => module-services/service-desktop/endpoints/contacts/ContactHelper.hpp +4 -0
@@ 49,10 49,14 @@ namespace parserFSM
inline constexpr auto primaryName = "priName";
inline constexpr auto alternativeName = "altName";
inline constexpr auto address = "address";
+ inline constexpr auto note = "note";
+ inline constexpr auto mail = "email";
inline constexpr auto id = "id";
inline constexpr auto numbers = "numbers";
inline constexpr auto isBlocked = "blocked";
inline constexpr auto isFavourite = "favourite";
+ inline constexpr auto isICE = "ice";
+ inline constexpr auto speedDial = "speedDial";
inline constexpr auto count = "count";
} // namespace json::contacts
M test/pytest/service-desktop/test_contacts.py => test/pytest/service-desktop/test_contacts.py +12 -2
@@ 59,8 59,10 @@ def test_contacts(harness):
# adding new contact
body = {"address": "6 Czeczota St.\n02600 Warsaw",
"altName": "Testowy",
+ "email": "testowy.2@example.com",
"blocked": True,
"favourite": True,
+ "ice": False,
"numbers": ["547623521"],
"priName": "Test"}
ret = harness.endpoint_request("contacts", "post", body)
@@ 87,10 89,14 @@ def test_contacts(harness):
# updating existing contact
body = {"address": "6 Czeczota St.\n02600 Warsaw",
"altName": "Testowy2",
- "blocked": True,
+ "email": "testowy.2@example.com",
+ "blocked": False,
"favourite": True,
+ "ice": True,
"numbers": ["547623521"],
+ "speedDial": "7",
"priName": "Test2",
+ "note": "this is a really cool guy",
"id": contact_id_to_update}
ret = harness.endpoint_request("contacts", "put", body)
assert ret["status"] == status["NoContent"]
@@ 100,10 106,14 @@ def test_contacts(harness):
ret = harness.endpoint_request("contacts", "get", body)
contact = {"address": "6 Czeczota St.\n02600 Warsaw",
"altName": "Testowy2",
- "blocked": True,
+ "email": "testowy.2@example.com",
+ "blocked": False,
"favourite": True,
+ "ice": True,
"numbers": ["547623521"],
+ "speedDial": "7",
"priName": "Test2",
+ "note": "this is a really cool guy",
"id": contact_id_to_update}
assert ret["body"] == contact
M test/requirements.txt => test/requirements.txt +2 -0
@@ 8,3 8,5 @@ pyserial==3.5
pytest==6.1.2
six==1.15.0
toml==0.10.2
+inotify==0.2.10
+dataclasses_json==0.5.4