Class: Spaceship::ConnectAPI

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
spaceship/lib/spaceship/connect_api.rb,
spaceship/lib/spaceship/connect_api/model.rb,
spaceship/lib/spaceship/connect_api/token.rb,
spaceship/lib/spaceship/connect_api/client.rb,
spaceship/lib/spaceship/connect_api/response.rb,
spaceship/lib/spaceship/connect_api/spaceship.rb,
spaceship/lib/spaceship/connect_api/api_client.rb,
spaceship/lib/spaceship/connect_api/models/app.rb,
spaceship/lib/spaceship/connect_api/models/user.rb,
spaceship/lib/spaceship/connect_api/tunes/tunes.rb,
spaceship/lib/spaceship/connect_api/users/users.rb,
spaceship/lib/spaceship/connect_api/models/actor.rb,
spaceship/lib/spaceship/connect_api/models/build.rb,
spaceship/lib/spaceship/connect_api/tunes/client.rb,
spaceship/lib/spaceship/connect_api/users/client.rb,
spaceship/lib/spaceship/connect_api/file_uploader.rb,
spaceship/lib/spaceship/connect_api/models/device.rb,
spaceship/lib/spaceship/connect_api/models/profile.rb,
spaceship/lib/spaceship/connect_api/models/app_info.rb,
spaceship/lib/spaceship/connect_api/models/app_price.rb,
spaceship/lib/spaceship/connect_api/models/bundle_id.rb,
spaceship/lib/spaceship/connect_api/models/territory.rb,
spaceship/lib/spaceship/connect_api/models/beta_group.rb,
spaceship/lib/spaceship/connect_api/testflight/client.rb,
spaceship/lib/spaceship/connect_api/models/app_preview.rb,
spaceship/lib/spaceship/connect_api/models/beta_tester.rb,
spaceship/lib/spaceship/connect_api/models/certificate.rb,
spaceship/lib/spaceship/connect_api/models/app_category.rb,
spaceship/lib/spaceship/connect_api/models/build_bundle.rb,
spaceship/lib/spaceship/connect_api/models/capabilities.rb,
spaceship/lib/spaceship/connect_api/provisioning/client.rb,
spaceship/lib/spaceship/connect_api/models/beta_feedback.rb,
spaceship/lib/spaceship/connect_api/models/app_data_usage.rb,
spaceship/lib/spaceship/connect_api/models/app_price_tier.rb,
spaceship/lib/spaceship/connect_api/models/app_screenshot.rb,
spaceship/lib/spaceship/connect_api/models/build_delivery.rb,
spaceship/lib/spaceship/connect_api/models/sandbox_tester.rb,
spaceship/lib/spaceship/connect_api/testflight/testflight.rb,
spaceship/lib/spaceship/connect_api/models/app_preview_set.rb,
spaceship/lib/spaceship/connect_api/models/app_price_point.rb,
spaceship/lib/spaceship/connect_api/models/beta_screenshot.rb,
spaceship/lib/spaceship/connect_api/models/custom_app_user.rb,
spaceship/lib/spaceship/connect_api/models/user_invitation.rb,
spaceship/lib/spaceship/connect_api/models/app_availability.rb,
spaceship/lib/spaceship/connect_api/models/review_rejection.rb,
spaceship/lib/spaceship/connect_api/models/app_store_version.rb,
spaceship/lib/spaceship/connect_api/models/beta_build_metric.rb,
spaceship/lib/spaceship/connect_api/models/build_beta_detail.rb,
spaceship/lib/spaceship/connect_api/models/review_submission.rb,
spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb,
spaceship/lib/spaceship/connect_api/models/beta_tester_metric.rb,
spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb,
spaceship/lib/spaceship/connect_api/models/pre_release_version.rb,
spaceship/lib/spaceship/connect_api/models/bundle_id_capability.rb,
spaceship/lib/spaceship/connect_api/models/app_info_localization.rb,
spaceship/lib/spaceship/connect_api/models/beta_app_localization.rb,
spaceship/lib/spaceship/connect_api/models/reset_ratings_request.rb,
spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb,
spaceship/lib/spaceship/connect_api/models/beta_app_review_detail.rb,
spaceship/lib/spaceship/connect_api/models/review_submission_item.rb,
spaceship/lib/spaceship/connect_api/models/territory_availability.rb,
spaceship/lib/spaceship/connect_api/models/app_data_usage_category.rb,
spaceship/lib/spaceship/connect_api/models/app_data_usage_grouping.rb,
spaceship/lib/spaceship/connect_api/models/app_data_usage_purposes.rb,
spaceship/lib/spaceship/connect_api/models/app_store_review_detail.rb,
spaceship/lib/spaceship/connect_api/models/beta_build_localization.rb,
spaceship/lib/spaceship/connect_api/models/build_bundle_file_sizes.rb,
spaceship/lib/spaceship/connect_api/models/custom_app_organization.rb,
spaceship/lib/spaceship/connect_api/models/resolution_center_thread.rb,
spaceship/lib/spaceship/connect_api/models/resolution_center_message.rb,
spaceship/lib/spaceship/connect_api/models/beta_app_review_submission.rb,
spaceship/lib/spaceship/connect_api/models/app_store_review_attachment.rb,
spaceship/lib/spaceship/connect_api/models/app_store_version_submission.rb,
spaceship/lib/spaceship/connect_api/models/app_data_usages_publish_state.rb,
spaceship/lib/spaceship/connect_api/models/app_data_usage_data_protection.rb,
spaceship/lib/spaceship/connect_api/models/app_store_version_localization.rb,
spaceship/lib/spaceship/connect_api/models/app_store_version_phased_release.rb,
spaceship/lib/spaceship/connect_api/models/app_store_version_release_request.rb

