Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit e75a976

Browse files
committed
adds ability to get single label from project
1 parent 7d66f6d commit e75a976

5 files changed

Lines changed: 136 additions & 0 deletions

File tree

lib/tracker_api/endpoints/labels.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ def initialize(client)
77
@client = client
88
end
99

10+
def get_label(project_id, id, params={})
11+
data = client.get("/projects/#{project_id}/labels/#{id}", params: params).body
12+
13+
Resources::Label.new({ client: client }.merge(data))
14+
end
15+
1016
def get(project_id, params={})
1117
data = client.paginate("/projects/#{project_id}/labels", params: params)
1218
raise Errors::UnexpectedData, 'Array of labels expected' unless data.is_a? Array

lib/tracker_api/resources/project.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def labels(params = {})
6363
end
6464
end
6565

66+
def label(label_id, params = {})
67+
Endpoints::Labels.new(client).get_label(id,label_id, params)
68+
end
69+
6670
# Provides a list of all the epics in the project.
6771
#
6872
# @param [Hash] params

test/project_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@
6363
end
6464
end
6565

66+
describe '.label' do
67+
it 'gets a single label from this project' do
68+
VCR.use_cassette('get label', record: :new_episodes) do
69+
label = project.label(7849080)
70+
71+
_(label).must_be_instance_of TrackerApi::Resources::Label
72+
end
73+
end
74+
end
75+
6676
describe '.iterations' do
6777
it 'can get only done iterations' do
6878
VCR.use_cassette('get done iterations', record: :new_episodes) do

