Class: Pindo::TaskSystem::AppStoreUploadScreenshotTask

Inherits:
AppStoreTask show all
Defined in:
lib/pindo/module/task/model/appstore/appstore_upload_screenshot_task.rb

Overview

App Store Screenshot 上传任务上传应用截图到 App Store Connect

Instance Attribute Summary collapse

Attributes inherited from PindoTask

#callbacks_setup, #context, #created_at, #dependencies, #error, #finished_at, #id, #max_retry_count, #metadata, #name, #priority, #result, #retry_count, #retry_delay, #retry_mode, #started_at, #status, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AppStoreTask

task_type

Methods inherited from PindoTask

#before_retry, #cancel, #cancelled?, #check_cancelled!, #do_task, #execution_time, #finished?, #on, #reset_for_retry, #retryable?, #running?, #should_retry?, task_type

Constructor Details

#initialize(app_id, screenshot_path, options = {}) ⇒ AppStoreUploadScreenshotTask

初始化 Screenshot 上传任务

Parameters:

  • app_id (String)

    App Store Connect 应用 ID

  • screenshot_path (String)

    截图目录路径

  • options (Hash) (defaults to: {})

    选项

Options Hash (options):

  • :apple_id (String)

    Apple ID(App Store Connect 账号)

  • :api_key_id (String)

    API Key ID(使用 API Key 认证)

  • :api_issuer_id (String)

    API Issuer ID

  • :api_key_path (String)

    API Key 文件路径(.p8 文件)

  • :locale (String)

    语言区域(默认 “zh-Hans”)

  • :device_types (Array<String>)

    设备类型(如 [“iPhone 6.5”, “iPad Pro”])

  • :overwrite (Boolean)

    是否覆盖已有截图(默认 false)



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/pindo/module/task/model/appstore/appstore_upload_screenshot_task.rb', line 35

def initialize(app_id, screenshot_path, options = {})
  @app_id = app_id                      # App Store Connect 应用 ID
  @screenshot_path = screenshot_path    # 截图目录路径

  # App Store Connect 认证配置
  @apple_id = options[:apple_id]
  @api_key_id = options[:api_key_id]
  @api_issuer_id = options[:api_issuer_id]
  @api_key_path = options[:api_key_path]

  # 截图配置
  @locale = options[:locale] || "zh-Hans"
  @device_types = options[:device_types] || []
  @overwrite = options[:overwrite] || false

  # 设置上传任务的优先级为 LOW(截图上传可以最后执行)
  options[:priority] ||= TaskPriority::LOW

  super("上传 Screenshot 到 App Store", options)
end

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



9
10
11
# File 'lib/pindo/module/task/model/appstore/appstore_upload_screenshot_task.rb', line 9

def app_id
  @app_id
end

#screenshot_pathObject (readonly)

Returns the value of attribute screenshot_path.



9
10
11
# File 'lib/pindo/module/task/model/appstore/appstore_upload_screenshot_task.rb', line 9

def screenshot_path
  @screenshot_path
end

Class Method Details

.default_retry_countObject



16
17
18
# File 'lib/pindo/module/task/model/appstore/appstore_upload_screenshot_task.rb', line 16

def self.default_retry_count
  2  # 默认可以重试 2 次
end

.default_retry_delayObject



20
21
22
# File 'lib/pindo/module/task/model/appstore/appstore_upload_screenshot_task.rb', line 20

def self.default_retry_delay
  15  # 默认延迟 15 秒
end

.default_retry_modeObject

重试配置



12
13
14
# File 'lib/pindo/module/task/model/appstore/appstore_upload_screenshot_task.rb', line 12

def self.default_retry_mode
  RetryMode::DELAYED  # 延迟重试
end

Instance Method Details

#validateObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/pindo/module/task/model/appstore/appstore_upload_screenshot_task.rb', line 56

def validate
  # 验证基本参数
  unless @app_id && !@app_id.empty?
    @error = "缺少必需参数: app_id"
    return false
  end

  unless @screenshot_path && !@screenshot_path.empty?
    @error = "缺少必需参数: screenshot_path"
    return false
  end

  # 验证截图路径
  unless File.directory?(@screenshot_path)
    @error = "截图路径不存在或不是目录: #{@screenshot_path}"
    return false
  end

  # 验证认证信息(Apple ID 或 API Key)
  has_apple_id_auth = @apple_id && !@apple_id.empty?
  has_api_key_auth = @api_key_id && @api_issuer_id && @api_key_path

  unless has_apple_id_auth || has_api_key_auth
    @error = "缺少认证信息:需要提供 Apple ID 或 API Key"
    return false
  end

  true
end