Module: Fastlane::Helper::AppsCdnHelper

Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/helper/apps_cdn_helper.rb

Constant Summary collapse

API_BASE_URL =
'https://public-api.wordpress.com'
VALID_VISIBILITIES =
%i[internal external].freeze
VALID_POST_STATUS =

These are from the WordPress.com API, not the Apps CDN plugin

%w[publish draft].freeze

Class Method Summary collapse

Class Method Details

.rest_v1_1_url(site_id:, path:) ⇒ URI

Builds a WordPress.com REST API v1.1 URI scoped to a site.

Parameters:

  • site_id (String)

    the WordPress.com site ID

  • path (String)

    the API path relative to the site (e.g. ‘media/new’)

Returns:

  • (URI)

    the parsed full API URI



21
22
23
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/apps_cdn_helper.rb', line 21

def self.rest_v1_1_url(site_id:, path:)
  URI.parse("#{API_BASE_URL}/rest/v1.1/sites/#{site_id}/#{path}")
end

.verify_post_status_paramProc

Returns a proc that validates a post status parameter value against VALID_POST_STATUS. Intended for use as a ‘verify_block` in Fastlane ConfigItem definitions.

Returns:

  • (Proc)

    a proc that raises FastlaneError if the value is invalid



48
49
50
51
52
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/apps_cdn_helper.rb', line 48

def self.verify_post_status_param
  proc do |value|
    UI.user_error!("Post status must be one of: #{VALID_POST_STATUS.join(', ')}") unless VALID_POST_STATUS.include?(value)
  end
end

.verify_visibility_paramProc

Returns a proc that validates a visibility parameter value against VALID_VISIBILITIES. Intended for use as a ‘verify_block` in Fastlane ConfigItem definitions.

Returns:

  • (Proc)

    a proc that raises FastlaneError if the value is invalid



38
39
40
41
42
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/apps_cdn_helper.rb', line 38

def self.verify_visibility_param
  proc do |value|
    UI.user_error!("Visibility must be one of: #{VALID_VISIBILITIES.map { "`:#{_1}`" }.join(', ')}") unless VALID_VISIBILITIES.include?(value.to_s.downcase.to_sym)
  end
end

.wpcom_v2_url(site_id:, path:) ⇒ URI

Builds a WordPress.com REST API wpcom/v2 URI scoped to a site.

Parameters:

  • site_id (String)

    the WordPress.com site ID

  • path (String)

    the API path relative to the site (e.g. ‘a8c-cdn/builds/123’)

Returns:

  • (URI)

    the parsed full API URI



30
31
32
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/apps_cdn_helper.rb', line 30

def self.wpcom_v2_url(site_id:, path:)
  URI.parse("#{API_BASE_URL}/wpcom/v2/sites/#{site_id}/#{path}")
end