Class: Shenzhen::Plugins::TestFlight::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/shenzhen/plugins/testflight.rb

Constant Summary collapse

HOSTNAME =
'testflightapp.com'

Instance Method Summary collapse

Constructor Details

#initialize(api_token, team_token) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
17
18
19
20
# File 'lib/shenzhen/plugins/testflight.rb', line 11

def initialize(api_token, team_token)
  @api_token, @team_token = api_token, team_token
  @connection = Faraday.new(:url => "http://#{HOSTNAME}", :request => { :timeout => 120 }) do |builder|
    builder.request :multipart
    builder.request :json
    builder.response :json, :content_type => /\bjson$/
    builder.use FaradayMiddleware::FollowRedirects
    builder.adapter :net_http
  end
end

Instance Method Details

#upload_build(ipa, options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/shenzhen/plugins/testflight.rb', line 22

def upload_build(ipa, options)
  options.update({
    :api_token => @api_token,
    :team_token => @team_token,
    :file => Faraday::UploadIO.new(ipa, 'application/octet-stream')
  })

  if dsym_filename = options.delete(:dsym_filename)
    options[:dsym] = Faraday::UploadIO.new(dsym_filename, 'application/octet-stream')
  end

  @connection.post("/api/builds.json", options).on_complete do |env|
    yield env[:status], env[:body] if block_given?
  end

rescue Faraday::Error::TimeoutError
  say_error "Timed out while uploading build. Check https://testflightapp.com/dashboard/applications/ to see if the upload was completed." and abort
end