Class: CoderCompanion::API
- Inherits:
-
Object
- Object
- CoderCompanion::API
- Defined in:
- lib/codercompanion/api.rb
Instance Method Summary collapse
- #get_temporary_access_key ⇒ Object
-
#initialize ⇒ API
constructor
A new instance of API.
- #notify_s3_upload(key) ⇒ Object
- #upload(file) ⇒ Object
Constructor Details
#initialize ⇒ API
Returns a new instance of API.
3 4 5 |
# File 'lib/codercompanion/api.rb', line 3 def initialize() # puts CoderCompanion::config end |
Instance Method Details
#get_temporary_access_key ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/codercompanion/api.rb', line 21 def get_temporary_access_key begin RestClient.post("#{CoderCompanion::config["host"]}/project/get_temporary_access_key.json", :access_key => CoderCompanion::config["project"]["access_key"], :access_id => CoderCompanion::config["user"]["access_id"]) { |response, request, result, &block| return (response.code == CoderCompanion::STATUS_OK) ? response : nil } rescue return nil end end |
#notify_s3_upload(key) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/codercompanion/api.rb', line 33 def notify_s3_upload(key) begin RestClient.post("#{CoderCompanion::config["host"]}/project/notify_project_upload.json", :s3_key => key, :access_key => CoderCompanion::config["project"]["access_key"], :access_id => CoderCompanion::config["user"]["access_id"]) { |response, request, result, &block| return (response.code == CoderCompanion::STATUS_OK) ? response : nil } rescue return nil end end |
#upload(file) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/codercompanion/api.rb', line 7 def upload(file) response = nil begin response = RestClient.post(CoderCompanion::config["host"] + '/update_project.json', :myfile => File.new(file),# /Users/oseghale/Projects/JinglePage/JingleParser/test_upload.jingle'), :access_key => CoderCompanion::config["project"]["access_key"], :access_id => CoderCompanion::config["user"]["access_id"]) { |response, request, result, &block| return response.code || nil } rescue return CoderCompanion::GENERIC_ERROR end end |