class Android::Publisher::Connection
Constants
- API_URL
- UPLOAD_URL
Attributes
endpoints[R]
package_name[R]
Public Class Methods
new(authorized_connection, package_name, endpoints = [])
click to toggle source
# File lib/android/publisher/connection.rb, line 11 def initialize(authorized_connection, package_name, endpoints = []) @authorized_connection = authorized_connection @package_name = package_name @endpoints = endpoints end
Public Instance Methods
add_endpoint(endpoint)
click to toggle source
# File lib/android/publisher/connection.rb, line 17 def add_endpoint(endpoint) Connection.new(authorized_connection,package_name, [*@endpoints, endpoint]) end
delete(path = "")
click to toggle source
# File lib/android/publisher/connection.rb, line 43 def delete(path = "") authorized_connection.delete(append(path)) end
get(path = "")
click to toggle source
# File lib/android/publisher/connection.rb, line 29 def get(path = "") authorized_connection.get(append(path)) end
just_post(path = "", params = {})
click to toggle source
# File lib/android/publisher/connection.rb, line 33 def just_post(path = "", params = {}) authorized_connection.post(URI.join(API_URL, "#{package_name}/", path), params) end
patch(path = "", params = {})
click to toggle source
# File lib/android/publisher/connection.rb, line 47 def patch(path = "", params = {}) authorized_connection.patch(append(path), params) end
post(path = "", params = {})
click to toggle source
# File lib/android/publisher/connection.rb, line 37 def post(path = "", params = {}) authorized_connection.post(append(path), params) end
put(params = {})
click to toggle source
# File lib/android/publisher/connection.rb, line 25 def put(params = {}) authorized_connection.put(append(""), params) end
remove_endpoint()
click to toggle source
# File lib/android/publisher/connection.rb, line 21 def remove_endpoint Connection.new(authorized_connection,package_name, @endpoints[0..-2]) end
upload(file)
click to toggle source
# File lib/android/publisher/connection.rb, line 51 def upload(file) params = { :headers => { 'Content-Type' => 'application/octet-stream', 'Content-Length'=> file.size.to_s }, :body => Faraday::UploadIO.new(file.path, 'application/octet-stream') } authorized_connection.post(upload_uri, params) end
Private Instance Methods
append(path)
click to toggle source
# File lib/android/publisher/connection.rb, line 71 def append(path) path.gsub!(/^\//, "") URI.join(API_URL, "#{package_name}/", get_endpoints, path).to_s end
get_endpoints()
click to toggle source
# File lib/android/publisher/connection.rb, line 76 def get_endpoints endpoints.empty? ? "" : "#{endpoints.join("/")}/" end
response(response_body)
click to toggle source
# File lib/android/publisher/connection.rb, line 67 def response(response_body) JSON.parse response_body end
upload_uri()
click to toggle source
# File lib/android/publisher/connection.rb, line 63 def upload_uri URI.join(UPLOAD_URL, "#{package_name}/", get_endpoints, "?uploadType=media").to_s end