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
-
.rest_v1_1_url(site_id:, path:) ⇒ URI
Builds a WordPress.com REST API v1.1 URI scoped to a site.
-
.verify_post_status_param ⇒ Proc
Returns a proc that validates a post status parameter value against VALID_POST_STATUS.
-
.verify_visibility_param ⇒ Proc
Returns a proc that validates a visibility parameter value against VALID_VISIBILITIES.
-
.wpcom_v2_url(site_id:, path:) ⇒ URI
Builds a WordPress.com REST API wpcom/v2 URI scoped to a site.
Class Method Details
.rest_v1_1_url(site_id:, path:) ⇒ URI
Builds a WordPress.com REST API v1.1 URI scoped to a site.
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_param ⇒ Proc
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.
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_param ⇒ Proc
Returns a proc that validates a visibility parameter value against VALID_VISIBILITIES. Intended for use as a ‘verify_block` in Fastlane ConfigItem definitions.
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.
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 |