Class: Fastlane::Actions::LoginAction

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

Class Method Summary collapse

Methods inherited from BaseAction

is_supported?

Class Method Details

.available_optionsObject



50
51
52
53
54
55
56
57
58
# File 'lib/fastlane/plugin/zhuixi_build_app/actions/login_action.rb', line 50

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :credentials,
                                 env_name: "ZHUIXI_BUILD_APP_YOUR_OPTION",
                                 description: "LoginAction",
                                 optional: false,
                                 type: Hash),
  ]
end

.login_and_get_user_id_and_token(account, password, packet_os) ⇒ Object



11
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
42
43
44
45
46
47
48
# File 'lib/fastlane/plugin/zhuixi_build_app/actions/login_action.rb', line 11

def self.(, password, packet_os)
  uri = URI.parse("http://xg.yutennet.com/issuesy/pack/user_login")
  request = Net::HTTP::Post.new(uri)
  request.content_type = "application/json"
  request.body = JSON.dump({
    "account" => ,
    "password" => password,
    "packet_os" => packet_os,
  })

  response = Net::HTTP.start(uri.hostname, uri.port) do |http|
    http.request(request)
  end

  if response.code == "200"
    result = JSON.parse(response.body)
    if result["code"] == 200
      user_id = result["data"]["user_id"]
      token = result["data"]["token"]
      lane_context[:user_id] = user_id
      lane_context[:token] = token
      platforms = result["data"]["platform_lists"]
      puts "ZHUIXI---登陆成功!platform:\n" + platforms.to_s
      for platform in platforms
        if lane_context[:selectPlatformName] == platform["platform_name"]
          lane_context[:platform_id] = platform["platform_id"]
          return { user_id: user_id, token: token, platform_id: lane_context[:platform_id] }
        end
      end
    else
      puts "ZHUIXI---登录失败:#{result["msg"]}"
    end
  else
    puts "ZHUIXI---登录失败:HTTP #{response.code}"
  end

  return nil, nil
end

.run(params) ⇒ Object



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

def self.run(params)
  (params[:credentials][:account], params[:credentials][:password], "2")
end