Defined Under Namespace

Modules: BundleIdPlatform, FileUploader, Model, Models, Platform, Provisioning, TestFlight, Tunes, Users Classes: APIClient, Actor, AgeRatingDeclaration, App, AppAvailability, AppCategory, AppDataUsage, AppDataUsageCategory, AppDataUsageDataProtection, AppDataUsageGrouping, AppDataUsagePurpose, AppDataUsagesPublishState, AppInfo, AppInfoLocalization, AppPreview, AppPreviewSet, AppPrice, AppPricePoint, AppPriceTier, AppScreenshot, AppScreenshotSet, AppStoreReviewAttachment, AppStoreReviewDetail, AppStoreVersion, AppStoreVersionLocalization, AppStoreVersionPhasedRelease, AppStoreVersionReleaseRequest, AppStoreVersionSubmission, BetaAppLocalization, BetaAppReviewDetail, BetaAppReviewSubmission, BetaBuildLocalization, BetaBuildMetric, BetaFeedback, BetaGroup, BetaScreenshot, BetaTester, BetaTesterMetric, Build, BuildBetaDetail, BuildBundle, BuildBundleFileSizes, BuildDelivery, BundleId, BundleIdCapability, Capabilities, Certificate, Client, CustomAppOrganization, CustomAppUser, Device, PreReleaseVersion, Profile, ResetRatingsRequest, ResolutionCenterMessage, ResolutionCenterThread, Response, ReviewRejection, ReviewSubmission, ReviewSubmissionItem, SandboxTester, Territory, TerritoryAvailability, Token, User, UserInvitation

Constant Summary collapse

MAX_OBJECTS_PER_PAGE_LIMIT =
200

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.clientObject

This client stores the global client when using the lazy syntax



9
10
11
# File 'spaceship/lib/spaceship/connect_api/spaceship.rb', line 9

def client
  @client
end

Class Method Details

.auth(key_id: nil, issuer_id: nil, filepath: nil, key: nil, duration: nil, in_house: nil) ⇒ Spaceship::ConnectAPI::Client

Initializes client with Apple’s App Store Connect JWT auth key.

This method will automatically use the arguments from environment variables if not given.

The key_id, issuer_id and either filepath or key are needed to authenticate.

