Class: Upscrn::Client
- Inherits:
-
Object
- Object
- Upscrn::Client
- Defined in:
- lib/upscrn_client/client.rb
Class Attribute Summary collapse
-
.auth_token ⇒ Object
Returns the value of attribute auth_token.
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
-
#params ⇒ Object
Returns the value of attribute params.
-
#resources ⇒ Object
Returns the value of attribute resources.
Class Method Summary collapse
- .config {|_self| ... } ⇒ Object
-
.projects(auth_token) ⇒ Object
return a list of projects for a given user list is returned in json format.
-
.upload_screenshot(filename, auth_token, options = {}) ⇒ Object
Pass :project_id in the options to upload to a particular project.
Instance Method Summary collapse
- #clean ⇒ Object
- #comment(params = {}) ⇒ Object
- #comments(params = {}) ⇒ Object
- #get(clean = true) ⇒ Object
-
#initialize(auth_token = nil) ⇒ Client
constructor
A new instance of Client.
- #post(clean = true) ⇒ Object
- #project(id, params = {}) ⇒ Object
- #projects(params = {}) ⇒ Object
- #put(clean = true) ⇒ Object
- #screenshot(id, params = {}) ⇒ Object
- #screenshots(params = {}) ⇒ Object
- #video(id, params = {}) ⇒ Object
- #videos(params = {}) ⇒ Object
Constructor Details
#initialize(auth_token = nil) ⇒ Client
Returns a new instance of Client.
67 68 69 70 71 |
# File 'lib/upscrn_client/client.rb', line 67 def initialize(auth_token = nil) @auth_token = auth_token || self.class.auth_token @resources = [] @params = {} end |
Class Attribute Details
.auth_token ⇒ Object
Returns the value of attribute auth_token.
5 6 7 |
# File 'lib/upscrn_client/client.rb', line 5 def auth_token @auth_token end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
63 64 65 |
# File 'lib/upscrn_client/client.rb', line 63 def auth_token @auth_token end |
#params ⇒ Object
Returns the value of attribute params.
63 64 65 |
# File 'lib/upscrn_client/client.rb', line 63 def params @params end |
#resources ⇒ Object
Returns the value of attribute resources.
63 64 65 |
# File 'lib/upscrn_client/client.rb', line 63 def resources @resources end |
Class Method Details
.config {|_self| ... } ⇒ Object
7 8 9 |
# File 'lib/upscrn_client/client.rb', line 7 def config yield self end |
.projects(auth_token) ⇒ Object
return a list of projects for a given user list is returned in json format
47 48 49 50 |
# File 'lib/upscrn_client/client.rb', line 47 def projects(auth_token) puts "DEPRECATED: will be removed on version 0.3" perform('get', 'projects', auth_token) end |
.upload_screenshot(filename, auth_token, options = {}) ⇒ Object
Pass :project_id in the options to upload to a particular project
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/upscrn_client/client.rb', line 17 def upload_screenshot(filename, auth_token, = {}) puts "DEPRECATED: will be removed on version 0.3" #puts "filepath: #{filepath}" @result = Hash.new @result['success'] = true file = File.open filename, 'r' begin if [:project_id] post_response = perform("post", "projects/#{[:project_id]}/screenshots", auth_token, {:screenshot => {:image => @image}}) else post_response = perform('post', 'screenshots', auth_token, {:screenshot => {:image => file}}) end #puts "response: #{post_response}" @url = post_response["url"] @result['success'] = true @result['url'] = @url #puts "url = #{@url}" @url rescue Exception => e #puts "Exception! #{e.message}" @result['success'] = false @result['error'] = e..to_s end @result end |
Instance Method Details
#clean ⇒ Object
150 151 152 153 154 155 |
# File 'lib/upscrn_client/client.rb', line 150 def clean tap do @resources = [] @params = {} end end |
#comment(params = {}) ⇒ Object
123 124 125 126 127 128 |
# File 'lib/upscrn_client/client.rb', line 123 def comment(params = {}) tap do @resources += ['comments'] @params.merge!(params) end end |
#comments(params = {}) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/upscrn_client/client.rb', line 88 def comments(params = {}) tap do @resources += ['comments'] @params.merge!(params) end end |
#get(clean = true) ⇒ Object
132 133 134 135 136 |
# File 'lib/upscrn_client/client.rb', line 132 def get(clean = true) result = client[build_path(@auth_token,@resources,@params)].get self.clean if clean JSON.parse result end |
#post(clean = true) ⇒ Object
138 139 140 141 142 |
# File 'lib/upscrn_client/client.rb', line 138 def post(clean = true) result = client[build_path(@auth_token,@resources)].post(@params) self.clean if clean JSON.parse result end |
#project(id, params = {}) ⇒ Object
102 103 104 105 106 107 |
# File 'lib/upscrn_client/client.rb', line 102 def project(id , params = {}) tap do @resources = ['projects',id] @params.merge!(params) end end |
#projects(params = {}) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/upscrn_client/client.rb', line 74 def projects(params = {}) tap do @resources = ['projects'] @params.merge!(params) end end |
#put(clean = true) ⇒ Object
144 145 146 147 148 |
# File 'lib/upscrn_client/client.rb', line 144 def put(clean = true) result = client[build_path(@auth_token,@resources)].put(@params) self.clean if clean JSON.parse result end |
#screenshot(id, params = {}) ⇒ Object
109 110 111 112 113 114 |
# File 'lib/upscrn_client/client.rb', line 109 def screenshot(id , params = {}) tap do @resources += ['screenshots',id] @params.merge!(params) end end |
#screenshots(params = {}) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/upscrn_client/client.rb', line 81 def screenshots(params = {}) tap do @resources += ['screenshots'] @params.merge!(params) end end |
#video(id, params = {}) ⇒ Object
116 117 118 119 120 121 |
# File 'lib/upscrn_client/client.rb', line 116 def video(id , params = {}) tap do @resources += ['videos',id] @params.merge!(params) end end |
#videos(params = {}) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/upscrn_client/client.rb', line 95 def videos(params = {}) tap do @resources += ['videos'] @params.merge!(params) end end |