class Fastlane::Actions::HockeyDevicesAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/hockey_devices/actions/hockey_devices_action.rb, line 80 def self.available_options [ FastlaneCore::ConfigItem.new(key: :api_token, env_name: "FL_HOCKEY_API_TOKEN", sensitive: true, description: "API Token for Hockey Access", optional: false), FastlaneCore::ConfigItem.new(key: :public_identifier, env_name: "FL_HOCKEY_PUBLIC_IDENTIFIER", description: "App id of the app you are targeting", optional: false), FastlaneCore::ConfigItem.new(key: :unprovisioned, env_name: "HOCKEY_DEVICES_UNPROVISIONED", description: "Only retrieve unprovisioned devices list", optional: true, is_string: false, default_value: true) ] end
connection(options)
click to toggle source
# File lib/fastlane/plugin/hockey_devices/actions/hockey_devices_action.rb, line 4 def self.connection(options) require 'faraday' require 'faraday_middleware' base_url = "https://rink.hockeyapp.net" foptions = { url: base_url } Faraday.new(foptions) do |builder| builder.request :url_encoded builder.response :json, content_type: /\bjson$/ builder.adapter :net_http end end
description()
click to toggle source
# File lib/fastlane/plugin/hockey_devices/actions/hockey_devices_action.rb, line 64 def self.description "Retrieves a list of devices from Hockey which can then be used with Match" end
details()
click to toggle source
# File lib/fastlane/plugin/hockey_devices/actions/hockey_devices_action.rb, line 76 def self.details "Retrieves all or unprovisioned list of devices from Hockey. List then can be used either to register new devices using Match etc." end
example_code()
click to toggle source
# File lib/fastlane/plugin/hockey_devices/actions/hockey_devices_action.rb, line 104 def self.example_code [ 'hockey_devices( api_token: "XXXXYYYYZZZZWWWW", public_identifier: "aaaabbbbccccdddd" )' ] end
get_devices(api_token, options)
click to toggle source
# File lib/fastlane/plugin/hockey_devices/actions/hockey_devices_action.rb, line 19 def self.get_devices(api_token, options) connection = self.connection(options) app_id = options.delete(:public_identifier) only_unprovisioned = options.delete(:unprovisioned) ? 1 : 0 return connection.get do |req| req.url("/api/2/apps/#{app_id}/devices?unprovisioned=#{only_unprovisioned}") req.headers['X-HockeyAppToken'] = api_token end end
get_devices_hash(devices)
click to toggle source
# File lib/fastlane/plugin/hockey_devices/actions/hockey_devices_action.rb, line 30 def self.get_devices_hash(devices) devices_hash = {} used_names = {} devices.each do |d| agg_name = d["name"] if used_names[agg_name] num = used_names[agg_name] + 1 used_names[agg_name] = num agg_name += " (#{num})" else used_names[agg_name] = 1 end devices_hash[agg_name] = d["udid"] end devices_hash end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/hockey_devices/actions/hockey_devices_action.rb, line 100 def self.is_supported?(platform) true end
return_value()
click to toggle source
# File lib/fastlane/plugin/hockey_devices/actions/hockey_devices_action.rb, line 72 def self.return_value "The hash of devices" end
run(options)
click to toggle source
# File lib/fastlane/plugin/hockey_devices/actions/hockey_devices_action.rb, line 47 def self.run(options) values = options.values api_token = values.delete(:api_token) values.delete_if { |k, v| v.nil? } response = self.get_devices(api_token, values) case response.status when 200...300 devices_hash = get_devices_hash(response.body['devices']) UI.message("successfully got devices list") devices_hash else UI.user_error!("Error trying to get devices list: #{response.status} - #{response.body}") end end