MCPcopy Create free account
hub / github.com/comaps/comaps / CreateNote

Method CreateNote

libs/editor/server_api.cpp:125–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125uint64_t ServerApi06::CreateNote(ms::LatLon const & ll, std::string const & message) const
126{
127 CHECK(!message.empty(), ("Note content should not be empty."));
128 std::string const params =
129 "?lat=" + strings::to_string_dac(ll.m_lat, 7) + "&lon=" + strings::to_string_dac(ll.m_lon, 7) +
130 "&text=" + url::UrlEncode(message + " #CoMaps " + OMIM_OS_NAME + " " + GetPlatform().Version());
131 OsmOAuth::Response const response = m_auth.Request("/notes" + params, "POST");
132 if (response.first != OsmOAuth::HTTP::OK)
133 MYTHROW(ErrorAddingNote, ("Could not post a new note:", response));
134 pugi::xml_document details;
135 if (!details.load_string(response.second.c_str()))
136 MYTHROW(CantParseServerResponse, ("Could not parse a note XML response", response));
137 pugi::xml_node const uid = details.child("osm").child("note").child("id");
138 if (!uid)
139 MYTHROW(CantParseServerResponse, ("Caould not find a note id", response));
140 return uid.text().as_ullong();
141}
142
143void ServerApi06::CloseNote(uint64_t const id) const
144{

Callers 5

UNIT_TESTFunction · 0.45
CreateNoteTestMethod · 0.45
SaveTransactionTestMethod · 0.45
UNIT_TESTFunction · 0.45

Calls 5

to_string_dacFunction · 0.85
UrlEncodeFunction · 0.85
VersionMethod · 0.80
RequestMethod · 0.80
emptyMethod · 0.45

Tested by 5

UNIT_TESTFunction · 0.36
CreateNoteTestMethod · 0.36
SaveTransactionTestMethod · 0.36
UNIT_TESTFunction · 0.36