-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add #search to the project * specs for Project#search * Add README listing for Project#search
- Loading branch information
Showing
9 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module TrackerApi | ||
module Endpoints | ||
class Search | ||
attr_accessor :client | ||
|
||
def initialize(client) | ||
@client = client | ||
end | ||
|
||
def get(project_id, query, options={}) | ||
raise ArgumentError, 'Valid query string required to search' unless query.is_a?(String) | ||
|
||
options.key?(:body) ? options[:body][:query] = query : options[:body] = { query: query } | ||
data = client.get("/projects/#{project_id}/search", options).body | ||
|
||
raise Errors::UnexpectedData, 'Hash of search results expect' unless data.is_a? Hash | ||
|
||
Resources::SearchResultContainer.new(data) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module TrackerApi | ||
module Resources | ||
class EpicsSearchResult | ||
include Shared::Base | ||
|
||
attribute :epics, Array[Resources::Epic] | ||
attribute :total_hits, Integer | ||
attribute :total_hits_with_done, Integer | ||
attribute :kind, String | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module TrackerApi | ||
module Resources | ||
class SearchResultContainer | ||
include Shared::Base | ||
|
||
attribute :query, String | ||
attribute :stories, Resources::StoriesSearchResult | ||
attribute :epics, Resources::EpicsSearchResult | ||
attribute :kind, String | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module TrackerApi | ||
module Resources | ||
class StoriesSearchResult | ||
include Shared::Base | ||
|
||
attribute :stories, Array[Resources::Story] | ||
attribute :total_hits, Integer | ||
attribute :total_hits_with_done, Integer | ||
attribute :total_points, Float | ||
attribute :total_points_completed, Float | ||
attribute :kind, String | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"http_interactions":[{"request":{"method":"get","uri":"https://www.pivotaltracker.com/services/v5/projects/1027494","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Ruby/2.2.4 (x86_64-darwin15; ruby) TrackerApi/1.6.0 Faraday/0.9.2"],"X-TrackerToken":["77f9b9a466c436e6456939208c84c973"]}},"response":{"status":{"code":200,"message":null},"headers":{"Access-Control-Allow-Credentials":["false"],"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"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=0, private, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Mon, 10 Apr 2017 18:34:56 GMT"],"Etag":["\"46471d209a7b433eba4710d6f9b001cb\""],"Server":["nginx + Phusion Passenger"],"Status":["200 OK"],"Strict-Transport-Security":["max-age=31536000; includeSubDomains; preload"],"X-Powered-By":["Phusion Passenger Enterprise"],"X-Rack-Cache":["miss"],"X-Request-Id":["480867069c44e12ed5491e58c5bf6542"],"X-Runtime":["0.057795"],"X-Tracker-Client-Pinger-Interval":["20"],"X-Tracker-Project-Version":["3"],"X-Ua-Compatible":["IE=Edge,chrome=1"],"X-Vcap-Request-Id":["ca69d9ea-1ecc-42af-7681-2957a99f14c1"],"Content-Length":["845"],"Connection":["keep-alive"]},"body":{"encoding":"ASCII-8BIT","string":"{\"id\":1027494,\"kind\":\"project\",\"name\":\"My Sample Project\",\"version\":3,\"iteration_length\":1,\"week_start_day\":\"Monday\",\"point_scale\":\"0,1,2,3\",\"point_scale_is_custom\":false,\"bugs_and_chores_are_estimatable\":false,\"automatic_planning\":true,\"enable_tasks\":true,\"time_zone\":{\"kind\":\"time_zone\",\"olson_name\":\"America/Los_Angeles\",\"offset\":\"-07:00\"},\"velocity_averaged_over\":3,\"number_of_done_iterations_to_show\":12,\"has_google_domain\":false,\"profile_content\":\"This is a demo project, created by Tracker, with example stories for a simple shopping web site.\",\"enable_incoming_emails\":true,\"initial_velocity\":10,\"public\":false,\"atom_enabled\":false,\"project_type\":\"demo\",\"start_time\":\"2014-02-10T08:00:00Z\",\"created_at\":\"2014-03-02T07:18:28Z\",\"updated_at\":\"2014-03-02T07:18:28Z\",\"account_id\":621388,\"current_iteration_number\":166,\"enable_following\":true}"},"http_version":null},"recorded_at":"Mon, 10 Apr 2017 18:34:56 GMT"},{"request":{"method":"get","uri":"https://www.pivotaltracker.com/services/v5/projects/1027494/search","body":{"encoding":"UTF-8","string":"{\"query\":\"name:\\\"story to test search\\\"\"}"},"headers":{"User-Agent":["Ruby/2.2.4 (x86_64-darwin15; ruby) TrackerApi/1.6.0 Faraday/0.9.2"],"X-TrackerToken":["77f9b9a466c436e6456939208c84c973"],"Content-Type":["application/json"]}},"response":{"status":{"code":200,"message":null},"headers":{"Access-Control-Allow-Credentials":["false"],"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"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=0, private, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Mon, 10 Apr 2017 18:34:57 GMT"],"Etag":["\"8a5f6bd57393dc3dcfc9ee0386be8575\""],"Server":["nginx + Phusion Passenger"],"Status":["200 OK"],"Strict-Transport-Security":["max-age=31536000; includeSubDomains; preload"],"X-Powered-By":["Phusion Passenger Enterprise"],"X-Rack-Cache":["miss"],"X-Request-Id":["0976a6e85fab21b3a8c6767650c4f4b8"],"X-Runtime":["0.509539"],"X-Tracker-Client-Pinger-Interval":["20"],"X-Tracker-Project-Version":["3"],"X-Ua-Compatible":["IE=Edge,chrome=1"],"X-Vcap-Request-Id":["331980c0-1e08-4e76-5707-302b5cae005d"],"Content-Length":["506"],"Connection":["keep-alive"]},"body":{"encoding":"ASCII-8BIT","string":"{\"stories\":{\"stories\":[{\"kind\":\"story\",\"id\":143444685,\"created_at\":\"2017-04-10T18:20:52Z\",\"updated_at\":\"2017-04-10T18:20:52Z\",\"story_type\":\"feature\",\"name\":\"story to test search\",\"current_state\":\"unscheduled\",\"requested_by_id\":1266318,\"url\":\"https://www.pivotaltracker.com/story/show/143444685\",\"project_id\":1027494,\"owner_ids\":[],\"labels\":[]}],\"total_points\":0,\"total_points_completed\":0,\"total_hits\":1,\"total_hits_with_done\":1},\"epics\":{\"epics\":[],\"total_hits\":0},\"query\":\"name:\\\"story to test search\\\"\"}"},"http_version":null},"recorded_at":"Mon, 10 Apr 2017 18:34:57 GMT"}],"recorded_with":"VCR 3.0.3"} |