Class: Shenzhen::Plugins::Pgyer::Client
- Inherits:
-
Object
- Object
- Shenzhen::Plugins::Pgyer::Client
- Defined in:
- lib/shenzhen/plugins/pgyer.rb
Constant Summary collapse
- HOSTNAME =
'www.pgyer.com'
Instance Method Summary collapse
-
#initialize(user_key, api_key) ⇒ Client
constructor
A new instance of Client.
- #update_app_info(options) ⇒ Object
- #upload_build(ipa, options) ⇒ Object
Constructor Details
#initialize(user_key, api_key) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 |
# 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 |
Instance Method Details
#update_app_info(options) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/shenzhen/plugins/pgyer.rb', line 37 def update_app_info() 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 .update({ :uKey => @user_key, :_api_key => @api_key, }) connection.post("/apiv1/app/update", ) 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) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/shenzhen/plugins/pgyer.rb', line 22 def upload_build(ipa, ) .update({ :uKey => @user_key, :_api_key => @api_key, :file => Faraday::UploadIO.new(ipa, 'application/octet-stream') }) @connection.post("/apiv1/app/upload", ).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 |