{"action":"created","comment":{"url":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/comments/185801491","pull_request_review_id":117262847,"id":185801491,"diff_hunk":"@@ -28,40 +37,99 @@ public class MagentoAPI: BaseAPI, API {\n     \n     public func getShopInfo(callback: @escaping RepoCallback<Shop>) {\n         // There is no api to fetch terms\n+        callback(nil, nil)\n     }\n     \n     // MARK: - Products\n     \n     public func getProductList(perPage: Int, paginationValue: Any?, sortBy: SortingValue?, keyPhrase: String?, excludePhrase: String?, reverse: Bool, callback: @escaping RepoCallback<[Product]>) {\n-        // TODO: Implement api method\n+        guard let sortBy = sortBy, sortBy.rawValue != SortingValue.popular.rawValue else {\n+            callback([], nil)\n+            \n+            return\n+        }\n+        \n+        var currentPaginationValue = defaultPaginationValue\n+        let builder = ProductsParametersBuilder()\n+        \n+        if sortBy.rawValue == SortingValue.createdAt.rawValue {\n+            _ = builder.addSortOrderParameters(field: createdAtField, isRevers: reverse)\n+        } else if sortBy.rawValue == SortingValue.type.rawValue, let keyPhrase = keyPhrase {\n+            _ = builder.addFilterParameters(field: attributeSetIdField, value: keyPhrase)\n+            \n+            if let excludePhrase = excludePhrase {\n+                _ = builder.addFilterParameters(field: nameField, value: excludePhrase, condition: .notEqual)\n+            }\n+        }\n+\n+        if let paginationValue = paginationValue as? String, let custedPaginationValue = Int(paginationValue) {\n+            currentPaginationValue = custedPaginationValue\n+        }\n+        \n+        getProductList(perPage: perPage, paginationValue: currentPaginationValue, builder: builder, callback: callback)\n     }\n     \n     public func getProduct(id: String, callback: @escaping RepoCallback<Product>) {\n-        // TODO: Implement api method\n+        getStoreConfigs { [weak self] (сurrency, error) in\n+            guard let strongSelf = self else {\n+                return\n+            }\n+            \n+            guard error == nil, let сurrency = сurrency else {\n+                callback(nil, error ?? ContentError())\n+                \n+                return\n+            }\n+            \n+            let route = MagentoProductsRoute.getProduct(sku: id)\n+            let request = MagentoProductsRouter(route: route)\n+            \n+            strongSelf.execute(request) { (response, error) in\n+                guard error == nil, let json = response as? [String: Any], let response = GetProductResponse.object(from: json) else {\n+                    callback(nil, error ?? ContentError())\n+                    \n+                    return\n+                }\n+                \n+                callback(MagentoProductAdapter.adapt(response, currency: сurrency), nil)\n+            }\n+        }\n     }\n     \n     public func searchProducts(perPage: Int, paginationValue: Any?, searchQuery: String, callback: @escaping RepoCallback<[Product]>) {\n-        // TODO: Implement api method\n+        var currentPaginationValue = defaultPaginationValue\n+        let builder = ProductsParametersBuilder()\n+            .addFilterParameters(field: nameField, value: String(format: searchValueFormat, arguments: [searchQuery]), condition: .like)\n+        \n+        if let paginationValue = paginationValue as? String, let custedPaginationValue = Int(paginationValue) {","path":"ShopApp/Data/API/Alamofire/MagentoAPI.swift","position":96,"original_position":96,"commit_id":"a2a33db4c95a5c680e66b1796fc637487993b845","original_commit_id":"a2a33db4c95a5c680e66b1796fc637487993b845","user":{"login":"AntonoffEvgeniy","id":8193451,"avatar_url":"https://avatars0.githubusercontent.com/u/8193451?v=4","gravatar_id":"","url":"https://api.github.com/users/AntonoffEvgeniy","html_url":"https://github.com/AntonoffEvgeniy","followers_url":"https://api.github.com/users/AntonoffEvgeniy/followers","following_url":"https://api.github.com/users/AntonoffEvgeniy/following{/other_user}","gists_url":"https://api.github.com/users/AntonoffEvgeniy/gists{/gist_id}","starred_url":"https://api.github.com/users/AntonoffEvgeniy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AntonoffEvgeniy/subscriptions","organizations_url":"https://api.github.com/users/AntonoffEvgeniy/orgs","repos_url":"https://api.github.com/users/AntonoffEvgeniy/repos","events_url":"https://api.github.com/users/AntonoffEvgeniy/events{/privacy}","received_events_url":"https://api.github.com/users/AntonoffEvgeniy/received_events","type":"User","site_admin":false},"body":"custedPaginationValue => castedPaginationValue","created_at":"2018-05-03T13:42:40Z","updated_at":"2018-05-03T13:58:46Z","html_url":"https://github.com/rubygarage/shopapp-ios/pull/166#discussion_r185801491","pull_request_url":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/166","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/comments/185801491"},"html":{"href":"https://github.com/rubygarage/shopapp-ios/pull/166#discussion_r185801491"},"pull_request":{"href":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/166"}}},"pull_request":{"url":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/166","id":185714045,"html_url":"https://github.com/rubygarage/shopapp-ios/pull/166","diff_url":"https://github.com/rubygarage/shopapp-ios/pull/166.diff","patch_url":"https://github.com/rubygarage/shopapp-ios/pull/166.patch","issue_url":"https://api.github.com/repos/rubygarage/shopapp-ios/issues/166","number":166,"state":"open","locked":false,"title":"Add product api","user":{"login":"radyslavkrechet","id":22166175,"avatar_url":"https://avatars1.githubusercontent.com/u/22166175?v=4","gravatar_id":"","url":"https://api.github.com/users/radyslavkrechet","html_url":"https://github.com/radyslavkrechet","followers_url":"https://api.github.com/users/radyslavkrechet/followers","following_url":"https://api.github.com/users/radyslavkrechet/following{/other_user}","gists_url":"https://api.github.com/users/radyslavkrechet/gists{/gist_id}","starred_url":"https://api.github.com/users/radyslavkrechet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radyslavkrechet/subscriptions","organizations_url":"https://api.github.com/users/radyslavkrechet/orgs","repos_url":"https://api.github.com/users/radyslavkrechet/repos","events_url":"https://api.github.com/users/radyslavkrechet/events{/privacy}","received_events_url":"https://api.github.com/users/radyslavkrechet/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-03T13:20:33Z","updated_at":"2018-05-03T13:58:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a77cd995623e33a2b66a736f774a161ed6a91fc5","assignee":null,"assignees":[],"requested_reviewers":[{"login":"plzen","id":610948,"avatar_url":"https://avatars3.githubusercontent.com/u/610948?v=4","gravatar_id":"","url":"https://api.github.com/users/plzen","html_url":"https://github.com/plzen","followers_url":"https://api.github.com/users/plzen/followers","following_url":"https://api.github.com/users/plzen/following{/other_user}","gists_url":"https://api.github.com/users/plzen/gists{/gist_id}","starred_url":"https://api.github.com/users/plzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plzen/subscriptions","organizations_url":"https://api.github.com/users/plzen/orgs","repos_url":"https://api.github.com/users/plzen/repos","events_url":"https://api.github.com/users/plzen/events{/privacy}","received_events_url":"https://api.github.com/users/plzen/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/166/commits","review_comments_url":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/166/comments","review_comment_url":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rubygarage/shopapp-ios/issues/166/comments","statuses_url":"https://api.github.com/repos/rubygarage/shopapp-ios/statuses/a2a33db4c95a5c680e66b1796fc637487993b845","head":{"label":"rubygarage:products","ref":"products","sha":"a2a33db4c95a5c680e66b1796fc637487993b845","user":{"login":"rubygarage","id":2300590,"avatar_url":"https://avatars2.githubusercontent.com/u/2300590?v=4","gravatar_id":"","url":"https://api.github.com/users/rubygarage","html_url":"https://github.com/rubygarage","followers_url":"https://api.github.com/users/rubygarage/followers","following_url":"https://api.github.com/users/rubygarage/following{/other_user}","gists_url":"https://api.github.com/users/rubygarage/gists{/gist_id}","starred_url":"https://api.github.com/users/rubygarage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubygarage/subscriptions","organizations_url":"https://api.github.com/users/rubygarage/orgs","repos_url":"https://api.github.com/users/rubygarage/repos","events_url":"https://api.github.com/users/rubygarage/events{/privacy}","received_events_url":"https://api.github.com/users/rubygarage/received_events","type":"Organization","site_admin":false},"repo":{"id":105553986,"name":"shopapp-ios","full_name":"rubygarage/shopapp-ios","owner":{"login":"rubygarage","id":2300590,"avatar_url":"https://avatars2.githubusercontent.com/u/2300590?v=4","gravatar_id":"","url":"https://api.github.com/users/rubygarage","html_url":"https://github.com/rubygarage","followers_url":"https://api.github.com/users/rubygarage/followers","following_url":"https://api.github.com/users/rubygarage/following{/other_user}","gists_url":"https://api.github.com/users/rubygarage/gists{/gist_id}","starred_url":"https://api.github.com/users/rubygarage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubygarage/subscriptions","organizations_url":"https://api.github.com/users/rubygarage/orgs","repos_url":"https://api.github.com/users/rubygarage/repos","events_url":"https://api.github.com/users/rubygarage/events{/privacy}","received_events_url":"https://api.github.com/users/rubygarage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rubygarage/shopapp-ios","description":"ShopApp is an application that transfers an online store into a mobile app","fork":false,"url":"https://api.github.com/repos/rubygarage/shopapp-ios","forks_url":"https://api.github.com/repos/rubygarage/shopapp-ios/forks","keys_url":"https://api.github.com/repos/rubygarage/shopapp-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rubygarage/shopapp-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rubygarage/shopapp-ios/teams","hooks_url":"https://api.github.com/repos/rubygarage/shopapp-ios/hooks","issue_events_url":"https://api.github.com/repos/rubygarage/shopapp-ios/issues/events{/number}","events_url":"https://api.github.com/repos/rubygarage/shopapp-ios/events","assignees_url":"https://api.github.com/repos/rubygarage/shopapp-ios/assignees{/user}","branches_url":"https://api.github.com/repos/rubygarage/shopapp-ios/branches{/branch}","tags_url":"https://api.github.com/repos/rubygarage/shopapp-ios/tags","blobs_url":"https://api.github.com/repos/rubygarage/shopapp-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rubygarage/shopapp-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rubygarage/shopapp-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/rubygarage/shopapp-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rubygarage/shopapp-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/rubygarage/shopapp-ios/languages","stargazers_url":"https://api.github.com/repos/rubygarage/shopapp-ios/stargazers","contributors_url":"https://api.github.com/repos/rubygarage/shopapp-ios/contributors","subscribers_url":"https://api.github.com/repos/rubygarage/shopapp-ios/subscribers","subscription_url":"https://api.github.com/repos/rubygarage/shopapp-ios/subscription","commits_url":"https://api.github.com/repos/rubygarage/shopapp-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/rubygarage/shopapp-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/rubygarage/shopapp-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/rubygarage/shopapp-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/rubygarage/shopapp-ios/contents/{+path}","compare_url":"https://api.github.com/repos/rubygarage/shopapp-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rubygarage/shopapp-ios/merges","archive_url":"https://api.github.com/repos/rubygarage/shopapp-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rubygarage/shopapp-ios/downloads","issues_url":"https://api.github.com/repos/rubygarage/shopapp-ios/issues{/number}","pulls_url":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/rubygarage/shopapp-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/rubygarage/shopapp-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rubygarage/shopapp-ios/labels{/name}","releases_url":"https://api.github.com/repos/rubygarage/shopapp-ios/releases{/id}","deployments_url":"https://api.github.com/repos/rubygarage/shopapp-ios/deployments","created_at":"2017-10-02T15:54:24Z","updated_at":"2018-04-22T21:54:53Z","pushed_at":"2018-05-03T13:20:33Z","git_url":"git://github.com/rubygarage/shopapp-ios.git","ssh_url":"git@github.com:rubygarage/shopapp-ios.git","clone_url":"https://github.com/rubygarage/shopapp-ios.git","svn_url":"https://github.com/rubygarage/shopapp-ios","homepage":"","size":5756,"stargazers_count":11,"watchers_count":11,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":2,"watchers":11,"default_branch":"master"}},"base":{"label":"rubygarage:feature/magento","ref":"feature/magento","sha":"590176459b1cb74cecb63c774e3c5002ea3f6844","user":{"login":"rubygarage","id":2300590,"avatar_url":"https://avatars2.githubusercontent.com/u/2300590?v=4","gravatar_id":"","url":"https://api.github.com/users/rubygarage","html_url":"https://github.com/rubygarage","followers_url":"https://api.github.com/users/rubygarage/followers","following_url":"https://api.github.com/users/rubygarage/following{/other_user}","gists_url":"https://api.github.com/users/rubygarage/gists{/gist_id}","starred_url":"https://api.github.com/users/rubygarage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubygarage/subscriptions","organizations_url":"https://api.github.com/users/rubygarage/orgs","repos_url":"https://api.github.com/users/rubygarage/repos","events_url":"https://api.github.com/users/rubygarage/events{/privacy}","received_events_url":"https://api.github.com/users/rubygarage/received_events","type":"Organization","site_admin":false},"repo":{"id":105553986,"name":"shopapp-ios","full_name":"rubygarage/shopapp-ios","owner":{"login":"rubygarage","id":2300590,"avatar_url":"https://avatars2.githubusercontent.com/u/2300590?v=4","gravatar_id":"","url":"https://api.github.com/users/rubygarage","html_url":"https://github.com/rubygarage","followers_url":"https://api.github.com/users/rubygarage/followers","following_url":"https://api.github.com/users/rubygarage/following{/other_user}","gists_url":"https://api.github.com/users/rubygarage/gists{/gist_id}","starred_url":"https://api.github.com/users/rubygarage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubygarage/subscriptions","organizations_url":"https://api.github.com/users/rubygarage/orgs","repos_url":"https://api.github.com/users/rubygarage/repos","events_url":"https://api.github.com/users/rubygarage/events{/privacy}","received_events_url":"https://api.github.com/users/rubygarage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rubygarage/shopapp-ios","description":"ShopApp is an application that transfers an online store into a mobile app","fork":false,"url":"https://api.github.com/repos/rubygarage/shopapp-ios","forks_url":"https://api.github.com/repos/rubygarage/shopapp-ios/forks","keys_url":"https://api.github.com/repos/rubygarage/shopapp-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rubygarage/shopapp-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rubygarage/shopapp-ios/teams","hooks_url":"https://api.github.com/repos/rubygarage/shopapp-ios/hooks","issue_events_url":"https://api.github.com/repos/rubygarage/shopapp-ios/issues/events{/number}","events_url":"https://api.github.com/repos/rubygarage/shopapp-ios/events","assignees_url":"https://api.github.com/repos/rubygarage/shopapp-ios/assignees{/user}","branches_url":"https://api.github.com/repos/rubygarage/shopapp-ios/branches{/branch}","tags_url":"https://api.github.com/repos/rubygarage/shopapp-ios/tags","blobs_url":"https://api.github.com/repos/rubygarage/shopapp-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rubygarage/shopapp-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rubygarage/shopapp-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/rubygarage/shopapp-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rubygarage/shopapp-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/rubygarage/shopapp-ios/languages","stargazers_url":"https://api.github.com/repos/rubygarage/shopapp-ios/stargazers","contributors_url":"https://api.github.com/repos/rubygarage/shopapp-ios/contributors","subscribers_url":"https://api.github.com/repos/rubygarage/shopapp-ios/subscribers","subscription_url":"https://api.github.com/repos/rubygarage/shopapp-ios/subscription","commits_url":"https://api.github.com/repos/rubygarage/shopapp-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/rubygarage/shopapp-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/rubygarage/shopapp-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/rubygarage/shopapp-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/rubygarage/shopapp-ios/contents/{+path}","compare_url":"https://api.github.com/repos/rubygarage/shopapp-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rubygarage/shopapp-ios/merges","archive_url":"https://api.github.com/repos/rubygarage/shopapp-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rubygarage/shopapp-ios/downloads","issues_url":"https://api.github.com/repos/rubygarage/shopapp-ios/issues{/number}","pulls_url":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/rubygarage/shopapp-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/rubygarage/shopapp-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rubygarage/shopapp-ios/labels{/name}","releases_url":"https://api.github.com/repos/rubygarage/shopapp-ios/releases{/id}","deployments_url":"https://api.github.com/repos/rubygarage/shopapp-ios/deployments","created_at":"2017-10-02T15:54:24Z","updated_at":"2018-04-22T21:54:53Z","pushed_at":"2018-05-03T13:20:33Z","git_url":"git://github.com/rubygarage/shopapp-ios.git","ssh_url":"git@github.com:rubygarage/shopapp-ios.git","clone_url":"https://github.com/rubygarage/shopapp-ios.git","svn_url":"https://github.com/rubygarage/shopapp-ios","homepage":"","size":5756,"stargazers_count":11,"watchers_count":11,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":2,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/166"},"html":{"href":"https://github.com/rubygarage/shopapp-ios/pull/166"},"issue":{"href":"https://api.github.com/repos/rubygarage/shopapp-ios/issues/166"},"comments":{"href":"https://api.github.com/repos/rubygarage/shopapp-ios/issues/166/comments"},"review_comments":{"href":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/166/comments"},"review_comment":{"href":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rubygarage/shopapp-ios/pulls/166/commits"},"statuses":{"href":"https://api.github.com/repos/rubygarage/shopapp-ios/statuses/a2a33db4c95a5c680e66b1796fc637487993b845"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"AntonoffEvgeniy"}}