Class: Fastlane::Actions::GetPackConfigAction

Inherits:
BaseAction
  • Object
show all
Defined in:
lib/fastlane/plugin/zhuixi_build_app/actions/get_pack_config_action.rb

Class Method Summary collapse

Methods inherited from BaseAction

is_supported?

Class Method Details

.available_optionsObject



43
44
45
46
47
48
49
50
51
# File 'lib/fastlane/plugin/zhuixi_build_app/actions/get_pack_config_action.rb', line 43

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :game_id,
                                 env_name: "ZHUIXI_BUILD_APP_YOUR_OPTION",
                                 description: "GetPackConfigAction",
                                 optional: false,
                                 type: String),
  ]
end

.get_pack_config(game_id) ⇒ Object

获取打包配置数据



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fastlane/plugin/zhuixi_build_app/actions/get_pack_config_action.rb', line 12

def self.get_pack_config(game_id)
  uri = URI.parse("http://xg.yutennet.com/issuesy/pack/doPack")
  request = Net::HTTP::Post.new(uri)
  request.content_type = "application/json"
  request.body = JSON.dump({
    "user_id" => lane_context[:user_id],
    "token" => lane_context[:token],
    "packet_os" => "2",
    "platform_id" => lane_context[:platform_id],
    "game_id" => game_id,
  })
  response = Net::HTTP.start(uri.hostname, uri.port) do |http|
    puts request.body
    http.request(request)
  end

  if response.code == "200"
    result = JSON.parse(response.body)
    if result["code"] == 200
      data = result["data"]
      lane_context[:configParams] = data["config"]
      resourcesUrl = data["resources_url"]
      return resourcesUrl.to_s
    else
      puts "获取打包配置失败:\n#{result}"
    end
  else
    puts "获取打包配置失败:HTTP\n #{response}"
  end
end

.run(params) ⇒ Object



7
8
9
# File 'lib/fastlane/plugin/zhuixi_build_app/actions/get_pack_config_action.rb', line 7

def self.run(params)
  get_pack_config(params[:game_id])
end