Skip to content

Commit 0122749

Browse files
committed
Merge pull request #2 from diacode/feature/stories-endpoint
Story endpoint integration
2 parents a8fcfc5 + 3e24b51 commit 0122749

7 files changed

Lines changed: 77 additions & 8 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ Based heavily on the [Tentacat](https://github.com/edgurgel/tentacat) and [ExTwi
4444
* [ ] Source Commits
4545
* [x] Stories
4646
* [x] Get
47-
* [ ] Story
47+
* [ ] Post
48+
* [x] Story
49+
* [x] Get
50+
* [ ] Put
51+
* [ ] Delete
4852
* [ ] Story Tasks
4953
* [ ] Story Transitions
5054
* [ ] Workspaces

lib/extracker/projects.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ defmodule ExTracker.Projects do
77
88
## Example
99
10-
ExTracker.Projects.find("12345", client)
10+
ExTracker.Projects.find(client, "12345")
1111
1212
More info at: https://www.pivotaltracker.com/help/api/rest/v5#Project
1313
"""
14-
@spec find(pos_integer, Client.t, [{atom, binary}] | []) :: ExTracker.Record.Project.t
15-
def find(project_id, client, params \\ []) do
14+
@spec find(Client.t, pos_integer, [{atom, binary}] | []) :: ExTracker.Record.Project.t
15+
def find(client, project_id, params \\ []) do
1616
get("projects/#{project_id}", client, params)
1717
|> ExTracker.Parser.parse_project
1818
end

lib/extracker/stories.ex

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,30 @@ defmodule ExTracker.Stories do
22
import ExTracker
33
alias Extracker.Client
44

5+
@doc """
6+
Get a single `story`.
7+
8+
## Example
9+
10+
ExTracker.Stories.find(client, "12345")
11+
12+
More info at: https://www.pivotaltracker.com/help/api/rest/v5#stories_story_id_get
13+
"""
14+
@spec find(Client.t, pos_integer, [{atom, binary}] | []) :: ExTracker.Record.Story.t
15+
def find(client, story_id, params \\ []) do
16+
get("stories/#{story_id}", client, params)
17+
|> ExTracker.Parser.parse_story
18+
end
19+
20+
521
@doc """
622
Get all stories from project
723
824
## Example
925
1026
ExTracker.Stories.list(client, project_id)
1127
12-
More info at:https://www.pivotaltracker.com/help/api/rest/v5#Stories
28+
More info at: https://www.pivotaltracker.com/help/api/rest/v5#Stories
1329
"""
1430
@spec list(Client.t, pos_integer, [{atom, binary}] | []) :: [ExTracker.Record.Story.t] | []
1531
def list(client, project_id, params \\ []) do
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[
2+
{
3+
"request": {
4+
"body": "\"\"",
5+
"headers": {
6+
"User-agent": "extracker",
7+
"X-TrackerToken": "d55c3bc1f74346b843ca84ba340b29bf"
8+
},
9+
"method": "get",
10+
"options": [],
11+
"request_body": "",
12+
"url": "https://www.pivotaltracker.com/services/v5/stories/66727974"
13+
},
14+
"response": {
15+
"body": "{\"kind\":\"story\",\"id\":66727974,\"created_at\":\"2014-02-10T00:00:00Z\",\"updated_at\":\"2014-03-02T07:11:04Z\",\"accepted_at\":\"2014-02-11T00:00:00Z\",\"story_type\":\"chore\",\"name\":\"Setup development environment\",\"description\":\"We need 2 machines set up\",\"current_state\":\"accepted\",\"requested_by_id\":1266314,\"url\":\"https://www.pivotaltracker.com/story/show/66727974\",\"project_id\":1027488,\"owner_ids\":[],\"labels\":[]}",
16+
"headers": {
17+
"Content-Type": "application/json; charset=utf-8",
18+
"Transfer-Encoding": "chunked",
19+
"Status": "200 OK",
20+
"Cache-Control": "max-age=0, private, must-revalidate",
21+
"Date": "Tue, 01 Mar 2016 06:04:50 GMT",
22+
"X-Tracker-Project-Version": "120",
23+
"X-Request-Id": "75bae1844699644e82d9257ef0a3a29f",
24+
"X-UA-Compatible": "IE=Edge,chrome=1",
25+
"ETag": "\"cb76acb351c88232bdc0a95c1ab73bc9\"",
26+
"X-Runtime": "0.056699",
27+
"X-Rack-Cache": "miss",
28+
"X-Powered-By": "Phusion Passenger Enterprise",
29+
"Server": "nginx + Phusion Passenger",
30+
"Access-Control-Allow-Origin": "*",
31+
"Access-Control-Allow-Credentials": "false",
32+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
33+
"Access-Control-Allow-Headers": "X-TrackerToken,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Tracker-Warn-Unless-Project-Version-Is",
34+
"X-Tracker-Client-Pinger-Interval": "12"
35+
},
36+
"status_code": 200,
37+
"type": "ok"
38+
}
39+
}
40+
]

test/projects_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule ExTracker.ProjectsTest do
2121

2222
test "find/3" do
2323
use_cassette "projects#find" do
24-
%Project{name: name, week_start_day: week_start_day} = find(@project_id, @client)
24+
%Project{name: name, week_start_day: week_start_day} = find(@client, @project_id)
2525
assert name == "My Sample Project"
2626
assert week_start_day == "Monday"
2727
end
@@ -30,7 +30,7 @@ defmodule ExTracker.ProjectsTest do
3030
test "find/3 with fields param" do
3131
use_cassette "projects#find and include epics and epic label" do
3232
%Project{name: name, epics: epics} =
33-
find( @project_id, @client,
33+
find(@client, @project_id,
3434
fields: ":default,epics(:default,label(name))")
3535
assert name == "My Sample Project"
3636
assert length(epics) > 1

test/stories_test.exs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@ defmodule ExTracker.StoriesTest do
77
doctest ExTracker.Stories
88

99
alias ExTracker.Support.Helpers
10+
alias ExTracker.Record.Story
1011

1112
@client ExTracker.Client.new(%{access_token: Helpers.pt_user_1.token})
1213
@project_id Helpers.pt_user_1.project_id
14+
@story_id Helpers.pt_user_1.story_id
1315

1416
setup_all do
1517
HTTPoison.start
1618
end
1719

20+
test "find/2" do
21+
use_cassette "stories#find" do
22+
%Story{name: name} = find(@client, @story_id)
23+
assert name == "Setup development environment"
24+
end
25+
end
26+
1827
test "list/2" do
1928
use_cassette "stories#list" do
2029
stories = list(@client, @project_id)

test/support/helpers.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule ExTracker.Support.Helpers do
22
# These API Tokens are for a user with just one Public Sample Project
33
def pt_user_1 do
4-
%{ username: "trackerapi1", password: "trackerapi1", token: "d55c3bc1f74346b843ca84ba340b29bf", project_id: 1027488 }
4+
%{ username: "trackerapi1", password: "trackerapi1", token: "d55c3bc1f74346b843ca84ba340b29bf", project_id: 1027488, story_id: 66727974 }
55
end
66

77
def pt_user_2 do

0 commit comments

Comments
 (0)