Class: Appsendr::App

Inherits:
Object
  • Object
show all
Defined in:
lib/appsendr/app.rb

Constant Summary collapse

API_BASE_URL =
"https://api.appsendr.com"

Class Method Summary collapse

Class Method Details

.create(file, icon = nil, identifier = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/appsendr/app.rb', line 9

def self.create(file,icon=nil,identifier=nil)
  #File.new("test.apk", 'rb')
  
  params = {:app_data => file, :multipart => true}
  params[:icon] = icon if icon
  params[:identifier] = identifier if identifier
  
  begin
    response = RestClient.post _url("new"), params
    return JSON.parse response.to_str
  rescue => e
    return JSON.parse e.response unless e.response.empty?
  end
end

.destroy(id, token) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/appsendr/app.rb', line 24

def self.destroy(id, token)
  params = {"token" => token}

  begin
    response = RestClient.delete _url(id, params)

    return (response.code == 204)
  rescue => e
    return false
  end
end

.details(id) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/appsendr/app.rb', line 36

def self.details(id)
  begin
    response = RestClient.get _url(id)
    return JSON.parse response.to_str
  rescue => e
    return JSON.parse e.response
  end
end