Class: Lhj::PgyerShortcut
- Inherits:
-
Object
- Object
- Lhj::PgyerShortcut
- Defined in:
- lib/lhj/helper/pgyer_shortcut_helper.rb
Overview
pgyer upload
Constant Summary collapse
- API_SHORTCUT_HOST =
'https://api.pgyer.com/apiv2/app/getByShortcut'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#shortcut_url ⇒ Object
readonly
Returns the value of attribute shortcut_url.
-
#user_key ⇒ Object
readonly
Returns the value of attribute user_key.
Instance Method Summary collapse
- #build_app_version ⇒ Object
- #build_app_version_no ⇒ Object
- #build_updated ⇒ Object
- #build_version ⇒ Object
-
#initialize(env = :uat) ⇒ PgyerShortcut
constructor
A new instance of PgyerShortcut.
- #request_shortcut_body ⇒ Object
- #res_body ⇒ Object
Constructor Details
#initialize(env = :uat) ⇒ PgyerShortcut
Returns a new instance of PgyerShortcut.
14 15 16 17 18 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 14 def initialize(env = :uat) @api_key = Lhj::PgyerConfig.api_key(env) @user_key = Lhj::PgyerConfig.user_key(env) @shortcut_url = Lhj::PgyerConfig.shortcut_url(env) end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 12 def api_key @api_key end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
12 13 14 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 12 def password @password end |
#shortcut_url ⇒ Object (readonly)
Returns the value of attribute shortcut_url.
12 13 14 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 12 def shortcut_url @shortcut_url end |
#user_key ⇒ Object (readonly)
Returns the value of attribute user_key.
12 13 14 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 12 def user_key @user_key end |
Instance Method Details
#build_app_version ⇒ Object
53 54 55 56 57 58 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 53 def build_app_version res_json = res_body res = '' res = res_json['data']['buildVersion'] if res_json['code'].to_i.zero? res end |
#build_app_version_no ⇒ Object
60 61 62 63 64 65 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 60 def build_app_version_no res_json = res_body res = '' res = res_json['data']['buildVersionNo'] if res_json['code'].to_i.zero? res end |
#build_updated ⇒ Object
46 47 48 49 50 51 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 46 def build_updated res_json = res_body res = '' res = res_json['data']['buildUpdated'] if res_json['code'].to_i.zero? res end |
#build_version ⇒ Object
39 40 41 42 43 44 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 39 def build_version res_json = res_body res = '' res = res_json['data']['buildBuildVersion'] if res_json['code'].to_i.zero? res end |
#request_shortcut_body ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 20 def request_shortcut_body url = URI(API_SHORTCUT_HOST) https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request['Content-Type'] = 'application/x-www-form-urlencoded' request.body = "_api_key=#{@api_key}&buildShortcutUrl=#{@shortcut_url}" response = https.request(request) response.read_body end |
#res_body ⇒ Object
34 35 36 37 |
# File 'lib/lhj/helper/pgyer_shortcut_helper.rb', line 34 def res_body body = request_shortcut_body unless @res_body @res_body ||= JSON.parse(body) end |