test/vcr/cassettes/get_label.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"method": "get", "uri": "https://www.pivotaltracker.com/services/v5/projects/1027488/labels/5431", "body": {"encoding": "US-ASCII", "string": "" }, "headers": {"User-Agent": ["Ruby/2.7.5 (arm64-darwin21; ruby) TrackerApi/1.16.0 Faraday/2.8.1" ], "X-TrackerToken": ["d55c3bc1f74346b843ca84ba340b29bf" ], "Accept": ["application/json" ] } }, "response": {"status": {"code": 404, "message": "Not Found" }, "headers": {"content-type": ["application/json; charset=utf-8" ], "status": ["404 Not Found" ], "cache-control": ["no-cache" ], "x-request-id": ["2f2cfed8-9bc7-49c7-94ed-a67e5f89d414" ], "x-runtime": ["0.133386" ], "x-frame-options": ["SAMEORIGIN" ], "x-content-type-options": ["nosniff, nosniff" ], "date": ["Mon, 19 Aug 2024 18:30:35 GMT" ], "x-powered-by": ["Phusion Passenger" ], "server": ["nginx + Phusion Passenger" ], "access-control-allow-origin": ["*" ], "access-control-allow-credentials": ["false" ], "access-control-allow-methods": ["GET, POST, PUT, DELETE, OPTIONS" ], "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" ], "x-tracker-client-pinger-interval": ["20" ], "strict-transport-security": ["max-age=31536000; includeSubDomains; preload" ], "x-xss-protection": ["1; mode=block" ], "content-encoding": ["gzip" ], "via": ["1.1 google" ], "alt-svc": ["h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" ], "transfer-encoding": ["chunked" ] }, "body": {"encoding": "UTF-8", "string": "{\"code\":\"unfound_resource\",\"kind\":\"error\",\"error\":\"The object you tried to access could not be found. It may have been removed by another user, you may be using the ID of another object type, or you may be trying to access a sub-resource at the wrong point in a tree.\"}" } }, "recorded_at": "Mon, 19 Aug 2024 18:30:34 GMT" }, {"request": {"method": "get", "uri": "https://www.pivotaltracker.com/services/v5/projects/1027488/labels/7849080", "body": {"encoding": "US-ASCII", "string": "" }, "headers": {"User-Agent": ["Ruby/2.7.5 (arm64-darwin21; ruby) TrackerApi/1.16.0 Faraday/2.8.1" ], "X-TrackerToken": ["d55c3bc1f74346b843ca84ba340b29bf" ], "Accept": ["application/json" ] } }, "response": {"status": {"code": 200, "message": "OK" }, "headers": {"content-type": ["application/json; charset=utf-8" ], "status": ["200 OK" ], "cache-control": ["max-age=0, private, must-revalidate" ], "x-tracker-project-version": ["728" ], "x-request-id": ["0fd34d62-bdda-48a9-b63f-3513c65cd0f0" ], "etag": ["W/\"fc0ba785ea8bde512fd0417626fc0bf9\"" ], "x-frame-options": ["SAMEORIGIN" ], "x-runtime": ["0.080823" ], "x-content-type-options": ["nosniff, nosniff" ], "date": ["Mon, 19 Aug 2024 18:31:45 GMT" ], "x-powered-by": ["Phusion Passenger" ], "server": ["nginx + Phusion Passenger" ], "access-control-allow-origin": ["*" ], "access-control-allow-credentials": ["false" ], "access-control-allow-methods": ["GET, POST, PUT, DELETE, OPTIONS" ], "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" ], "x-tracker-client-pinger-interval": ["20" ], "strict-transport-security": ["max-age=31536000; includeSubDomains; preload" ], "x-xss-protection": ["1; mode=block" ], "content-encoding": ["gzip" ], "via": ["1.1 google" ], "alt-svc": ["h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" ], "transfer-encoding": ["chunked" ] }, "body": {"encoding": "UTF-8", "string": "{\"kind\":\"label\",\"id\":7849080,\"project_id\":1027488,\"name\":\"admin\",\"created_at\":\"2014-03-02T07:11:04Z\",\"updated_at\":\"2014-03-02T07:11:04Z\"}" } }, "recorded_at": "Mon, 19 Aug 2024 18:31:45 GMT" } ], "recorded_with": "VCR 6.3.0" }
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"http_interactions":
3+
[
4+
{
5+
"request":
6+
{
7+
"method": "get",
8+
"uri": "https://www.pivotaltracker.com/services/v5/projects/1027488/label/5431",
9+
"body":
10+
{
11+
"encoding": "US-ASCII",
12+
"string": ""
13+
},
14+
"headers":
15+
{
16+
"User-Agent":
17+
[
18+
"Ruby/2.2.3 (x86_64-darwin15; ruby) TrackerApi/0.2.12 Faraday/0.9.2"
19+
],
20+
"X-TrackerToken":
21+
[
22+
"d55c3bc1f74346b843ca84ba340b29bf"
23+
]
24+
}
25+
},
26+
"response":
27+
{
28+
"status":
29+
{
30+
"code": 200,
31+
"message": null
32+
},
33+
"headers":
34+
{
35+
"Content-Type":
36+
[
37+
"application/json; charset=utf-8"
38+
],
39+
"Status":
40+
[
41+
"200 OK"
42+
],
43+
"Cache-Control":
44+
[
45+
"max-age=0, private, must-revalidate"
46+
],
47+
"Date":
48+
[
49+
"Sat, 13 Feb 2016 23:35:55 GMT"
50+
],
51+
"X-Tracker-Project-Version":
52+
[
53+
"112"
54+
],
55+
"X-Request-Id":
56+
[
57+
"47d462e385f9e42fa2121b900e118f50"
58+
],
59+
"X-UA-Compatible":
60+
[
61+
"IE=Edge,chrome=1"
62+
],
63+
"ETag":
64+
[
65+
"\"09b7b80839393f41a467e3262507852b\""
66+
],
67+
"X-Runtime":
68+
[
69+
"0.045784"
70+
],
71+
"X-Rack-Cache":
72+
[
73+
"miss"
74+
],
75+
"X-Powered-By":
76+
[
77+
"Phusion Passenger Enterprise"
78+
],
79+
"Server":
80+
[
81+
"nginx + Phusion Passenger"
82+
],
83+
"Access-Control-Allow-Origin":
84+
[
85+
"*"
86+
],
87+
"Access-Control-Allow-Credentials":
88+
[
89+
"false"
90+
],
91+
"Access-Control-Allow-Methods":
92+
[
93+
"GET, POST, PUT, DELETE, OPTIONS"
94+
],
95+
"Access-Control-Allow-Headers":
96+
[
97+
"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"
98+
],
99+
"X-Tracker-Client-Pinger-Interval":
100+
[
101+
"12"
102+
]
103+
},
104+
"body":
105+
{
106+
"encoding": "UTF-8",
107+
"string": "{\"kind\":\"label\",\"id\":7849080,\"project_id\":1027488,\"name\":\"admin\",\"created_at\":\"2014-03-02T07:11:04Z\",\"updated_at\":\"2014-03-02T07:11:04Z\"}"
108+
},
109+
"http_version": null
110+
},
111+
"recorded_at": "Sat, 13 Feb 2016 23:35:55 GMT"
112+
}
113+
],
114+
"recorded_with": "VCR 2.9.3"
115+
}

0 commit comments

Comments
 (0)