diff --git a/lib/tentacat/search.ex b/lib/tentacat/search.ex index e1de284..ec53289 100644 --- a/lib/tentacat/search.ex +++ b/lib/tentacat/search.ex @@ -50,4 +50,19 @@ defmodule Tentacat.Search do def repositories(client \\ %Client{}, params, options \\ []) do get("search/repositories", client, params, options) end + + @doc """ + Search in issues and pull requests + + ## Example + + Tentacat.Search.issues %{q: "repo:edgurgel/tentacat is:merged", sort: "comments"} + Tentacat.Search.issues client, %{q: "repo:edgurgel/tentacat is:merged", sort: "created"} + + More info at: https://developer.github.com/v3/search/#search-issues + """ + @spec issues(Client.t(), any, Keyword.t()) :: Tentacat.response() + def issues(client \\ %Client{}, params, options \\ []) do + get("search/issues", client, params, options) + end end diff --git a/test/fixture/vcr_cassettes/search#issues.json b/test/fixture/vcr_cassettes/search#issues.json new file mode 100644 index 0000000..b19c347 --- /dev/null +++ b/test/fixture/vcr_cassettes/search#issues.json @@ -0,0 +1,42 @@ +[ + { + "request": { + "body": "\"\\\"\\\"\"", + "headers": { + "User-agent": "tentacat" + }, + "method": "get", + "options": [], + "request_body": "", + "url": "https://api.github.com/search/issues?q=repo%3Aedgurgel%2Ftentacat+is%3Aopen&sort=comments" + }, + "response": { + "binary": false, + "body": "{\"total_count\":16,\"incomplete_results\":false,\"items\":[{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/84\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/84/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/84/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/84/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/84\",\"id\":154776454,\"node_id\":\"MDU6SXNzdWUxNTQ3NzY0NTQ=\",\"number\":84,\"title\":\"Github rate limit\",\"user\":{\"login\":\"mgwidmann\",\"id\":5035724,\"node_id\":\"MDQ6VXNlcjUwMzU3MjQ=\",\"avatar_url\":\"https://avatars1.githubusercontent.com/u/5035724?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/mgwidmann\",\"html_url\":\"https://github.com/mgwidmann\",\"followers_url\":\"https://api.github.com/users/mgwidmann/followers\",\"following_url\":\"https://api.github.com/users/mgwidmann/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/mgwidmann/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/mgwidmann/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/mgwidmann/subscriptions\",\"organizations_url\":\"https://api.github.com/users/mgwidmann/orgs\",\"repos_url\":\"https://api.github.com/users/mgwidmann/repos\",\"events_url\":\"https://api.github.com/users/mgwidmann/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/mgwidmann/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":12,\"created_at\":\"2016-05-13T18:45:41Z\",\"updated_at\":\"2017-11-28T22:48:07Z\",\"closed_at\":null,\"author_association\":\"CONTRIBUTOR\",\"body\":\"Currently theres no handling of the rate limit in this project. I regularly hit the rate limit (usually at the end of the hour) and would like to hear your thoughts on how to handle this properly.\\n\\nHeres the exception I get when that happens:\\n\\n```\\n[error] Task #PID<0.516.0> started from #PID<0.515.0> terminating\\n** (FunctionClauseError) no function clause matching in Tentacat.process_stream/1\\n lib/tentacat.ex:102: Tentacat.process_stream({403, %{\\\"documentation_url\\\" => \\\"https://developer.github.com/v3/#rate-limiting\\\", \\\"message\\\" => \\\"API rate limit exceeded for mgwidmann.\\\"}})\\n (elixir) lib/stream.ex:1099: Stream.do_resource/5\\n (elixir) lib/enum.ex:1486: Enum.reduce/3\\n (elixir) lib/enum.ex:2248: Enum.to_list/1\\n```\\n\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/95\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/95/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/95/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/95/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/pull/95\",\"id\":176103956,\"node_id\":\"MDExOlB1bGxSZXF1ZXN0ODQ3MTUxNDE=\",\"number\":95,\"title\":\"readme\",\"user\":{\"login\":\"polymetis\",\"id\":1136430,\"node_id\":\"MDQ6VXNlcjExMzY0MzA=\",\"avatar_url\":\"https://avatars2.githubusercontent.com/u/1136430?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/polymetis\",\"html_url\":\"https://github.com/polymetis\",\"followers_url\":\"https://api.github.com/users/polymetis/followers\",\"following_url\":\"https://api.github.com/users/polymetis/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/polymetis/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/polymetis/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/polymetis/subscriptions\",\"organizations_url\":\"https://api.github.com/users/polymetis/orgs\",\"repos_url\":\"https://api.github.com/users/polymetis/repos\",\"events_url\":\"https://api.github.com/users/polymetis/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/polymetis/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":3,\"created_at\":\"2016-09-09T20:37:31Z\",\"updated_at\":\"2016-09-11T22:34:55Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"pull_request\":{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/pulls/95\",\"html_url\":\"https://github.com/edgurgel/tentacat/pull/95\",\"diff_url\":\"https://github.com/edgurgel/tentacat/pull/95.diff\",\"patch_url\":\"https://github.com/edgurgel/tentacat/pull/95.patch\"},\"body\":\"Just added a readme function because I was floating about the code. \\n\\nhttps://developer.github.com/v3/repos/contents/#get-the-readme\\n\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/72\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/72/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/72/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/72/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/72\",\"id\":147169427,\"node_id\":\"MDU6SXNzdWUxNDcxNjk0Mjc=\",\"number\":72,\"title\":\"Documentation doesn't mention you can pass parameters\",\"user\":{\"login\":\"2016rshah\",\"id\":6821244,\"node_id\":\"MDQ6VXNlcjY4MjEyNDQ=\",\"avatar_url\":\"https://avatars3.githubusercontent.com/u/6821244?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/2016rshah\",\"html_url\":\"https://github.com/2016rshah\",\"followers_url\":\"https://api.github.com/users/2016rshah/followers\",\"following_url\":\"https://api.github.com/users/2016rshah/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/2016rshah/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/2016rshah/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/2016rshah/subscriptions\",\"organizations_url\":\"https://api.github.com/users/2016rshah/orgs\",\"repos_url\":\"https://api.github.com/users/2016rshah/repos\",\"events_url\":\"https://api.github.com/users/2016rshah/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/2016rshah/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":3,\"created_at\":\"2016-04-09T22:26:22Z\",\"updated_at\":\"2016-04-10T21:52:51Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"body\":\"As you can see [here](https://github.com/edgurgel/tentacat/blob/master/lib/tentacat/repositories.ex#L25) the documentation doesn't mention you can pass in parameters like `[sort: \\\"pushed\\\"]` to the function even though that feature has already been implemented. \\n\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/78\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/78/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/78/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/78/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/pull/78\",\"id\":151130683,\"node_id\":\"MDExOlB1bGxSZXF1ZXN0Njc4ODI3MzQ=\",\"number\":78,\"title\":\"edit issues by https://developer.github.com/v3/issues/#edit-an-issue\",\"user\":{\"login\":\"zhongwencool\",\"id\":3116225,\"node_id\":\"MDQ6VXNlcjMxMTYyMjU=\",\"avatar_url\":\"https://avatars2.githubusercontent.com/u/3116225?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/zhongwencool\",\"html_url\":\"https://github.com/zhongwencool\",\"followers_url\":\"https://api.github.com/users/zhongwencool/followers\",\"following_url\":\"https://api.github.com/users/zhongwencool/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/zhongwencool/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/zhongwencool/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/zhongwencool/subscriptions\",\"organizations_url\":\"https://api.github.com/users/zhongwencool/orgs\",\"repos_url\":\"https://api.github.com/users/zhongwencool/repos\",\"events_url\":\"https://api.github.com/users/zhongwencool/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/zhongwencool/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":2,\"created_at\":\"2016-04-26T13:11:06Z\",\"updated_at\":\"2016-04-26T16:33:53Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"pull_request\":{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/pulls/78\",\"html_url\":\"https://github.com/edgurgel/tentacat/pull/78\",\"diff_url\":\"https://github.com/edgurgel/tentacat/pull/78.diff\",\"patch_url\":\"https://github.com/edgurgel/tentacat/pull/78.patch\"},\"body\":\"\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/111\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/111/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/111/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/111/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/pull/111\",\"id\":208578174,\"node_id\":\"MDExOlB1bGxSZXF1ZXN0MTA2ODI2Nzk2\",\"number\":111,\"title\":\"Add support for notifications API\",\"user\":{\"login\":\"Baransu\",\"id\":9558691,\"node_id\":\"MDQ6VXNlcjk1NTg2OTE=\",\"avatar_url\":\"https://avatars2.githubusercontent.com/u/9558691?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/Baransu\",\"html_url\":\"https://github.com/Baransu\",\"followers_url\":\"https://api.github.com/users/Baransu/followers\",\"following_url\":\"https://api.github.com/users/Baransu/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/Baransu/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/Baransu/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/Baransu/subscriptions\",\"organizations_url\":\"https://api.github.com/users/Baransu/orgs\",\"repos_url\":\"https://api.github.com/users/Baransu/repos\",\"events_url\":\"https://api.github.com/users/Baransu/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/Baransu/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":3,\"created_at\":\"2017-02-17T22:46:20Z\",\"updated_at\":\"2017-03-26T11:52:46Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"pull_request\":{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/pulls/111\",\"html_url\":\"https://github.com/edgurgel/tentacat/pull/111\",\"diff_url\":\"https://github.com/edgurgel/tentacat/pull/111.diff\",\"patch_url\":\"https://github.com/edgurgel/tentacat/pull/111.patch\"},\"body\":\"I found that notifications is not covered in this library so I've added functions cover this part of API.\\r\\n\\r\\nI've also tried to add tests to every new function but in seems that token yourtokencomeshere\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/96\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/96/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/96/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/96/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/96\",\"id\":176381918,\"node_id\":\"MDU6SXNzdWUxNzYzODE5MTg=\",\"number\":96,\"title\":\"Support for .diff and .patch mediatypes\",\"user\":{\"login\":\"smetana\",\"id\":5590,\"node_id\":\"MDQ6VXNlcjU1OTA=\",\"avatar_url\":\"https://avatars2.githubusercontent.com/u/5590?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/smetana\",\"html_url\":\"https://github.com/smetana\",\"followers_url\":\"https://api.github.com/users/smetana/followers\",\"following_url\":\"https://api.github.com/users/smetana/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/smetana/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/smetana/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/smetana/subscriptions\",\"organizations_url\":\"https://api.github.com/users/smetana/orgs\",\"repos_url\":\"https://api.github.com/users/smetana/repos\",\"events_url\":\"https://api.github.com/users/smetana/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/smetana/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":2,\"created_at\":\"2016-09-12T13:57:03Z\",\"updated_at\":\"2017-02-16T11:31:43Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"body\":\"GitHub API allows to set Accept header to application/vnd.github.v3.diff and application/vnd.github.v3.patch to return raw diffs and patches. This raises error in Tentacat because response body is always processed by JSX.decode!. Even if it is not json\\n\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/2\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/2/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/2/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/2/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/2\",\"id\":15853488,\"node_id\":\"MDU6SXNzdWUxNTg1MzQ4OA==\",\"number\":2,\"title\":\"Tentacat Logo/Mascott\",\"user\":{\"login\":\"edgurgel\",\"id\":30873,\"node_id\":\"MDQ6VXNlcjMwODcz\",\"avatar_url\":\"https://avatars0.githubusercontent.com/u/30873?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/edgurgel\",\"html_url\":\"https://github.com/edgurgel\",\"followers_url\":\"https://api.github.com/users/edgurgel/followers\",\"following_url\":\"https://api.github.com/users/edgurgel/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/edgurgel/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/edgurgel/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/edgurgel/subscriptions\",\"organizations_url\":\"https://api.github.com/users/edgurgel/orgs\",\"repos_url\":\"https://api.github.com/users/edgurgel/repos\",\"events_url\":\"https://api.github.com/users/edgurgel/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/edgurgel/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[{\"id\":43408683,\"node_id\":\"MDU6TGFiZWw0MzQwODY4Mw==\",\"url\":\"https://api.github.com/repos/edgurgel/tentacat/labels/enhancement\",\"name\":\"enhancement\",\"color\":\"84b6eb\",\"default\":true}],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":1,\"created_at\":\"2013-06-21T14:25:06Z\",\"updated_at\":\"2015-12-14T20:51:31Z\",\"closed_at\":null,\"author_association\":\"OWNER\",\"body\":\"We need a cool logo/mascott for Tentacat! @jugoncalves :question: \\n\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/135\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/135/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/135/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/135/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/135\",\"id\":277541753,\"node_id\":\"MDU6SXNzdWUyNzc1NDE3NTM=\",\"number\":135,\"title\":\"passing the etag in requests\",\"user\":{\"login\":\"bryanhuntesl\",\"id\":31992054,\"node_id\":\"MDQ6VXNlcjMxOTkyMDU0\",\"avatar_url\":\"https://avatars3.githubusercontent.com/u/31992054?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/bryanhuntesl\",\"html_url\":\"https://github.com/bryanhuntesl\",\"followers_url\":\"https://api.github.com/users/bryanhuntesl/followers\",\"following_url\":\"https://api.github.com/users/bryanhuntesl/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/bryanhuntesl/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/bryanhuntesl/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/bryanhuntesl/subscriptions\",\"organizations_url\":\"https://api.github.com/users/bryanhuntesl/orgs\",\"repos_url\":\"https://api.github.com/users/bryanhuntesl/repos\",\"events_url\":\"https://api.github.com/users/bryanhuntesl/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/bryanhuntesl/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":1,\"created_at\":\"2017-11-28T21:19:51Z\",\"updated_at\":\"2017-11-28T21:21:51Z\",\"closed_at\":null,\"author_association\":\"CONTRIBUTOR\",\"body\":\"Hi, I'm going to drop down to HTTPoison most likely for this, one optimization which can be made in any call is to pass the ETag from the previous invocation - if you do so, and nothing has changed, your rate limit remains unchanged. Could it be passed in the existing options block? \\r\\n\\r\\n\\\"ETag\\\", \\\"\\\\\\\"eaa46eb91c77ded86b4261245e49fbd5\\\\\\\"\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/144\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/144/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/144/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/144/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/144\",\"id\":315491184,\"node_id\":\"MDU6SXNzdWUzMTU0OTExODQ=\",\"number\":144,\"title\":\"0.9.0 API is inconsistent. Some requests still return body instead of tuple {code, body, response}\",\"user\":{\"login\":\"smetana\",\"id\":5590,\"node_id\":\"MDQ6VXNlcjU1OTA=\",\"avatar_url\":\"https://avatars2.githubusercontent.com/u/5590?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/smetana\",\"html_url\":\"https://github.com/smetana\",\"followers_url\":\"https://api.github.com/users/smetana/followers\",\"following_url\":\"https://api.github.com/users/smetana/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/smetana/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/smetana/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/smetana/subscriptions\",\"organizations_url\":\"https://api.github.com/users/smetana/orgs\",\"repos_url\":\"https://api.github.com/users/smetana/repos\",\"events_url\":\"https://api.github.com/users/smetana/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/smetana/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[{\"id\":43408681,\"node_id\":\"MDU6TGFiZWw0MzQwODY4MQ==\",\"url\":\"https://api.github.com/repos/edgurgel/tentacat/labels/bug\",\"name\":\"bug\",\"color\":\"fc2929\",\"default\":true}],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":1,\"created_at\":\"2018-04-18T13:56:30Z\",\"updated_at\":\"2018-04-18T22:49:30Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"body\":\"```elixir\\r\\nTentacat.Organizations.list_mine(client) # returns tuple\\r\\nTentacat.Repositories.list_mine(client) # returns list\\r\\n```\\r\\n\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/93\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/93/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/93/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/93/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/93\",\"id\":173455290,\"node_id\":\"MDU6SXNzdWUxNzM0NTUyOTA=\",\"number\":93,\"title\":\"support passing in params for Deployments.list method\",\"user\":{\"login\":\"batmany13\",\"id\":2660308,\"node_id\":\"MDQ6VXNlcjI2NjAzMDg=\",\"avatar_url\":\"https://avatars3.githubusercontent.com/u/2660308?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/batmany13\",\"html_url\":\"https://github.com/batmany13\",\"followers_url\":\"https://api.github.com/users/batmany13/followers\",\"following_url\":\"https://api.github.com/users/batmany13/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/batmany13/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/batmany13/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/batmany13/subscriptions\",\"organizations_url\":\"https://api.github.com/users/batmany13/orgs\",\"repos_url\":\"https://api.github.com/users/batmany13/repos\",\"events_url\":\"https://api.github.com/users/batmany13/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/batmany13/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":0,\"created_at\":\"2016-08-26T13:39:16Z\",\"updated_at\":\"2016-12-18T23:16:24Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"body\":\"Looking at GitHub's Deployments api [docs](https://developer.github.com/v3/repos/deployments/#create-a-deployment), it describes the ability to filter deployments by \\\"sha\\\", \\\"ref\\\", \\\"task\\\" and \\\"environment\\\". There doesn't seem to be the ability to pass in optional query params to the Tentacat.Repositories.Deployments.list call. This will be convenient, for instance, in the case of finding all deployments associated with a PR/sha value.\\n\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/101\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/101/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/101/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/101/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/101\",\"id\":187885766,\"node_id\":\"MDU6SXNzdWUxODc4ODU3NjY=\",\"number\":101,\"title\":\"Add headers for text match?\",\"user\":{\"login\":\"mercul3s\",\"id\":2100610,\"node_id\":\"MDQ6VXNlcjIxMDA2MTA=\",\"avatar_url\":\"https://avatars3.githubusercontent.com/u/2100610?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/mercul3s\",\"html_url\":\"https://github.com/mercul3s\",\"followers_url\":\"https://api.github.com/users/mercul3s/followers\",\"following_url\":\"https://api.github.com/users/mercul3s/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/mercul3s/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/mercul3s/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/mercul3s/subscriptions\",\"organizations_url\":\"https://api.github.com/users/mercul3s/orgs\",\"repos_url\":\"https://api.github.com/users/mercul3s/repos\",\"events_url\":\"https://api.github.com/users/mercul3s/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/mercul3s/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":0,\"created_at\":\"2016-11-08T02:28:57Z\",\"updated_at\":\"2016-11-08T02:28:57Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"body\":\"I'm trying to use Github's metadata matching to return code snippets/highlights in the response, as documented in https://developer.github.com/v3/search/#text-match-metadata. I know that I can add my own headers in HTTPoison, ie\\r\\n```\\r\\nheader_list = Enum.to_list(headers)\\r\\n [{\\\"Accept\\\", \\\"application/vnd.github.v3.text-match+json\\\"} | header_list]\\r\\n```\\r\\nSo I can get back something like this:\\r\\n```\\r\\n...\\r\\n \\\"object_type\\\": \\\"FileContent\\\",\\r\\n \\\"property\\\": \\\"content\\\",\\r\\n \\\"fragment\\\": \\\"\\\\\\\",\\\\n \\\\\\\"key_limit\\\\\\\": 2,\\\\n \\\\\\\"owner\\\\\\\": {\\\\n \\\\\\\"email\\\",\\r\\n \\\"matches\\\": [\\r\\n {\\r\\n \\\"text\\\": \\\"key_limit\\\",\\r\\n \\\"indices\\\": [\\r\\n 16,\\r\\n 25\\r\\n ]\\r\\n\\t}\\r\\n...\\r\\n```\\r\\nIs there a way to pass the header info during the client creation? I tried something like the following, but no luck:\\r\\n```\\r\\nTentacat.Client.new(%{access_token: \\\"#{token}\\\", accept: \\\"application/vnd.github.v3.text-match+json\\\"}, \\\"#{@uri}\\\")\\r\\n```\\r\\nI also tried wrapping HTTPoison.base to pass the accept header, but I'm assuming that'll only work if I'm using all the HTTPoison base methods directly. Attempts to add text match as a header return results as a regular search api call. Any suggestions?\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/112\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/112/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/112/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/112/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/112\",\"id\":218698734,\"node_id\":\"MDU6SXNzdWUyMTg2OTg3MzQ=\",\"number\":112,\"title\":\"Projects support\",\"user\":{\"login\":\"AndrewDryga\",\"id\":1877644,\"node_id\":\"MDQ6VXNlcjE4Nzc2NDQ=\",\"avatar_url\":\"https://avatars3.githubusercontent.com/u/1877644?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/AndrewDryga\",\"html_url\":\"https://github.com/AndrewDryga\",\"followers_url\":\"https://api.github.com/users/AndrewDryga/followers\",\"following_url\":\"https://api.github.com/users/AndrewDryga/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/AndrewDryga/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/AndrewDryga/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/AndrewDryga/subscriptions\",\"organizations_url\":\"https://api.github.com/users/AndrewDryga/orgs\",\"repos_url\":\"https://api.github.com/users/AndrewDryga/repos\",\"events_url\":\"https://api.github.com/users/AndrewDryga/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/AndrewDryga/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":0,\"created_at\":\"2017-04-01T14:20:19Z\",\"updated_at\":\"2017-04-01T14:20:19Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"body\":\"It will be really nice to have one library that helps to automate Github Projects workflow (eg list labels and set correct workflow status in GitHub Projects).\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/128\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/128/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/128/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/128/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/128\",\"id\":271303127,\"node_id\":\"MDU6SXNzdWUyNzEzMDMxMjc=\",\"number\":128,\"title\":\"Feature request: Add Gist endpoint\",\"user\":{\"login\":\"DoumanAsh\",\"id\":5676053,\"node_id\":\"MDQ6VXNlcjU2NzYwNTM=\",\"avatar_url\":\"https://avatars3.githubusercontent.com/u/5676053?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/DoumanAsh\",\"html_url\":\"https://github.com/DoumanAsh\",\"followers_url\":\"https://api.github.com/users/DoumanAsh/followers\",\"following_url\":\"https://api.github.com/users/DoumanAsh/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/DoumanAsh/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/DoumanAsh/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/DoumanAsh/subscriptions\",\"organizations_url\":\"https://api.github.com/users/DoumanAsh/orgs\",\"repos_url\":\"https://api.github.com/users/DoumanAsh/repos\",\"events_url\":\"https://api.github.com/users/DoumanAsh/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/DoumanAsh/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":0,\"created_at\":\"2017-11-05T18:40:12Z\",\"updated_at\":\"2017-11-05T18:40:12Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"body\":\"Subj.\\r\\nReference https://developer.github.com/v3/gists/\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/141\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/141/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/141/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/141/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/141\",\"id\":302131791,\"node_id\":\"MDU6SXNzdWUzMDIxMzE3OTE=\",\"number\":141,\"title\":\"Feature request toggle 'watching' \",\"user\":{\"login\":\"bryanhuntesl\",\"id\":31992054,\"node_id\":\"MDQ6VXNlcjMxOTkyMDU0\",\"avatar_url\":\"https://avatars3.githubusercontent.com/u/31992054?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/bryanhuntesl\",\"html_url\":\"https://github.com/bryanhuntesl\",\"followers_url\":\"https://api.github.com/users/bryanhuntesl/followers\",\"following_url\":\"https://api.github.com/users/bryanhuntesl/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/bryanhuntesl/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/bryanhuntesl/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/bryanhuntesl/subscriptions\",\"organizations_url\":\"https://api.github.com/users/bryanhuntesl/orgs\",\"repos_url\":\"https://api.github.com/users/bryanhuntesl/repos\",\"events_url\":\"https://api.github.com/users/bryanhuntesl/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/bryanhuntesl/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":0,\"created_at\":\"2018-03-04T22:59:41Z\",\"updated_at\":\"2018-03-04T22:59:41Z\",\"closed_at\":null,\"author_association\":\"CONTRIBUTOR\",\"body\":\"I've just implemented this in the python github client - this issue serves as a reminder to me, or anyone else who fancies a crack at it - to add this functionality to tentacat. \\r\\n\\r\\n## Subscribing to every public basho project on github\\r\\n\\r\\n[Link](https://github.com/PyGithub/PyGithub) to PyGithub/PyGithub project page \\r\\n\\r\\n[Commit](https://github.com/bryanhuntesl/PyGithub/commit/0d1104c9f7e5124db17dc186b350b1abb9dad270) which added and tested this functionality.\\r\\n\\r\\nInstall the feature version :\\r\\n\\r\\n```bash\\r\\npip install git+git://github.com/bryanhuntesl/PyGithub.git@esl-local-fix-watches \\r\\n```\\r\\n\\r\\nGrab a github token, set it as an environmental variable and run this snippet:\\r\\n\\r\\n```python\\r\\nfrom github import *\\r\\nimport os\\r\\ng = Github(login_or_token=os.getenv(\\\"GITHUB_TOKEN\\\"))\\r\\nu=g.get_user()\\r\\norg=g.get_organization(\\\"basho\\\")\\r\\nfor r in org.get_repos():\\r\\n u.add_to_watched(r)\\r\\n```\\r\\n\\r\\n### TADA \\r\\n\\r\\nNow you're subscribed to every currently public basho repository on github\\r\\n\\r\\n### Next \\r\\n\\r\\nPerform this same operation using [tentacat](https://github.com/edgurgel/tentacat).\\r\\n\\r\\n\",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/147\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/147/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/147/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/147/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/147\",\"id\":321125918,\"node_id\":\"MDU6SXNzdWUzMjExMjU5MTg=\",\"number\":147,\"title\":\"Add search/issues endpoint\",\"user\":{\"login\":\"Ryman\",\"id\":994978,\"node_id\":\"MDQ6VXNlcjk5NDk3OA==\",\"avatar_url\":\"https://avatars2.githubusercontent.com/u/994978?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/Ryman\",\"html_url\":\"https://github.com/Ryman\",\"followers_url\":\"https://api.github.com/users/Ryman/followers\",\"following_url\":\"https://api.github.com/users/Ryman/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/Ryman/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/Ryman/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/Ryman/subscriptions\",\"organizations_url\":\"https://api.github.com/users/Ryman/orgs\",\"repos_url\":\"https://api.github.com/users/Ryman/repos\",\"events_url\":\"https://api.github.com/users/Ryman/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/Ryman/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":0,\"created_at\":\"2018-05-08T10:16:56Z\",\"updated_at\":\"2018-05-08T10:16:56Z\",\"closed_at\":null,\"author_association\":\"NONE\",\"body\":\"It looks like the rest of the Search API is supported but the `search/issues` endpoint isn't, it would be great to have that support :) \",\"score\":1.0},{\"url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/119\",\"repository_url\":\"https://api.github.com/repos/edgurgel/tentacat\",\"labels_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/119/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/119/comments\",\"events_url\":\"https://api.github.com/repos/edgurgel/tentacat/issues/119/events\",\"html_url\":\"https://github.com/edgurgel/tentacat/issues/119\",\"id\":234972213,\"node_id\":\"MDU6SXNzdWUyMzQ5NzIyMTM=\",\"number\":119,\"title\":\"Support for v4 GraphQL\",\"user\":{\"login\":\"mgwidmann\",\"id\":5035724,\"node_id\":\"MDQ6VXNlcjUwMzU3MjQ=\",\"avatar_url\":\"https://avatars1.githubusercontent.com/u/5035724?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/mgwidmann\",\"html_url\":\"https://github.com/mgwidmann\",\"followers_url\":\"https://api.github.com/users/mgwidmann/followers\",\"following_url\":\"https://api.github.com/users/mgwidmann/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/mgwidmann/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/mgwidmann/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/mgwidmann/subscriptions\",\"organizations_url\":\"https://api.github.com/users/mgwidmann/orgs\",\"repos_url\":\"https://api.github.com/users/mgwidmann/repos\",\"events_url\":\"https://api.github.com/users/mgwidmann/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/mgwidmann/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":0,\"created_at\":\"2017-06-10T01:58:51Z\",\"updated_at\":\"2017-06-10T01:58:51Z\",\"closed_at\":null,\"author_association\":\"CONTRIBUTOR\",\"body\":\"Could be just basic but it'd be nice to be able to easily specify the query and the parameters w/ the client and have it run it for you. Something like:\\r\\n\\r\\n```elixir\\r\\nTentacat.GraphQL.query(@query, %{params: :go_here}, client)\\r\\n```\",\"score\":1.0}]}", + "headers": { + "Server": "GitHub.com", + "Date": "Tue, 05 Jun 2018 10:41:07 GMT", + "Content-Type": "application/json; charset=utf-8", + "Content-Length": "34863", + "Status": "200 OK", + "X-RateLimit-Limit": "10", + "X-RateLimit-Remaining": "6", + "X-RateLimit-Reset": "1528195268", + "Cache-Control": "no-cache", + "X-GitHub-Media-Type": "github.v3; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-Runtime-rack": "0.279231", + "X-GitHub-Request-Id": "CAF4:1003:31FAFA:72E6F2:5B1668C3" + }, + "status_code": 200, + "type": "ok" + } + } +] \ No newline at end of file diff --git a/test/search_test.exs b/test/search_test.exs index 4e854e3..e8268be 100644 --- a/test/search_test.exs +++ b/test/search_test.exs @@ -60,4 +60,21 @@ defmodule Tentacat.SearchTest do repositories(@client, params, pagination: :none) end end + + test "issues/2" do + use_cassette "search#issues" do + params = %{q: "repo:edgurgel/tentacat is:merged", sort: "comments"} + + assert {_, %{"incomplete_results" => false, "items" => _}, _} = issues(@client, params) + end + end + + test "issues/2 with none-pagination" do + use_cassette "search#issues" do + params = %{q: "repo:edgurgel/tentacat is:open", sort: "comments"} + + assert {_, %{"incomplete_results" => false, "items" => _}, _} = + issues(@client, params, pagination: :none) + end + end end