Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Availability and B2B information through ConnectAPI? #17244

Closed
mattinasi opened this issue Sep 15, 2020 · 14 comments · Fixed by #17490
Closed

Availability and B2B information through ConnectAPI? #17244

mattinasi opened this issue Sep 15, 2020 · 14 comments · Fixed by #17490

Comments

@mattinasi
Copy link

mattinasi commented Sep 15, 2020

We have automation scripts to publish custom-branded apps in our customers' B2B stores. The final publishing had been working fine but has stopped, due to a change in how App Store availability works since the big API change a couple months ago.

Currently there are 3 Availability options on the App Store Connect website:

  1. Available on the App Store, for volume purchasing on Apple Business Manager, and for volume purchasing at a reduced price on Apple School Manager
  2. Available on the App Store and for volume purchasing on Apple Business Manager and Apple School Manager
  3. Available for private distribution to specific organizations on Apple Business Manager or Apple School Manager

We are using Tunes.Availability.enable_b2b_app! and update_availability to add our customer's DEP ID and ORG.

      availability = Spaceship::Tunes.client.availability(build.app_id)
      
      # only add the dep org if it is not already there
      if availability.b2b_organizations.count { |org| org.dep_customer_id == dep_id && org.name == organization_name } == 0
        availability.enable_b2b_app!
        add_map = {'type' => 'ADD', 'depCustomerId' => dep_id, 'organizationId' => nil, 'name' => organization_name}
        add_org = Spaceship::Tunes::B2bOrganization.new('value' => add_map)
        availability.update_dep_organizations([add_org])

        Spaceship::Tunes.client.update_availability!(build.app_id, availability)
      end

However the result now is that the second option is selected (Available on the App Store and for volume purchasing on Apple Business Manager and Apple School Manager) and when we try to deliver it to the B2B store it fails with

Fastlane error: The request cannot be fulfilled because of the state of another resource. - Submit for review errors found.
An attribute value is not acceptable for the current resource state. - An app with APP_STORE distribution may not have organizations.

When I manually select the 3rd option (Available for private distribution to specific organizations on Apple Business Manager or Apple School Manager) and run the deployment script it succeeds.

I presume the old Tunes mechanisms are not quite valid now, and have been looking for a way to update the B2B availability via ConnectAPI but I cannot find it... am I missing something? Is there a way to select the 3rd availability option via fastlane?

fastlane env

🚫 fastlane environment 🚫

Stack

Key Value
OS 10.15.6
Ruby 2.6.3
Bundler? true
Git git version 2.24.3 (Apple Git-128)
Installation Source ~/git/mobilesky/vendor/bundle/ruby/2.6.0/bin/fastlane
Host Mac OS X 10.15.6 (19G2021)
Ruby Lib Dir /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
OpenSSL Version LibreSSL 2.8.3
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode.app/Contents/Developer/
Xcode Version 11.6

System Locale

Variable Value
LANG en_US.UTF-8
LC_ALL
LANGUAGE

fastlane files:

fastlane gems

Gem Version Update-Status
fastlane 2.158.0 🚫 Update available

Loaded fastlane plugins:

Plugin Version Update-Status
fastlane-plugin-appicon 0.14.1 🚫 Update available
Loaded gems
Gem Version
did_you_mean 1.4.0
bundler 1.17.2
etc 1.1.0
forwardable 1.2.0
rake 13.0.0
CFPropertyList 3.0.1
concurrent-ruby 1.1.5
i18n 0.9.5
minitest 5.12.2
thread_safe 0.3.6
tzinfo 1.2.5
activesupport 4.2.11.1
public_suffix 4.0.6
addressable 2.7.0
httpclient 2.8.3
json 2.2.0
algoliasearch 1.27.1
atomos 0.1.3
aws-eventstream 1.1.0
aws-partitions 1.365.0
aws-sigv4 1.2.2
jmespath 1.4.0
aws-sdk-core 3.105.0
aws-sdk-kms 1.37.0
aws-sdk-s3 1.79.1
babosa 1.0.3
claide 1.0.3
clamp 1.3.1
fuzzy_match 2.0.4
nap 1.1.0
cocoapods-core 1.8.4
cocoapods-deintegrate 1.0.4
cocoapods-downloader 1.2.2
cocoapods-plugins 1.0.0
cocoapods-search 1.0.0
cocoapods-stats 1.1.0
netrc 0.11.0
cocoapods-trunk 1.4.1
cocoapods-try 1.1.0
colored2 3.1.2
escape 0.0.4
fourflusher 2.3.1
gh_inspector 1.1.3
molinillo 0.6.6
ruby-macho 1.4.0
nanaimo 0.2.6
xcodeproj 1.13.0
cocoapods 1.8.4
coderay 1.1.2
colored 1.2
highline 1.7.10
commander-fastlane 4.4.6
declarative 0.0.20
declarative-option 0.1.0
digest-crc 0.6.1
unf_ext 0.0.7.7
unf 0.1.4
domain_name 0.5.20190701
dotenv 2.7.6
emoji_regex 3.0.0
excon 0.76.0
multipart-post 2.0.0
faraday 1.0.1
http-cookie 1.0.3
faraday-cookie_jar 0.0.7
faraday_middleware 1.0.0
fastimage 2.2.0
jwt 2.2.2
memoist 0.16.2
multi_json 1.15.0
os 1.1.1
signet 0.14.0
googleauth 0.13.1
mini_mime 1.0.2
uber 0.1.0
representable 3.0.4
retriable 3.1.2
google-api-client 0.38.0
google-cloud-env 1.3.3
google-cloud-errors 1.0.1
google-cloud-core 1.5.0
google-cloud-storage 1.28.0
mini_magick 4.9.5
plist 3.5.0
rubyzip 2.3.0
security 0.1.3
naturally 2.2.0
simctl 1.6.8
slack-notifier 2.3.2
terminal-notifier 2.0.0
unicode-display_width 1.7.0
terminal-table 1.8.0
tty-screen 0.8.1
tty-cursor 0.7.1
tty-spinner 0.9.3
word_wrap 1.0.0
rouge 2.0.7
xcpretty 0.3.0
xcpretty-travis-formatter 1.0.0
fastlane-plugin-appicon 0.14.1
method_source 0.9.2
mini_portile2 2.4.0
nokogiri 1.10.9
pry 0.12.2
slather 2.4.8

