Class: PivotalTrackerApi::API
- Inherits:
-
Object
- Object
- PivotalTrackerApi::API
- Includes:
- Project, ProjectMembership, Story
- Defined in:
- lib/pivotal_tracker_api.rb
Constant Summary collapse
- DOMAIN_URL =
"https://www.pivotaltracker.com"
- API_URL =
"https://www.pivotaltracker.com/services/v5"
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #delete(path, params = {}) ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(token_api, params = {}) ⇒ API
constructor
A new instance of API.
- #post(path, params = {}, headers = {}) ⇒ Object
- #put(path, params = {}) ⇒ Object
- #upload(path, filename) ⇒ Object
Methods included from ProjectMembership
#find_membership_by_project_id
Methods included from Project
#find_project_by_id, #projects
Methods included from Story
#create_attachment, #create_comment, #create_story, #find_stories_by_project_id, #find_story_by_project_id_and_id, #update_story, #upload_attachment
Constructor Details
#initialize(token_api, params = {}) ⇒ API
Returns a new instance of API.
21 22 23 |
# File 'lib/pivotal_tracker_api.rb', line 21 def initialize(token_api, params={}) @token= token_api end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
19 20 21 |
# File 'lib/pivotal_tracker_api.rb', line 19 def token @token end |
Instance Method Details
#delete(path, params = {}) ⇒ Object
54 55 56 |
# File 'lib/pivotal_tracker_api.rb', line 54 def delete(path, params={}) parse_response service[path].delete end |
#get(path, params = {}) ⇒ Object
25 26 27 |
# File 'lib/pivotal_tracker_api.rb', line 25 def get(path, params={}) parse_response service[path].get(params) end |
#post(path, params = {}, headers = {}) ⇒ Object
33 34 35 |
# File 'lib/pivotal_tracker_api.rb', line 33 def post(path, params={}, headers={}) parse_response service[path].post(params, headers) end |
#put(path, params = {}) ⇒ Object
29 30 31 |
# File 'lib/pivotal_tracker_api.rb', line 29 def put(path, params={} ) parse_response service[path].put(params) end |
#upload(path, filename) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pivotal_tracker_api.rb', line 37 def upload(path, filename) url = URI.parse(API_URL+path) req = Net::HTTP::Post::Multipart.new( url.path, "file" => UploadIO.new(filename, "multipart/form-data")) http = Net::HTTP.new(url.host, url.port) req["X-TrackerToken"] = @token # to debug # http.set_debug_output($stderr) if url.scheme == 'https' http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end response = http.request(req) parse_response response end |