rubyapisyntaxrubygems

Api endpoint requires string, how to find what strings can be used?


I'm using Ruby and a gem for app_store_connect. I'm trying to create a profile. From the readme, I can configure my client like so

AppStoreConnect.config = {
  issuer_id: 'issuer_id',
  key_id: 'key_id',
  private_key: File.read(File.new("/Path/AuthKey.p8"))
}

app_store_connect = AppStoreConnect::Client.new

And I have that setup and successfully working. I've tested with with the create_bundle_id() function which is properly updating my AppStoreConnect account. I've also found that I can call the following to get a list of all profiles.

app_store_connect.profiles

Github seems to indicate that I can call the function create_profile() which requires strings for name and profile_type in order to create a new profile. So in my code, I run

app_store_connect.create_profile(
  name: "Foo"
  profile_type: "IOS_APP_STORE"
)

But no matter what I do, I can't seem to make this one work. I'm not sure what's failing or how to check either. I got the string for profile_type from checking other profiles, but I can't help but feel like I'm missing something. Is there a chance I could get some help figuring what I'm missing or what the proper string should be?

For context, I'm very new to ruby and I don't know what tools are available to make this language work for me. So far, it's mostly been trial and error.


Solution

  • I am assuming you're not actually missing the commas when you call create_profile.

    But no matter what I do, I can't seem to make this one work. I'm not sure what's failing or how to check either.

    It always helps to include the error/response you are seeing! 😉

    what the proper string [for profile_type] should be?

    Unfortunately, this gem seems to be somewhat poorly documented. In that kind of situation, I dive into the source code of the gem to attempt to understand how it works (I understand that this can be intimidating when you have less experience, but it can be a great way to learn!). I searched for create_profile, and this schema.json was the only result. The fact that there is no plain method definition for create_profile indicates to me that it gets defined through metaprogramming, from that schema. In that case, I would assume the API payload is sent through unmodified. In Googling the associated API endpoint URL from the schema, api.appstoreconnect.apple.com/v1/profiles, I found Apple's docs for it. Clicking through from there leads to this list of values for the profile type.