I'm currently using the (deprecated) Spaceship API to create subscription in-app-purchases. Besides Fastlane I'm not using Ruby at all, so I'm really a beginner when it comes to data types etc. in Ruby.
To have it better configurable I outsourced everything to a Json file:
{
"subscriptionFamily": {
"familyName": "TEST-FAMILY",
"localizedDescriptions": {
"en-US": {
"subscription_name": "Unlock all",
"name": "Get access to everything"
},
"de-DE": {
"subscription_name": "Blabla",
"name": "Blablabla"
}
}
}
Then, within Fastlane, I read the Json file first with that method:
def get_subscription_config
file = File.open $subscription_config_path
JSON.load file
rescue StandardError => e
UI.error("Couldn't find or read the subscription configuration file")
end
subscription_family = subscription_config['subscriptionFamily']
Then, eventually, after logging in through Spaceship, I create the subscription family:
app.in_app_purchases.families.create!(
name: subscription_family['familyName'],
versions: subscription_family['localizedDescriptions'],
product_id: first_subscription['subscriptionId'],
reference_name: first_subscription['referenceName']
)
This throws an error:
[!] The request could not be completed because:
You must enter a Subscription Group Display Name for English (U.S.). You must enter a Subscription Group Display Name for German. You must enter a Subscription Group Display Name for the following localizations: English (U.S.), German.
Now the thing that confuses me the most: When I add the data from the Json into a variable like that and then pass on the variable into the create method, then everything works!
localizationData = {
"en-US": {
"subscription_name": 'Unlock all features',
"name": 'Get access to all features within the app.'
},
"de-DE": {
"subscription_name": 'Alle Funktionen freischalten',
"name": 'Schalte alle Inhalte innerhalb der App frei.'
}
}
app.in_app_purchases.families.create!(
name: subscription_family['familyName'],
versions: localizationData,
product_id: first_subscription['subscriptionId'],
reference_name: first_subscription['referenceName']
)
I already tried to compare the types, but they are both hashes. I also tried to wrap the Json data into an OpenStruct: OpenStruct.new(subscription_family['localizedDescriptions']). This actually doesn't throw an error anymore, and the subscription group is created, but without submitting the metadata to AppStore connect. The localization area there just stays empty.
Does anyone know what I'm doing wrong? Why are both the data from the variable and from the Json a hash but the one can be processed by Fastlane, the other can't?
Would be awesome to get some assistance on that!