Class: AppSendr::Client

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, host = 'appsendr.com') ⇒ Client

Returns a new instance of Client.



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

def initialize(api_key,host='appsendr.com')
  @api_key = api_key
  @host = host
  @resource = RestClient::Resource.new "http://#{@host}"
  
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



35
36
37
# File 'lib/appsendr/client.rb', line 35

def api_key
  @api_key
end

#hostObject (readonly)

Returns the value of attribute host.



35
36
37
# File 'lib/appsendr/client.rb', line 35

def host
  @host
end

#passwordObject (readonly)

Returns the value of attribute password.



35
36
37
# File 'lib/appsendr/client.rb', line 35

def password
  @password
end

#userObject (readonly)

Returns the value of attribute user.



35
36
37
# File 'lib/appsendr/client.rb', line 35

def user
  @user
end

Class Method Details

.auth(user, pass, host) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/appsendr/client.rb', line 26

def self.auth(user,pass,host)
    @resource = RestClient::Resource.new "http://#{host}"
    resp = @resource['/api/user/authenticate'].post({:username=>user, :password=>pass})
    json_resp = JSON.parse(resp)
    return nil unless json_resp
    return json_resp["message"] if json_resp["status"].to_i == 200 
    
end

.gem_version_stringObject



22
23
24
# File 'lib/appsendr/client.rb', line 22

def self.gem_version_string
  "appsendr-gem/#{version}"
end

.versionObject



18
19
20
# File 'lib/appsendr/client.rb', line 18

def self.version
  AppSendr::VERSION
end

Instance Method Details

#add_collaborator(app_id, emaill) ⇒ Object

add_collaborator



90
91
92
# File 'lib/appsendr/client.rb', line 90

def add_collaborator(app_id,emaill)
    post('/api/app/add_collaborator/'+app_id.to_s,{:email=>email});
end

#add_group(app_id, name) ⇒ Object



76
77
78
# File 'lib/appsendr/client.rb', line 76

def add_group(app_id,name)
    post('/api/app/add_group/'+app_id.to_s,{:name=>name});
end

#add_tester(app_id, email, name, udid = nil) ⇒ Object



64
65
66
# File 'lib/appsendr/client.rb', line 64

def add_tester(app_id,email,name,udid=nil)
    post('/api/app/add_tester/'+app_id.to_s,{:email=>email, :name=>name});
end

#authenticateObject



44
45
46
# File 'lib/appsendr/client.rb', line 44

def authenticate
    post('/api/user/authenticate');
end

#clear_testers(app_id) ⇒ Object



72
73
74
# File 'lib/appsendr/client.rb', line 72

def clear_testers(app_id)
    delete('/api/app/clear_testers/'+app_id.to_s,{});
end

#collaborators(app_id) ⇒ Object



98
99
100
# File 'lib/appsendr/client.rb', line 98

def collaborators(app_id)
    JSON.parse(get('/api/app/collaborators/'+app_id.to_s))
end

#create(name) ⇒ Object



60
61
62
# File 'lib/appsendr/client.rb', line 60

def create(name)
    JSON.parse(post('/api/app/create', {:name=>name}))
end

#groups(app_id) ⇒ Object



84
85
86
# File 'lib/appsendr/client.rb', line 84

def groups(app_id)
    JSON.parse(get('/api/app/groups/'+app_id.to_s))
end

#install_url(app_id) ⇒ Object



56
57
58
# File 'lib/appsendr/client.rb', line 56

def install_url(app_id)
    JSON.parse(get('/api/app/last_install_url/'+app_id.to_s))
end


52
53
54
# File 'lib/appsendr/client.rb', line 52

def link(id)
    post('/api/app/link',{:id=>id});
end

#listObject



48
49
50
# File 'lib/appsendr/client.rb', line 48

def list
    JSON.parse(get('/api/app/list'))
end

#notify(app_id) ⇒ Object



105
106
107
# File 'lib/appsendr/client.rb', line 105

def notify(app_id)
    JSON.parse(get('/api/app/notify/'+app_id.to_s))
end

#remove_collaborator(app_id, email) ⇒ Object



94
95
96
# File 'lib/appsendr/client.rb', line 94

def remove_collaborator(app_id,email)
    post('/api/app/remove_collaborator/'+app_id.to_s,{:email=>email});
end

#remove_group(app_id, name) ⇒ Object



80
81
82
# File 'lib/appsendr/client.rb', line 80

def remove_group(app_id, name)
    post('/api/app/remove_group/'+app_id.to_s,{:name=>name});
end

#remove_tester(app_id, email) ⇒ Object



68
69
70
# File 'lib/appsendr/client.rb', line 68

def remove_tester(app_id,email)
    post('/api/app/remove_tester/'+app_id.to_s,{:email=>email});
end

#testers(app_id) ⇒ Object



102
103
104
# File 'lib/appsendr/client.rb', line 102

def testers(app_id)
    JSON.parse(get('/api/app/testers/'+app_id.to_s))
end

#upload(app_id, ipa, provisioning, notify, notes, bundle_id, icon) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/appsendr/client.rb', line 109

def upload(app_id, ipa,provisioning,notify, notes, bundle_id, icon)
params = {
      :profile => File.new(provisioning, 'rb'),
      :notes=>notes,
      :bundle_identifier => bundle_id,
      :built_at=>Time.now,
      :notify=>notify
  #    :ipa=>
    }
if icon
	params[:icon] = File.new(icon,'rb')
end
      if(is_file_to_large?(ipa))
          puts "IPA is too large to upload."
      else
	params[:ipa] = File.new(ipa, 'rb')

	post('/api/app/upload/'+app_id.to_s, params)
end
end