Class: Android::Publisher::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/android/publisher/connection.rb

Constant Summary collapse

API_URL =
URI.parse('https://www.googleapis.com/androidpublisher/v2/applications/')
UPLOAD_URL =
URI.parse('https://www.googleapis.com/upload/androidpublisher/v2/applications/')

Instance Method Summary collapse

Constructor Details

#initialize(authorized_connection, package_name, endpoints = []) ⇒ Connection

Returns a new instance of Connection.



11
12
13
14
15
# 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

Instance Method Details

#add_endpoint(endpoint) ⇒ Object



17
18
19
# File 'lib/android/publisher/connection.rb', line 17

def add_endpoint(endpoint)
  Connection.new(authorized_connection,package_name, [*@endpoints, endpoint])
end

#delete(path = "") ⇒ Object



43
44
45
# File 'lib/android/publisher/connection.rb', line 43

def delete(path = "")
  authorized_connection.delete(append(path))
end

#get(path = "") ⇒ Object



29
30
31
# File 'lib/android/publisher/connection.rb', line 29

def get(path = "")
  authorized_connection.get(append(path))
end

#just_post(path = "", params = {}) ⇒ Object



33
34
35
# 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 = {}) ⇒ Object



47
48
49
# File 'lib/android/publisher/connection.rb', line 47

def patch(path = "", params = {})
  authorized_connection.patch(append(path), params)
end

#post(path = "", params = {}) ⇒ Object



37
38
39
# File 'lib/android/publisher/connection.rb', line 37

def post(path = "", params = {})
  authorized_connection.post(append(path), params)
end

#put(params = {}) ⇒ Object



25
26
27
# File 'lib/android/publisher/connection.rb', line 25

def put(params = {})
  authorized_connection.put(append(""), params)
end

#remove_endpointObject



21
22
23
# File 'lib/android/publisher/connection.rb', line 21

def remove_endpoint
  Connection.new(authorized_connection,package_name, @endpoints[0..-2])
end

#upload(file) ⇒ Object



51
52
53
54
55
56
57
58
# 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