socialforge/app/api/mobile/apis/upgrade.rb

30 lines
812 B
Ruby
Raw Normal View History

2015-01-04 11:53:16 +08:00
#coding=utf-8
module Mobile
module Apis
class Upgrade < Grape::API
include ApplicationHelper
2015-01-04 11:53:16 +08:00
resource :upgrade do
desc "get update info"
params do
requires :platform, type: String, desc: '平台名android, ios'
end
get do
@current_version = ::PhoneAppVersion.reorder('created_at desc').first
attachment = @current_version.attachments.first
if attachment.nil?
raise '未发现客户端!'
end
url = "http://" + Setting.host_name + "/attachments/download/" + attachment.id.to_s + "/" + attachment.filename
2015-01-04 11:53:16 +08:00
{
version: @current_version.version,
url: url,
desc: @current_version.description
2015-01-04 11:53:16 +08:00
}
end
end
end
end
end