class Shenzhen::Plugins::Pgyer::Client

Constants

HOSTNAME

Public Class Methods

new(user_key, api_key) click to toggle source
# File lib/shenzhen/plugins/pgyer.rb, line 11
def initialize(user_key, api_key)
  @user_key, @api_key = user_key, api_key
  @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

Public Instance Methods

update_app_info(options) { |env, env| ... } click to toggle source
# File lib/shenzhen/plugins/pgyer.rb, line 37
def update_app_info(options)
  connection = Faraday.new(:url => "http://#{HOSTNAME}", :request => { :timeout => 120 }) do |builder|
    builder.request :url_encoded
    builder.request :json
    builder.response :logger
    builder.response :json, :content_type => /\bjson$/
    builder.use FaradayMiddleware::FollowRedirects
    builder.adapter :net_http
  end

  options.update({
    :uKey => @user_key,
    :_api_key => @api_key,
  })

  connection.post("/apiv1/app/update", options) do |env|
    yield env[:status], env[:body] if block_given?
  end

rescue Faraday::Error::TimeoutError
  say_error "Timed out while uploading build. Check http://www.pgyer.com/my to see if the upload was completed." and abort
end
upload_build(ipa, options) { |env, env| ... } click to toggle source
# File lib/shenzhen/plugins/pgyer.rb, line 22
def upload_build(ipa, options)
  options.update({
    :uKey => @user_key,
    :_api_key => @api_key,
    :file => Faraday::UploadIO.new(ipa, 'application/octet-stream')
  })

  @connection.post("/apiv1/app/upload", 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 http://www.pgyer.com/my to see if the upload was completed." and abort
end