generated on: 2020-09-15

@fastlane-bot
Copy link

It seems like you have not included the output of fastlane env
To make it easier for us help you resolve this issue, please update the issue to include the output of fastlane env 👍

@max-ott
Copy link
Contributor

max-ott commented Sep 17, 2020

I don't think this is added / supported yet. I'm sure @joshdholtz can shine more light on it.

@mhleiftaylor
Copy link

We used to do it this way as well @mattinasi
I think the old Tunes object hasn't been keeping up with the Appstore Connect changes.
We are having to do all the B2B stuff manually right now. Big PITA for our ci.cd pipeline.

@joshdholtz
Copy link
Member

@mhleiftaylor Sorry about that! I can start looking into this this week and try to get it fixed for you 💪 I'm not too familiar with B2B so I may have some questions for you along my journey if that's okay.

@joshdholtz joshdholtz self-assigned this Sep 22, 2020
@joshdholtz joshdholtz added this to Ready in Just Josh Things Sep 22, 2020
@joshdholtz joshdholtz moved this from Ready to Doing in Just Josh Things Oct 5, 2020
@mattinasi
Copy link
Author

@joshdholtz - thank you! 😸

If I can help test it or review please let me know

@joshdholtz
Copy link
Member

@mattinasi Do you happen to have an Organization ID that I can test with? 😬 I'm able to add support for Apple ID but I don't know how to make the request and test for Organization ID since these requests are not added to the docs yet. Feel free to send me an email at me@joshholtz.com if you want to communicate over that!

@joshdholtz
Copy link
Member

@mattinasi It also turns out that this is not available in the official App Store Connect API meaning that this will only work over a a web session with Apple ID and not with the App Store Connect API Key (yet) 😔 I'm filing a radar for adding this ability right now.

@mattinasi
Copy link
Author

@joshdholtz Thanks for the info!

I presume we have to do this manually until App Store Connect API supports it and fastlane is updated to use it?

@joshdholtz
Copy link
Member

@mattinasi Nope nope! I'm working on adding the models and methods to Spaceship::ConnectAPI but it will only work with Apple ID auth for now 🤷‍♂️

@joshdholtz
Copy link
Member

@mattinasi Hey sorry! Got sidetracked by some other things but here is the PR 😊 #17490

I dropped an example of how I tested it. If you want to test that this works for you that would be 💯

@mattinasi
Copy link
Author

@joshdholtz - I will try and test this in the next day. It looks we will no longer be messing with availability and instead doing things on the app, and creating a CustomAppOrganization.

What is a CustomAppUser used for?

@joshdholtz
Copy link
Member

@mattinasi I guess it's another way to make B2B work? I don't really know to be honest lol... But my app store account had an option to select by "Organization" or "Apple ID" so I added the ability to add both 🤷‍♂

@mattinasi
Copy link
Author

Many, many thanks!! 🙏

@fastlane-bot
Copy link

The pull request #17490 that closed this issue was merged and released as part of fastlane 2.165.0 🚀
Please let us know if the functionality works as expected as a reply here. If it does not, please open a new issue. Thanks!

@joshdholtz joshdholtz moved this from Doing to Done in Just Josh Things Oct 26, 2020
@fastlane fastlane locked and limited conversation to collaborators Dec 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

Successfully merging a pull request may close this issue.

5 participants