If I may add as well, this is how I get price points for $0.0 in USD and CAD, you can replace it with any currency.:
lane :get_app_price_points do |options|
require 'json'
require 'net/http'
auth_token = options[:auth_token] # Your App Store Connect API token
app_id = options[:app_id] # The app ID for which you want to list subscriptions
# Define the URL for fetching subscriptions
url = URI("https://api.appstoreconnect.apple.com/v1/apps/#{app_id}/appPricePoints?filter%5Bterritory%5D=USA,CAN&include=territory")
# Create the HTTP request
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
# Set up headers for the App Store Connect API request
headers = {
"Authorization" => "Bearer #{auth_token}",
"Content-Type" => "application/json"
}
# Prepare the GET request
request = Net::HTTP::Get.new(url, headers)
# Execute the request
response = http.request(request)
# Handle the response
if response.code == "200"
app_prices = JSON.parse(response.body)
# UI.message("Subscriptions for app #{app_id}: #{response.body}")
# Use the find method to get the free price point ID directly
free_price_point = app_prices["data"].find do |price_point|
price_point["attributes"]["customerPrice"] == "0.0"
end
free_price_point_id = free_price_point ? free_price_point["id"] : nil
UI.message("Free Price Point ID: #{free_price_point_id}")
# Return the ID of the price point with 0.0 price
free_price_point_id
else
UI.error("Failed to fetch subscriptions: #{response.body}")
end
end