forked from RishabhTayal/itc-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestflight.rb
51 lines (45 loc) · 1.38 KB
/
testflight.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
43
44
45
46
47
48
49
50
51
require 'sinatra'
require 'spaceship'
require 'json'
# Get List of testers
get '/testers' do
content_type :json
username = request.env['HTTP_USERNAME']
password = request.env['HTTP_PASSWORD']
bundle_id = params[:bundle_id]
Spaceship::Tunes.login(username, password)
client = Spaceship::Tunes.client
client.team_id = request.env['HTTP_TEAM_ID']
apps = Spaceship::Tunes::Application.all
myapp = apps.select { |a| a.bundle_id.casecmp(bundle_id).zero? }
testers = Spaceship::TestFlight::Tester.all(app_id: myapp.first.apple_id)
testers.collect do |tester|
{
first_name: tester.first_name,
last_name: tester.last_name,
email: tester.email
}
end.to_json
end
# Creating new testers
post '/tester' do
content_type :json
username = request.env['HTTP_USERNAME']
password = request.env['HTTP_PASSWORD']
bundle_id = params[:bundle_id]
email = params[:email]
first_name = params[:first_name]
last_name = params[:last_name]
Spaceship::Tunes.login(username, password)
client = Spaceship::Tunes.client
client.team_id = request.env['HTTP_TEAM_ID']
apps = Spaceship::Tunes::Application.all
myapp = apps.select { |a| a.bundle_id.casecmp(bundle_id).zero? }
Spaceship::TestFlight::Tester.create_app_level_tester(
app_id: myapp.first.apple_id,
email: email,
first_name: first_name,
last_name: last_name
)
{ success: true }.to_json
end