MCPcopy Create free account
hub / github.com/audacity/audacity / GetEffects

Function GetEffects

libraries/lib-musehub/MuseHubService.cpp:132–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void GetEffects(std::function<void(std::vector<EffectsGroup>)> callback)
133{
134 using namespace audacity::network_manager;
135 using rapidjson::StringRef;
136
137 // TODO Get locale
138 const std::string locale = "en-EN";
139
140 rapidjson::Document jsonDoc;
141 jsonDoc.SetObject();
142 auto& allocator = jsonDoc.GetAllocator();
143 jsonDoc.AddMember("query", rapidjson::Value(getEffectsQuery.c_str(), allocator), allocator);
144
145 rapidjson::Value variables(rapidjson::kObjectType);
146 variables.AddMember("locale", rapidjson::Value(locale.c_str(), allocator), allocator);
147 jsonDoc.AddMember("variables", variables, allocator);
148
149 rapidjson::StringBuffer buffer;
150 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
151 jsonDoc.Accept(writer);
152
153 Request request(GetMusehubAPIEndpoint());
154 request.setHeader(common_headers::ContentType, common_content_types::ApplicationJson);
155 request.setHeader(common_headers::Accept, common_content_types::ApplicationJson);
156
157 auto response = NetworkManager::GetInstance().doPost(request, buffer.GetString(), buffer.GetSize());
158
159 response->setRequestFinishedCallback([response, callback](auto) {
160 const auto httpCode = response->getHTTPCode();
161 const auto body = response->readAll<std::string>();
162
163 if(httpCode != HttpCode::OK) {
164 callback({});
165 return;
166 }
167
168 rapidjson::Document document;
169 document.Parse(body.c_str(), body.size());
170
171 if (document.HasParseError() || !document.IsObject()) {
172 callback({});
173 return;
174 }
175
176 auto groups = parseProductPages(document);
177 callback(groups);
178 });
179}
180
181std::string GetBecomeAPartnerUrl()
182{

Callers 1

ReloadEffectListMethod · 0.85

Calls 12

GetMusehubAPIEndpointFunction · 0.85
callbackFunction · 0.85
parseProductPagesFunction · 0.85
setHeaderMethod · 0.80
doPostMethod · 0.80
c_strMethod · 0.45
GetStringMethod · 0.45
GetSizeMethod · 0.45
getHTTPCodeMethod · 0.45
ParseMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected