Class: Shenzhen::Plugins::Fir::Client
- Inherits:
-
Object
- Object
- Shenzhen::Plugins::Fir::Client
- Defined in:
- lib/shenzhen/plugins/fir.rb
Constant Summary collapse
- HOSTNAME =
'fir.im'
- VERSION =
'v2'
Instance Method Summary collapse
- #get_app_info(app_id) ⇒ Object
-
#initialize(user_token) ⇒ Client
constructor
A new instance of Client.
- #update_app_info(app_id, options) ⇒ Object
- #upload_build(ipa, options) ⇒ Object
Constructor Details
#initialize(user_token) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/shenzhen/plugins/fir.rb', line 12 def initialize(user_token) @user_token = user_token @connection = Faraday.new(:url => "http://#{HOSTNAME}") do |builder| builder.request :url_encoded builder.response :json builder.use FaradayMiddleware::FollowRedirects builder.adapter :net_http end end |
Instance Method Details
#get_app_info(app_id) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/shenzhen/plugins/fir.rb', line 23 def get_app_info(app_id) = { :type => 'ios', :token => @user_token, } @connection.get("/api/#{VERSION}/app/info/#{app_id}", ) do |env| yield env[:status], env[:body] if block_given? end rescue Faraday::Error::TimeoutError say_error "Timed out while geting app info." and abort end |
#update_app_info(app_id, options) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/shenzhen/plugins/fir.rb', line 36 def update_app_info(app_id, ) @connection.put("/api/#{VERSION}/app/#{app_id}?token=#{@user_token}", ) do |env| yield env[:status], env[:body] if block_given? end rescue Faraday::Error::TimeoutError say_error "Timed out while geting app info." and abort end |
#upload_build(ipa, options) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/shenzhen/plugins/fir.rb', line 44 def upload_build(ipa, ) connection = Faraday.new(:url => ['url'], :request => { :timeout => 360 }) do |builder| builder.request :multipart builder.response :json builder.use FaradayMiddleware::FollowRedirects builder.adapter :net_http end = { :key => ['key'], :token => ['token'], :file => Faraday::UploadIO.new(ipa, 'application/octet-stream') } connection.post('/', ).on_complete do |env| yield env[:status], env[:body] if block_given? end rescue Errno::EPIPE say_error "Upload failed. Check internet connection is ok." and abort rescue Faraday::Error::TimeoutError say_error "Timed out while uploading build. Check https://fir.im// to see if the upload was completed." and abort end |