{"action":"created","comment":{"url":"https://api.github.com/repos/mapsme/omim/pulls/comments/82397842","pull_request_review_id":3309981,"id":82397842,"diff_hunk":"@@ -0,0 +1,221 @@\n+#include \"uber_api.hpp\"\n+\n+#include \"platform/http_client.hpp\"\n+\n+#include \"geometry/latlon.hpp\"\n+\n+#include \"base/assert.hpp\"\n+#include \"base/logging.hpp\"\n+#include \"base/thread.hpp\"\n+\n+#include \"std/chrono.hpp\"\n+#include \"std/future.hpp\"\n+\n+#include \"3party/jansson/myjansson.hpp\"\n+\n+#include \"private.h\"\n+\n+using namespace platform;\n+\n+namespace\n+{\n+string RunSimpleHttpRequest(string const & url)\n+{\n+  HttpClient request(url);\n+  if (request.RunHttpRequest() && !request.WasRedirected() && request.ErrorCode() == 200)\n+  {\n+    return request.ServerResponse();\n+  }\n+  return {};\n+}\n+\n+bool CheckUberAnswer(json_t const * answer)\n+{\n+  // Uber products are not available at this point.\n+  if (!json_is_array(answer))\n+    return false;\n+\n+  if (json_array_size(answer) <= 0)\n+    return false;\n+\n+  return true;\n+}\n+\n+void FillProducts(json_t const * time, json_t const * price, vector<uber::Product> & products)\n+{\n+  // Fill data from time.\n+  auto const timeSize = json_array_size(time);\n+  for (size_t i = 0; i < timeSize; ++i)\n+  {\n+    uber::Product product;\n+    json_int_t estimatedTime = 0;\n+    auto const item = json_array_get(time, i);\n+    my::FromJSONObject(item, \"display_name\", product.m_name);\n+    my::FromJSONObject(item, \"estimate\", estimatedTime);\n+    product.m_time = strings::to_string(estimatedTime);\n+    products.push_back(product);\n+  }\n+\n+  // Fill data from price.\n+  auto const priceSize = json_array_size(price);\n+  for (size_t i = 0; i < priceSize; ++i)\n+  {\n+    string name;\n+    auto const item = json_array_get(price, i);\n+\n+    my::FromJSONObject(item, \"display_name\", name);\n+    auto const it = find_if(products.begin(), products.end(), [&name](uber::Product const & product){\n+      return product.m_name == name;\n+    });\n+    if (it == products.end())\n+      continue;\n+\n+    my::FromJSONObject(item, \"product_id\", it->m_productId);\n+    my::FromJSONObject(item, \"estimate\", it->m_price);\n+\n+    // The field currency_code can contain null in case when price equal to Metered.\n+    auto const currency = json_object_get(item, \"currency_code\");\n+    if (currency != nullptr && !json_is_null(currency))\n+      it->m_currency = json_string_value(currency);\n+  }\n+\n+  products.erase(remove_if(products.begin(), products.end(), [](uber::Product const & p){\n+                   return p.m_name.empty() || p.m_productId.empty() || p.m_time.empty() ||","path":"partners_api/uber_api.cpp","position":83,"original_position":83,"commit_id":"baee0f0d2c9a94ef930d77b79aa3e71a7b409dae","original_commit_id":"baee0f0d2c9a94ef930d77b79aa3e71a7b409dae","user":{"login":"ygorshenin","id":454567,"avatar_url":"https://avatars.githubusercontent.com/u/454567?v=3","gravatar_id":"","url":"https://api.github.com/users/ygorshenin","html_url":"https://github.com/ygorshenin","followers_url":"https://api.github.com/users/ygorshenin/followers","following_url":"https://api.github.com/users/ygorshenin/following{/other_user}","gists_url":"https://api.github.com/users/ygorshenin/gists{/gist_id}","starred_url":"https://api.github.com/users/ygorshenin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ygorshenin/subscriptions","organizations_url":"https://api.github.com/users/ygorshenin/orgs","repos_url":"https://api.github.com/users/ygorshenin/repos","events_url":"https://api.github.com/users/ygorshenin/events{/privacy}","received_events_url":"https://api.github.com/users/ygorshenin/received_events","type":"User","site_admin":false},"body":"Please, create a helper method in uber::Product, like IsIncomplete, and use it here.","created_at":"2016-10-07T14:18:35Z","updated_at":"2016-10-07T14:18:35Z","html_url":"https://github.com/mapsme/omim/pull/4451#discussion_r82397842","pull_request_url":"https://api.github.com/repos/mapsme/omim/pulls/4451","_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments/82397842"},"html":{"href":"https://github.com/mapsme/omim/pull/4451#discussion_r82397842"},"pull_request":{"href":"https://api.github.com/repos/mapsme/omim/pulls/4451"}}},"pull_request":{"url":"https://api.github.com/repos/mapsme/omim/pulls/4451","id":88411764,"html_url":"https://github.com/mapsme/omim/pull/4451","diff_url":"https://github.com/mapsme/omim/pull/4451.diff","patch_url":"https://github.com/mapsme/omim/pull/4451.patch","issue_url":"https://api.github.com/repos/mapsme/omim/issues/4451","number":4451,"state":"open","locked":false,"title":"[core] Uber api","user":{"login":"milchakov","id":2606569,"avatar_url":"https://avatars.githubusercontent.com/u/2606569?v=3","gravatar_id":"","url":"https://api.github.com/users/milchakov","html_url":"https://github.com/milchakov","followers_url":"https://api.github.com/users/milchakov/followers","following_url":"https://api.github.com/users/milchakov/following{/other_user}","gists_url":"https://api.github.com/users/milchakov/gists{/gist_id}","starred_url":"https://api.github.com/users/milchakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milchakov/subscriptions","organizations_url":"https://api.github.com/users/milchakov/orgs","repos_url":"https://api.github.com/users/milchakov/repos","events_url":"https://api.github.com/users/milchakov/events{/privacy}","received_events_url":"https://api.github.com/users/milchakov/received_events","type":"User","site_admin":false},"body":"@ygorshenin \r\n@syershov ","created_at":"2016-10-07T10:05:08Z","updated_at":"2016-10-07T14:18:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"98359b3ea0c946a456ddd918c98e15636b488bda","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mapsme/omim/pulls/4451/commits","review_comments_url":"https://api.github.com/repos/mapsme/omim/pulls/4451/comments","review_comment_url":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapsme/omim/issues/4451/comments","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/baee0f0d2c9a94ef930d77b79aa3e71a7b409dae","head":{"label":"milchakov:uber_core","ref":"uber_core","sha":"baee0f0d2c9a94ef930d77b79aa3e71a7b409dae","user":{"login":"milchakov","id":2606569,"avatar_url":"https://avatars.githubusercontent.com/u/2606569?v=3","gravatar_id":"","url":"https://api.github.com/users/milchakov","html_url":"https://github.com/milchakov","followers_url":"https://api.github.com/users/milchakov/followers","following_url":"https://api.github.com/users/milchakov/following{/other_user}","gists_url":"https://api.github.com/users/milchakov/gists{/gist_id}","starred_url":"https://api.github.com/users/milchakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milchakov/subscriptions","organizations_url":"https://api.github.com/users/milchakov/orgs","repos_url":"https://api.github.com/users/milchakov/repos","events_url":"https://api.github.com/users/milchakov/events{/privacy}","received_events_url":"https://api.github.com/users/milchakov/received_events","type":"User","site_admin":false},"repo":{"id":61498503,"name":"omim","full_name":"milchakov/omim","owner":{"login":"milchakov","id":2606569,"avatar_url":"https://avatars.githubusercontent.com/u/2606569?v=3","gravatar_id":"","url":"https://api.github.com/users/milchakov","html_url":"https://github.com/milchakov","followers_url":"https://api.github.com/users/milchakov/followers","following_url":"https://api.github.com/users/milchakov/following{/other_user}","gists_url":"https://api.github.com/users/milchakov/gists{/gist_id}","starred_url":"https://api.github.com/users/milchakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milchakov/subscriptions","organizations_url":"https://api.github.com/users/milchakov/orgs","repos_url":"https://api.github.com/users/milchakov/repos","events_url":"https://api.github.com/users/milchakov/events{/privacy}","received_events_url":"https://api.github.com/users/milchakov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/milchakov/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":true,"url":"https://api.github.com/repos/milchakov/omim","forks_url":"https://api.github.com/repos/milchakov/omim/forks","keys_url":"https://api.github.com/repos/milchakov/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/milchakov/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/milchakov/omim/teams","hooks_url":"https://api.github.com/repos/milchakov/omim/hooks","issue_events_url":"https://api.github.com/repos/milchakov/omim/issues/events{/number}","events_url":"https://api.github.com/repos/milchakov/omim/events","assignees_url":"https://api.github.com/repos/milchakov/omim/assignees{/user}","branches_url":"https://api.github.com/repos/milchakov/omim/branches{/branch}","tags_url":"https://api.github.com/repos/milchakov/omim/tags","blobs_url":"https://api.github.com/repos/milchakov/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/milchakov/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/milchakov/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/milchakov/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/milchakov/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/milchakov/omim/languages","stargazers_url":"https://api.github.com/repos/milchakov/omim/stargazers","contributors_url":"https://api.github.com/repos/milchakov/omim/contributors","subscribers_url":"https://api.github.com/repos/milchakov/omim/subscribers","subscription_url":"https://api.github.com/repos/milchakov/omim/subscription","commits_url":"https://api.github.com/repos/milchakov/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/milchakov/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/milchakov/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/milchakov/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/milchakov/omim/contents/{+path}","compare_url":"https://api.github.com/repos/milchakov/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/milchakov/omim/merges","archive_url":"https://api.github.com/repos/milchakov/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/milchakov/omim/downloads","issues_url":"https://api.github.com/repos/milchakov/omim/issues{/number}","pulls_url":"https://api.github.com/repos/milchakov/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/milchakov/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/milchakov/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/milchakov/omim/labels{/name}","releases_url":"https://api.github.com/repos/milchakov/omim/releases{/id}","deployments_url":"https://api.github.com/repos/milchakov/omim/deployments","created_at":"2016-06-19T20:16:05Z","updated_at":"2016-06-19T20:17:34Z","pushed_at":"2016-10-07T13:09:09Z","git_url":"git://github.com/milchakov/omim.git","ssh_url":"git@github.com:milchakov/omim.git","clone_url":"https://github.com/milchakov/omim.git","svn_url":"https://github.com/milchakov/omim","homepage":null,"size":2743077,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mapsme:master","ref":"master","sha":"569ea6f2842680a66d3426176cd968798cc333cf","user":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"repo":{"id":42798033,"name":"omim","full_name":"mapsme/omim","owner":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapsme/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":false,"url":"https://api.github.com/repos/mapsme/omim","forks_url":"https://api.github.com/repos/mapsme/omim/forks","keys_url":"https://api.github.com/repos/mapsme/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapsme/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapsme/omim/teams","hooks_url":"https://api.github.com/repos/mapsme/omim/hooks","issue_events_url":"https://api.github.com/repos/mapsme/omim/issues/events{/number}","events_url":"https://api.github.com/repos/mapsme/omim/events","assignees_url":"https://api.github.com/repos/mapsme/omim/assignees{/user}","branches_url":"https://api.github.com/repos/mapsme/omim/branches{/branch}","tags_url":"https://api.github.com/repos/mapsme/omim/tags","blobs_url":"https://api.github.com/repos/mapsme/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapsme/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapsme/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapsme/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/mapsme/omim/languages","stargazers_url":"https://api.github.com/repos/mapsme/omim/stargazers","contributors_url":"https://api.github.com/repos/mapsme/omim/contributors","subscribers_url":"https://api.github.com/repos/mapsme/omim/subscribers","subscription_url":"https://api.github.com/repos/mapsme/omim/subscription","commits_url":"https://api.github.com/repos/mapsme/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapsme/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapsme/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapsme/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapsme/omim/contents/{+path}","compare_url":"https://api.github.com/repos/mapsme/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapsme/omim/merges","archive_url":"https://api.github.com/repos/mapsme/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapsme/omim/downloads","issues_url":"https://api.github.com/repos/mapsme/omim/issues{/number}","pulls_url":"https://api.github.com/repos/mapsme/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/mapsme/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/mapsme/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapsme/omim/labels{/name}","releases_url":"https://api.github.com/repos/mapsme/omim/releases{/id}","deployments_url":"https://api.github.com/repos/mapsme/omim/deployments","created_at":"2015-09-20T02:57:13Z","updated_at":"2016-10-07T08:42:10Z","pushed_at":"2016-10-07T14:14:09Z","git_url":"git://github.com/mapsme/omim.git","ssh_url":"git@github.com:mapsme/omim.git","clone_url":"https://github.com/mapsme/omim.git","svn_url":"https://github.com/mapsme/omim","homepage":null,"size":2815678,"stargazers_count":1998,"watchers_count":1998,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":368,"mirror_url":null,"open_issues_count":334,"forks":368,"open_issues":334,"watchers":1998,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/4451"},"html":{"href":"https://github.com/mapsme/omim/pull/4451"},"issue":{"href":"https://api.github.com/repos/mapsme/omim/issues/4451"},"comments":{"href":"https://api.github.com/repos/mapsme/omim/issues/4451/comments"},"review_comments":{"href":"https://api.github.com/repos/mapsme/omim/pulls/4451/comments"},"review_comment":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapsme/omim/pulls/4451/commits"},"statuses":{"href":"https://api.github.com/repos/mapsme/omim/statuses/baee0f0d2c9a94ef930d77b79aa3e71a7b409dae"}}}}
{"actor":{"display_login":"ygorshenin"}}