class Fastlane::Actions::UpdateDeviceNameAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/update_device_name/actions/update_device_name_action.rb, line 44
def self.authors
  ["huyanping"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/update_device_name/actions/update_device_name_action.rb, line 57
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :device_name,
                            env_name: "UPDATE_DEVICE_DEVICE_NAME",
                         description: "device_name",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :user_name,
                                 env_name: "FASTLANE_USER",
                                 description: "user_name",
                                 optional: false,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :password,
                                 env_name: "FASTLANE_PASSWORD",
                                 description: "password",
                                 optional: false,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :udid,
                                 env_name: "UPDATE_DEVICE_UDID",
                                 description: "udid",
                                 optional: false,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :team_id,
                                 env_name: "UPDATE_DEVICE_TEAM_ID",
                                 description: "team_id",
                                 optional: false,
                                 type: String)
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/update_device_name/actions/update_device_name_action.rb, line 40
def self.description
  "update device name"
end
details() click to toggle source
# File lib/fastlane/plugin/update_device_name/actions/update_device_name_action.rb, line 52
def self.details
  # Optional:
  "update device name"
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/update_device_name/actions/update_device_name_action.rb, line 87
def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end
return_value() click to toggle source
# File lib/fastlane/plugin/update_device_name/actions/update_device_name_action.rb, line 48
def self.return_value
  # If your method provides a return value, you can describe here what it does
end
run(params) click to toggle source
# File lib/fastlane/plugin/update_device_name/actions/update_device_name_action.rb, line 8
def self.run(params)
  begin
    user_name = params[:user_name]
    password = params[:password]
    device_name = params[:device_name]
    udid = params[:udid]
    team_id = params[:team_id]

    client = Spaceship::Portal.login(user_name, password)
    client.select_team()
    devices = client.devices();
    client.ensure_csrf(Spaceship::Portal::Device)
    # UI.message(devices)
    for i in devices
      if i['deviceNumber'] != udid
        next
      else
        req = client.request(:post, "account/ios/device/updateDevice.action", {
            teamId: team_id,
            devicePlatform: "IOS",
            deviceId: i['deviceId'],
            name: device_name,
        })
        data = client.parse_response(req, 'device')
        UI.message(data)
        UI.message("success")
      end
    end
  end
  UI.message("The update_device_name plugin is working!")
end