Parameters:

  • key_id (String) (defaults to: nil)

    (optional): The key id

  • issuer_id (String) (defaults to: nil)

    (optional): The issuer id

  • filepath (String) (defaults to: nil)

    (optional): The filepath

  • key (String) (defaults to: nil)

    (optional): The key

  • duration (Integer) (defaults to: nil)

    (optional): How long this session should last

  • in_house (Boolean) (defaults to: nil)

    (optional): Whether this session is an Enterprise one

Returns:

Raises:

  • InvalidUserCredentialsError: raised if authentication failed



62
63
64
# File 'spaceship/lib/spaceship/connect_api/spaceship.rb', line 62

def auth(key_id: nil, issuer_id: nil, filepath: nil, key: nil, duration: nil, in_house: nil)
  @client = ConnectAPI::Client.auth(key_id: key_id, issuer_id: issuer_id, filepath: filepath, key: key, duration: duration, in_house: in_house)
end

.login(user = nil, password = nil, use_portal: true, use_tunes: true, portal_team_id: nil, tunes_team_id: nil, team_name: nil, skip_select_team: false) ⇒ Spaceship::ConnectAPI::Client

Authenticates with Apple’s web services. This method has to be called once to generate a valid session.

This method will automatically use the username from the Appfile (if available) and fetch the password from the Keychain (if available)

Parameters:

  • user (String) (defaults to: nil)

    (optional): The username (usually the email address)

  • password (String) (defaults to: nil)

    (optional): The password

  • use_portal (Boolean) (defaults to: true)

    (optional): Whether to log in to Spaceship::Portal or not

  • use_tunes (Boolean) (defaults to: true)

    (optional): Whether to log in to Spaceship::Tunes or not

  • portal_team_id (String) (defaults to: nil)

    (optional): The Spaceship::Portal team id

  • tunes_team_id (String) (defaults to: nil)

    (optional): The Spaceship::Tunes team id

  • team_name (String) (defaults to: nil)

    (optional): The team name

  • skip_select_team (Boolean) (defaults to: false)

    (optional): Whether to skip automatic selection or prompt for team

Returns:

Raises:

  • InvalidUserCredentialsError: raised if authentication failed



84
85
86
# File 'spaceship/lib/spaceship/connect_api/spaceship.rb', line 84

def (user = nil, password = nil, use_portal: true, use_tunes: true, portal_team_id: nil, tunes_team_id: nil, team_name: nil, skip_select_team: false)
  @client = ConnectAPI::Client.(user, password, use_portal: use_portal, use_tunes: use_tunes, portal_team_id: portal_team_id, tunes_team_id: tunes_team_id, team_name: team_name, skip_select_team: skip_select_team)
end

.select_team(portal_team_id: nil, tunes_team_id: nil, team_name: nil) ⇒ Object

Open up the team selection for the user (if necessary).

If the user is in multiple teams, a team selection is shown. The user can then select a team by entering the number

Parameters:

  • portal_team_id (String) (defaults to: nil)

    (optional): The Spaceship::Portal team id

  • tunes_team_id (String) (defaults to: nil)

    (optional): The Spaceship::Tunes team id

  • team_name (String) (defaults to: nil)

    (optional): The name of an App Store Connect team



96
97
98
99
# File 'spaceship/lib/spaceship/connect_api/spaceship.rb', line 96

def select_team(portal_team_id: nil, tunes_team_id: nil, team_name: nil)
  return if client.nil?
  client.select_team(portal_team_id: portal_team_id, tunes_team_id: tunes_team_id, team_name: team_name)
end

.tokenObject



36
37
38
39
# File 'spaceship/lib/spaceship/connect_api/spaceship.rb', line 36

def token
  return nil if @client.nil?
  return @client.token
end

.token=(token) ⇒ Object



32
33
34
# File 'spaceship/lib/spaceship/connect_api/spaceship.rb', line 32

def token=(token)
  @client = ConnectAPI::Client.new(token: token)
end

.token?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'spaceship/lib/spaceship/connect_api/spaceship.rb', line 41

def token?
  (@client && @client.token)
end