class Shenzhen::Plugins::DeployGate::Client

Constants

HOSTNAME

Public Class Methods

new(api_token, user_name) click to toggle source
# File lib/shenzhen/plugins/deploygate.rb, line 11
def initialize(api_token, user_name)
  @api_token, @user_name = api_token, user_name
  @connection = Faraday.new(:url => "https://#{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

Public Instance Methods

upload_build(ipa, options) { |env, env| ... } click to toggle source
# File lib/shenzhen/plugins/deploygate.rb, line 22
def upload_build(ipa, options)
  options.update({
    :token => @api_token,
    :file => Faraday::UploadIO.new(ipa, 'application/octet-stream'),
    :message => options[:message] || ''
  })

  @connection.post("/api/users/#{@user_name}/apps", 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://deploygate.com/ to see if the upload was completed." and abort
end