fastlane 2.126.0.beta.20190606200048 → 2.126.0.beta.20190607200028

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/fastlane/lib/fastlane/actions/app_store_build_number.rb +1 -1
  3. data/fastlane/lib/fastlane/version.rb +1 -1
  4. data/fastlane_core/lib/fastlane_core/build_watcher.rb +3 -4
  5. data/pilot/lib/pilot/build_manager.rb +7 -7
  6. data/pilot/lib/pilot/manager.rb +2 -2
  7. data/pilot/lib/pilot/tester_exporter.rb +3 -3
  8. data/pilot/lib/pilot/tester_manager.rb +2 -2
  9. data/spaceship/lib/spaceship/connect_api.rb +2 -17
  10. data/spaceship/lib/spaceship/connect_api/{models/model.rb → model.rb} +5 -4
  11. data/spaceship/lib/spaceship/connect_api/response.rb +4 -7
  12. data/spaceship/lib/spaceship/connect_api/testflight/base.rb +41 -0
  13. data/spaceship/lib/spaceship/connect_api/testflight/client.rb +553 -0
  14. data/spaceship/lib/spaceship/connect_api/testflight/models/app.rb +99 -0
  15. data/spaceship/lib/spaceship/connect_api/testflight/models/beta_app_localization.rb +30 -0
  16. data/spaceship/lib/spaceship/connect_api/testflight/models/beta_app_review_detail.rb +34 -0
  17. data/spaceship/lib/spaceship/connect_api/testflight/models/beta_app_review_submission.rb +28 -0
  18. data/spaceship/lib/spaceship/connect_api/testflight/models/beta_build_localization.rb +22 -0
  19. data/spaceship/lib/spaceship/connect_api/testflight/models/beta_build_metric.rb +26 -0
  20. data/spaceship/lib/spaceship/connect_api/testflight/models/beta_group.rb +43 -0
  21. data/spaceship/lib/spaceship/connect_api/testflight/models/beta_tester.rb +58 -0
  22. data/spaceship/lib/spaceship/connect_api/testflight/models/beta_tester_metric.rb +45 -0
  23. data/spaceship/lib/spaceship/connect_api/testflight/models/build.rb +146 -0
  24. data/spaceship/lib/spaceship/connect_api/testflight/models/build_beta_detail.rb +58 -0
  25. data/spaceship/lib/spaceship/connect_api/testflight/models/build_delivery.rb +38 -0
  26. data/spaceship/lib/spaceship/connect_api/testflight/models/pre_release_version.rb +22 -0
  27. data/spaceship/lib/spaceship/connect_api/testflight/models/user.rb +52 -0
  28. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +27 -0
  29. data/spaceship/lib/spaceship/test_flight/build.rb +3 -3
  30. data/spaceship/lib/spaceship/test_flight/build_trains.rb +1 -1
  31. metadata +34 -33
  32. data/spaceship/lib/spaceship/connect_api/base.rb +0 -39
  33. data/spaceship/lib/spaceship/connect_api/client.rb +0 -551
  34. data/spaceship/lib/spaceship/connect_api/models/app.rb +0 -97
  35. data/spaceship/lib/spaceship/connect_api/models/beta_app_localization.rb +0 -28
  36. data/spaceship/lib/spaceship/connect_api/models/beta_app_review_detail.rb +0 -32
  37. data/spaceship/lib/spaceship/connect_api/models/beta_app_review_submission.rb +0 -26
  38. data/spaceship/lib/spaceship/connect_api/models/beta_build_localization.rb +0 -20
  39. data/spaceship/lib/spaceship/connect_api/models/beta_build_metric.rb +0 -24
  40. data/spaceship/lib/spaceship/connect_api/models/beta_group.rb +0 -41
  41. data/spaceship/lib/spaceship/connect_api/models/beta_tester.rb +0 -56
  42. data/spaceship/lib/spaceship/connect_api/models/beta_tester_metric.rb +0 -43
  43. data/spaceship/lib/spaceship/connect_api/models/build.rb +0 -144
  44. data/spaceship/lib/spaceship/connect_api/models/build_beta_detail.rb +0 -56
  45. data/spaceship/lib/spaceship/connect_api/models/build_delivery.rb +0 -36
  46. data/spaceship/lib/spaceship/connect_api/models/pre_release_version.rb +0 -20
  47. data/spaceship/lib/spaceship/connect_api/models/user.rb +0 -50
@@ -0,0 +1,58 @@
1
+ require_relative '../../model'
2
+ module Spaceship
3
+ module ConnectAPI
4
+ module TestFlight
5
+ class BuildBetaDetail
6
+ include Spaceship::ConnectAPI::Model
7
+
8
+ attr_accessor :auto_notify_enabled
9
+ attr_accessor :did_notify
10
+ attr_accessor :internal_build_state
11
+ attr_accessor :external_build_state
12
+
13
+ module InternalState
14
+ PROCESSING_EXCEPTION = "PROCESSING_EXCEPTION"
15
+ MISSING_EXPORT_COMPLIANCE = "MISSING_EXPORT_COMPLIANCE"
16
+ READY_FOR_BETA_TESTING = "READY_FOR_BETA_TESTING"
17
+ IN_BETA_TESTING = "IN_BETA_TESTING"
18
+ EXPIRED = "EXPIRED"
19
+ IN_EXPORT_COMPLIANCE_REVIEW = "IN_EXPORT_COMPLIANCE_REVIEW"
20
+ end
21
+
22
+ module ExternalState
23
+ PROCESSING = "PROCESSING"
24
+ PROCESSING_EXCEPTION = "PROCESSING_EXCEPTION"
25
+ MISSING_EXPORT_COMPLIANCE = "MISSING_EXPORT_COMPLIANCE"
26
+ READY_FOR_BETA_TESTING = "READY_FOR_BETA_TESTING"
27
+ IN_BETA_TESTING = "IN_BETA_TESTING"
28
+ EXPIRED = "EXPIRED"
29
+ READY_FOR_BETA_SUBMISSION = "READY_FOR_BETA_SUBMISSION"
30
+ IN_EXPORT_COMPLIANCE_REVIEW = "IN_EXPORT_COMPLIANCE_REVIEW"
31
+ WAITING_FOR_BETA_REVIEW = "WAITING_FOR_BETA_REVIEW"
32
+ IN_BETA_REVIEW = "IN_BETA_REVIEW"
33
+ BETA_REJECTED = "BETA_REJECTED"
34
+ BETA_APPROVED = "BETA_APPROVED"
35
+ end
36
+
37
+ attr_mapping({
38
+ "autoNotifyEnabled" => "auto_notify_enabled",
39
+ "didNotify" => "did_notify",
40
+ "internalBuildState" => "internal_build_state",
41
+ "externalBuildState" => "external_build_state"
42
+ })
43
+
44
+ def self.type
45
+ return "buildBetaDetails"
46
+ end
47
+
48
+ #
49
+ # Helpers
50
+ #
51
+
52
+ def ready_for_beta_submission?
53
+ return external_build_state == ExternalState::READY_FOR_BETA_SUBMISSION
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,38 @@
1
+ require_relative '../../model'
2
+ module Spaceship
3
+ module ConnectAPI
4
+ module TestFlight
5
+ class BuildDelivery
6
+ include Spaceship::ConnectAPI::Model
7
+
8
+ attr_accessor :cf_build_version
9
+ attr_accessor :cf_build_short_version_string
10
+ attr_accessor :platform
11
+ attr_accessor :uploaded_date
12
+
13
+ attr_mapping({
14
+ "cfBundleVersion" => "cf_build_version",
15
+ "cfBundleShortVersionString" => "cf_build_short_version_string",
16
+ "platform" => "platform",
17
+ "uploadedDate" => "uploaded_date"
18
+ })
19
+
20
+ def self.type
21
+ return "buildDeliveries"
22
+ end
23
+
24
+ #
25
+ # API
26
+ #
27
+
28
+ def self.all(app_id: nil, version: nil, build_number: nil)
29
+ resps = testflight_client.get_build_deliveries(
30
+ filter: { app: app_id, cfBundleShortVersionString: version, cfBundleVersion: build_number },
31
+ limit: 1
32
+ ).all_pages
33
+ return resps.map(&:to_models).flatten
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../../model'
2
+ module Spaceship
3
+ module ConnectAPI
4
+ module TestFlight
5
+ class PreReleaseVersion
6
+ include Spaceship::ConnectAPI::Model
7
+
8
+ attr_accessor :version
9
+ attr_accessor :platform
10
+
11
+ attr_mapping({
12
+ "version" => "version",
13
+ "platform" => "platform"
14
+ })
15
+
16
+ def self.type
17
+ return "preReleaseVersions"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,52 @@
1
+ require_relative '../../model'
2
+ module Spaceship
3
+ module ConnectAPI
4
+ module TestFlight
5
+ class User
6
+ include Spaceship::ConnectAPI::Model
7
+
8
+ attr_accessor :username
9
+ attr_accessor :first_name
10
+ attr_accessor :last_name
11
+ attr_accessor :email
12
+ attr_accessor :preferred_currency_territory
13
+ attr_accessor :agreed_to_terms
14
+ attr_accessor :roles
15
+ attr_accessor :all_apps_visible
16
+ attr_accessor :provisioning_allowed
17
+ attr_accessor :email_vetting_required
18
+ attr_accessor :notifications
19
+
20
+ attr_mapping({
21
+ "username" => "username",
22
+ "firstName" => "first_name",
23
+ "lastName" => "last_name",
24
+ "email" => "email",
25
+ "preferredCurrencyTerritory" => "preferred_currency_territory",
26
+ "agreedToTerms" => "agreed_to_terms",
27
+ "roles" => "roles",
28
+ "allAppsVisible" => "all_apps_visible",
29
+ "provisioningAllowed" => "provisioning_allowed",
30
+ "emailVettingRequired" => "email_vetting_required",
31
+ "notifications" => "notifications"
32
+ })
33
+
34
+ def self.type
35
+ return "users"
36
+ end
37
+
38
+ #
39
+ # API
40
+ #
41
+
42
+ def self.all(filter: {}, includes: nil, limit: nil, sort: nil)
43
+ return client.get_users(filter: filter, includes: includes)
44
+ end
45
+
46
+ def self.find(email: nil, includes: nil)
47
+ return all(filter: { email: email }, includes: includes)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,27 @@
1
+ require 'spaceship/connect_api/testflight/client'
2
+ require 'spaceship/connect_api/testflight/base'
3
+
4
+ require 'spaceship/connect_api/testflight/models/app'
5
+ require 'spaceship/connect_api/testflight/models/beta_app_localization'
6
+ require 'spaceship/connect_api/testflight/models/beta_build_localization'
7
+ require 'spaceship/connect_api/testflight/models/beta_build_metric'
8
+ require 'spaceship/connect_api/testflight/models/beta_app_review_detail'
9
+ require 'spaceship/connect_api/testflight/models/beta_app_review_submission'
10
+ require 'spaceship/connect_api/testflight/models/beta_group'
11
+ require 'spaceship/connect_api/testflight/models/beta_tester'
12
+ require 'spaceship/connect_api/testflight/models/beta_tester_metric'
13
+ require 'spaceship/connect_api/testflight/models/build'
14
+ require 'spaceship/connect_api/testflight/models/build_delivery'
15
+ require 'spaceship/connect_api/testflight/models/build_beta_detail'
16
+ require 'spaceship/connect_api/testflight/models/pre_release_version'
17
+ require 'spaceship/connect_api/testflight/models/user'
18
+
19
+ module Spaceship
20
+ module ConnectAPI
21
+ module TestFlight
22
+ def self.client
23
+ return Spaceship::ConnectAPI::TestFlight::Base.client
24
+ end
25
+ end
26
+ end
27
+ end
@@ -6,7 +6,7 @@ require_relative 'export_compliance'
6
6
  require_relative 'beta_review_info'
7
7
  require_relative 'build_trains'
8
8
 
9
- require_relative '../connect_api/base'
9
+ require_relative '../connect_api'
10
10
 
11
11
  module Spaceship
12
12
  module TestFlight
@@ -218,7 +218,7 @@ module Spaceship
218
218
  return if approved?
219
219
 
220
220
  build = find_app_store_connect_build
221
- Spaceship::ConnectAPI::Base.client.post_beta_app_review_submissions(build_id: build["id"])
221
+ Spaceship::ConnectAPI::TestFlight.client.post_beta_app_review_submissions(build_id: build["id"])
222
222
  end
223
223
 
224
224
  def expire!
@@ -231,7 +231,7 @@ module Spaceship
231
231
 
232
232
  # Bridges the TestFlight::Build to the App Store Connect API build
233
233
  def find_app_store_connect_build
234
- resp = Spaceship::ConnectAPI::Base.client.get_builds(filter: { expired: false, processingState: "PROCESSING,VALID", version: self.build_version, "preReleaseVersion.version" => self.train_version, app: app_id })
234
+ resp = Spaceship::ConnectAPI::TestFlight.client.get_builds(filter: { expired: false, processingState: "PROCESSING,VALID", version: self.build_version, "preReleaseVersion.version" => self.train_version, app: app_id })
235
235
  resp.first
236
236
  end
237
237
  end
@@ -13,7 +13,7 @@ module Spaceship::TestFlight
13
13
  # See `Spaceship::TestFlight::Build#reload`
14
14
 
15
15
  def self.all(app_id: nil, platform: nil, retry_count: 3)
16
- client = Spaceship::ConnectAPI::Base.client
16
+ client = Spaceship::ConnectAPI::TestFlight.client
17
17
 
18
18
  builds = []
19
19
  included = []
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.126.0.beta.20190606200048
4
+ version: 2.126.0.beta.20190607200028
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Liebowitz
@@ -27,7 +27,7 @@ authors:
27
27
  autorequire:
28
28
  bindir: bin
29
29
  cert_chain: []
30
- date: 2019-06-06 00:00:00.000000000 Z
30
+ date: 2019-06-07 00:00:00.000000000 Z
31
31
  dependencies:
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: slack-notifier
@@ -1587,24 +1587,25 @@ files:
1587
1587
  - spaceship/lib/spaceship/client.rb
1588
1588
  - spaceship/lib/spaceship/commands_generator.rb
1589
1589
  - spaceship/lib/spaceship/connect_api.rb
1590
- - spaceship/lib/spaceship/connect_api/base.rb
1591
- - spaceship/lib/spaceship/connect_api/client.rb
1592
- - spaceship/lib/spaceship/connect_api/models/app.rb
1593
- - spaceship/lib/spaceship/connect_api/models/beta_app_localization.rb
1594
- - spaceship/lib/spaceship/connect_api/models/beta_app_review_detail.rb
1595
- - spaceship/lib/spaceship/connect_api/models/beta_app_review_submission.rb
1596
- - spaceship/lib/spaceship/connect_api/models/beta_build_localization.rb
1597
- - spaceship/lib/spaceship/connect_api/models/beta_build_metric.rb
1598
- - spaceship/lib/spaceship/connect_api/models/beta_group.rb
1599
- - spaceship/lib/spaceship/connect_api/models/beta_tester.rb
1600
- - spaceship/lib/spaceship/connect_api/models/beta_tester_metric.rb
1601
- - spaceship/lib/spaceship/connect_api/models/build.rb
1602
- - spaceship/lib/spaceship/connect_api/models/build_beta_detail.rb
1603
- - spaceship/lib/spaceship/connect_api/models/build_delivery.rb
1604
- - spaceship/lib/spaceship/connect_api/models/model.rb
1605
- - spaceship/lib/spaceship/connect_api/models/pre_release_version.rb
1606
- - spaceship/lib/spaceship/connect_api/models/user.rb
1590
+ - spaceship/lib/spaceship/connect_api/model.rb
1607
1591
  - spaceship/lib/spaceship/connect_api/response.rb
1592
+ - spaceship/lib/spaceship/connect_api/testflight/base.rb
1593
+ - spaceship/lib/spaceship/connect_api/testflight/client.rb
1594
+ - spaceship/lib/spaceship/connect_api/testflight/models/app.rb
1595
+ - spaceship/lib/spaceship/connect_api/testflight/models/beta_app_localization.rb
1596
+ - spaceship/lib/spaceship/connect_api/testflight/models/beta_app_review_detail.rb
1597
+ - spaceship/lib/spaceship/connect_api/testflight/models/beta_app_review_submission.rb
1598
+ - spaceship/lib/spaceship/connect_api/testflight/models/beta_build_localization.rb
1599
+ - spaceship/lib/spaceship/connect_api/testflight/models/beta_build_metric.rb
1600
+ - spaceship/lib/spaceship/connect_api/testflight/models/beta_group.rb
1601
+ - spaceship/lib/spaceship/connect_api/testflight/models/beta_tester.rb
1602
+ - spaceship/lib/spaceship/connect_api/testflight/models/beta_tester_metric.rb
1603
+ - spaceship/lib/spaceship/connect_api/testflight/models/build.rb
1604
+ - spaceship/lib/spaceship/connect_api/testflight/models/build_beta_detail.rb
1605
+ - spaceship/lib/spaceship/connect_api/testflight/models/build_delivery.rb
1606
+ - spaceship/lib/spaceship/connect_api/testflight/models/pre_release_version.rb
1607
+ - spaceship/lib/spaceship/connect_api/testflight/models/user.rb
1608
+ - spaceship/lib/spaceship/connect_api/testflight/testflight.rb
1608
1609
  - spaceship/lib/spaceship/connect_api/token.rb
1609
1610
  - spaceship/lib/spaceship/du/du_client.rb
1610
1611
  - spaceship/lib/spaceship/du/upload_file.rb
@@ -1724,24 +1725,24 @@ metadata:
1724
1725
  post_install_message:
1725
1726
  rdoc_options: []
1726
1727
  require_paths:
1727
- - frameit/lib
1728
- - gym/lib
1729
- - sigh/lib
1730
- - credentials_manager/lib
1731
- - match/lib
1732
- - precheck/lib
1733
- - fastlane/lib
1734
- - produce/lib
1735
1728
  - supply/lib
1736
- - scan/lib
1737
- - pilot/lib
1738
- - fastlane_core/lib
1739
1729
  - cert/lib
1740
- - screengrab/lib
1730
+ - fastlane/lib
1741
1731
  - spaceship/lib
1742
- - pem/lib
1743
- - deliver/lib
1744
1732
  - snapshot/lib
1733
+ - scan/lib
1734
+ - fastlane_core/lib
1735
+ - pilot/lib
1736
+ - deliver/lib
1737
+ - pem/lib
1738
+ - precheck/lib
1739
+ - sigh/lib
1740
+ - gym/lib
1741
+ - screengrab/lib
1742
+ - credentials_manager/lib
1743
+ - produce/lib
1744
+ - frameit/lib
1745
+ - match/lib
1745
1746
  required_ruby_version: !ruby/object:Gem::Requirement
1746
1747
  requirements:
1747
1748
  - - ">="
@@ -1,39 +0,0 @@
1
- require_relative '../base'
2
- require_relative '../tunes/tunes_client'
3
-
4
- module Spaceship
5
- module ConnectAPI
6
- class Base < Spaceship::Base
7
- def self.client
8
- # Verify there is a client that can be used
9
- if Spaceship::Tunes.client
10
- # Initialize new client if new or if team changed
11
- if @client.nil? || @client.team_id != Spaceship::Tunes.client.team_id
12
- @client = Client.client_with_authorization_from(Spaceship::Tunes.client)
13
- end
14
- end
15
-
16
- # Need to handle not having a client but this shouldn't ever happen
17
- raise "Please login using `Spaceship::Tunes.login('user', 'password')`" unless @client
18
-
19
- @client
20
- end
21
-
22
- ##
23
- # Have subclasses inherit the client from their superclass
24
- #
25
- # Essentially, we are making a class-inheritable-accessor as described here:
26
- # https://apidock.com/rails/v4.2.7/Class/class_attribute
27
- def self.inherited(subclass)
28
- this_class = self
29
- subclass.define_singleton_method(:client) do
30
- this_class.client
31
- end
32
- end
33
-
34
- def to_json
35
- raw_data.to_json
36
- end
37
- end
38
- end
39
- end
@@ -1,551 +0,0 @@
1
- require_relative '../client'
2
- require_relative './response'
3
-
4
- module Spaceship
5
- # rubocop:disable Metrics/ClassLength
6
- module ConnectAPI
7
- class Client < Spaceship::Client
8
- ##
9
- # Spaceship HTTP client for the App Store Connect API.
10
- #
11
- # This client is solely responsible for the making HTTP requests and
12
- # parsing their responses. Parameters should be either named parameters, or
13
- # for large request data bodies, pass in anything that can resond to
14
- # `to_json`.
15
- #
16
- # Each request method should validate the required parameters. A required parameter is one that would result in 400-range response if it is not supplied.
17
- # Each request method should make only one request. For more high-level logic, put code in the data models.
18
-
19
- def self.hostname
20
- 'https://appstoreconnect.apple.com/iris/v1/'
21
- end
22
-
23
- #
24
- # Helpers
25
- #
26
-
27
- def build_params(filter: nil, includes: nil, limit: nil, sort: nil, cursor: nil)
28
- params = {}
29
-
30
- filter = filter.delete_if { |k, v| v.nil? } if filter
31
-
32
- params[:filter] = filter if filter && !filter.empty?
33
- params[:include] = includes if includes
34
- params[:limit] = limit if limit
35
- params[:sort] = sort if sort
36
- params[:cursor] = cursor if cursor
37
-
38
- return params
39
- end
40
-
41
- def get(url_or_path, params = nil)
42
- response = request(:get) do |req|
43
- req.url(url_or_path)
44
- req.options.params_encoder = Faraday::NestedParamsEncoder
45
- req.params = params if params
46
- end
47
- handle_response(response)
48
- end
49
-
50
- def post(url_or_path, body)
51
- response = request(:post) do |req|
52
- req.url(url_or_path)
53
- req.body = body.to_json
54
- req.headers['Content-Type'] = 'application/json'
55
- end
56
- handle_response(response)
57
- end
58
-
59
- def patch(url_or_path, body)
60
- response = request(:patch) do |req|
61
- req.url(url_or_path)
62
- req.body = body.to_json
63
- req.headers['Content-Type'] = 'application/json'
64
- end
65
- handle_response(response)
66
- end
67
-
68
- def delete(url_or_path, params = nil, body = nil)
69
- response = request(:delete) do |req|
70
- req.url(url_or_path)
71
- req.options.params_encoder = Faraday::NestedParamsEncoder if params
72
- req.params = params if params
73
- req.body = body.to_json if body
74
- req.headers['Content-Type'] = 'application/json' if body
75
- end
76
- handle_response(response)
77
- end
78
-
79
- #
80
- # apps
81
- #
82
-
83
- def get_apps(filter: {}, includes: nil, limit: nil, sort: nil)
84
- # GET
85
- # https://appstoreconnect.apple.com/iris/v1/apps
86
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
87
- get("apps", params)
88
- end
89
-
90
- def get_app(app_id: nil, includes: nil)
91
- # GET
92
- # https://appstoreconnect.apple.com/iris/v1/apps/<app_id>
93
- params = build_params(filter: nil, includes: includes, limit: nil, sort: nil)
94
- get("apps/#{app_id}", params)
95
- end
96
-
97
- #
98
- # betaAppLocalizations
99
- #
100
-
101
- def get_beta_app_localizations(filter: {}, includes: nil, limit: nil, sort: nil)
102
- # GET
103
- # https://appstoreconnect.apple.com/iris/v1/betaAppLocalizations?filter[app]=<app_id>
104
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
105
- get("betaAppLocalizations", params)
106
- end
107
-
108
- def post_beta_app_localizations(app_id: nil, attributes: {})
109
- # POST
110
- # https://appstoreconnect.apple.com/iris/v1/betaAppLocalizations
111
- path = "betaAppLocalizations"
112
-
113
- body = {
114
- data: {
115
- attributes: attributes,
116
- type: "betaAppLocalizations",
117
- relationships: {
118
- app: {
119
- data: {
120
- type: "apps",
121
- id: app_id
122
- }
123
- }
124
- }
125
- }
126
- }
127
-
128
- post(path, body)
129
- end
130
-
131
- def patch_beta_app_localizations(localization_id: nil, attributes: {})
132
- # PATCH
133
- # https://appstoreconnect.apple.com/iris/v1/apps/<app_id>/betaAppLocalizations/<localization_id>
134
- path = "betaAppLocalizations/#{localization_id}"
135
-
136
- body = {
137
- data: {
138
- attributes: attributes,
139
- id: localization_id,
140
- type: "betaAppLocalizations"
141
- }
142
- }
143
-
144
- patch(path, body)
145
- end
146
-
147
- #
148
- # betaAppReviewDetails
149
- #
150
-
151
- def get_beta_app_review_detail(filter: {}, includes: nil, limit: nil, sort: nil)
152
- # GET
153
- # https://appstoreconnect.apple.com/iris/v1/betaAppReviewDetails?filter[app]=<app_id>
154
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
155
- get("betaAppReviewDetails", params)
156
- end
157
-
158
- def patch_beta_app_review_detail(app_id: nil, attributes: {})
159
- # PATCH
160
- # https://appstoreconnect.apple.com/iris/v1/apps/<app_id>/betaAppReviewDetails
161
- path = "betaAppReviewDetails/#{app_id}"
162
-
163
- body = {
164
- data: {
165
- attributes: attributes,
166
- id: app_id,
167
- type: "betaAppReviewDetails"
168
- }
169
- }
170
-
171
- patch(path, body)
172
- end
173
-
174
- #
175
- # betaAppReviewSubmissions
176
- #
177
-
178
- def get_beta_app_review_submissions(filter: {}, includes: nil, limit: nil, sort: nil, cursor: nil)
179
- # GET
180
- # https://appstoreconnect.apple.com/iris/v1/betaAppReviewSubmissions
181
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort, cursor: cursor)
182
- get("betaAppReviewSubmissions", params)
183
- end
184
-
185
- def post_beta_app_review_submissions(build_id: nil)
186
- # POST
187
- # https://appstoreconnect.apple.com/iris/v1/betaAppReviewSubmissions
188
- path = "betaAppReviewSubmissions"
189
- body = {
190
- data: {
191
- type: "betaAppReviewSubmissions",
192
- relationships: {
193
- build: {
194
- data: {
195
- type: "builds",
196
- id: build_id
197
- }
198
- }
199
- }
200
- }
201
- }
202
-
203
- post(path, body)
204
- end
205
-
206
- def delete_beta_app_review_submission(beta_app_review_submission_id: nil)
207
- # DELETE
208
- # https://appstoreconnect.apple.com/iris/v1/betaAppReviewSubmissions/<beta_app_review_submission_id>
209
- params = build_params(filter: nil, includes: nil, limit: nil, sort: nil, cursor: nil)
210
- delete("betaAppReviewSubmissions/#{beta_app_review_submission_id}", params)
211
- end
212
-
213
- #
214
- # betaBuildLocalizations
215
- #
216
-
217
- def get_beta_build_localizations(filter: {}, includes: nil, limit: nil, sort: nil)
218
- # GET
219
- # https://appstoreconnect.apple.com/iris/v1/betaBuildLocalizations
220
- path = "betaBuildLocalizations"
221
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
222
- get(path, params)
223
- end
224
-
225
- def post_beta_build_localizations(build_id: nil, attributes: {})
226
- # POST
227
- # https://appstoreconnect.apple.com/iris/v1/betaBuildLocalizations
228
- path = "betaBuildLocalizations"
229
-
230
- body = {
231
- data: {
232
- attributes: attributes,
233
- type: "betaBuildLocalizations",
234
- relationships: {
235
- build: {
236
- data: {
237
- type: "builds",
238
- id: build_id
239
- }
240
- }
241
- }
242
- }
243
- }
244
-
245
- post(path, body)
246
- end
247
-
248
- def patch_beta_build_localizations(localization_id: nil, feedbackEmail: nil, attributes: {})
249
- # PATCH
250
- # https://appstoreconnect.apple.com/iris/v1/apps/<app_id>/betaBuildLocalizations
251
- path = "betaBuildLocalizations/#{localization_id}"
252
-
253
- body = {
254
- data: {
255
- attributes: attributes,
256
- id: localization_id,
257
- type: "betaBuildLocalizations"
258
- }
259
- }
260
-
261
- patch(path, body)
262
- end
263
-
264
- #
265
- # betaBuildMetrics
266
- #
267
-
268
- def get_beta_build_metrics(filter: {}, includes: nil, limit: nil, sort: nil)
269
- # GET
270
- # https://appstoreconnect.apple.com/iris/v1/betaBuildMetrics
271
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
272
- get("betaBuildMetrics", params)
273
- end
274
-
275
- #
276
- # betaGroups
277
- #
278
-
279
- def get_beta_groups(filter: {}, includes: nil, limit: nil, sort: nil)
280
- # GET
281
- # https://appstoreconnect.apple.com/iris/v1/betaGroups
282
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
283
- get("betaGroups", params)
284
- end
285
-
286
- def add_beta_groups_to_build(build_id: nil, beta_group_ids: [])
287
- # POST
288
- # https://appstoreconnect.apple.com/iris/v1/builds/<build_id>/relationships/betaGroups
289
- path = "builds/#{build_id}/relationships/betaGroups"
290
- body = {
291
- data: beta_group_ids.map do |id|
292
- {
293
- type: "betaGroups",
294
- id: id
295
- }
296
- end
297
- }
298
-
299
- post(path, body)
300
- end
301
-
302
- #
303
- # betaTesters
304
- #
305
-
306
- def get_beta_testers(filter: {}, includes: nil, limit: nil, sort: nil)
307
- # GET
308
- # https://appstoreconnect.apple.com/iris/v1/betaTesters
309
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
310
- get("betaTesters", params)
311
- end
312
-
313
- # beta_testers - [{email: "", firstName: "", lastName: ""}]
314
- def post_bulk_beta_tester_assignments(beta_group_id: nil, beta_testers: nil)
315
- # POST
316
- # https://appstoreconnect.apple.com/iris/v1/bulkBetaTesterAssignments
317
- beta_testers || []
318
-
319
- beta_testers.map do |tester|
320
- tester[:errors] = []
321
- end
322
-
323
- body = {
324
- data: {
325
- attributes: {
326
- betaTesters: beta_testers
327
- },
328
- relationships: {
329
- betaGroup: {
330
- data: {
331
- type: "betaGroups",
332
- id: beta_group_id
333
- }
334
- }
335
- },
336
- type: "bulkBetaTesterAssignments"
337
- }
338
- }
339
-
340
- post("bulkBetaTesterAssignments", body)
341
- end
342
-
343
- def delete_beta_tester_from_apps(beta_tester_id: nil, app_ids: [])
344
- # DELETE
345
- # https://appstoreconnect.apple.com/iris/v1/betaTesters/<beta_tester_id>/relationships/apps
346
- path = "betaTesters/#{beta_tester_id}/relationships/apps"
347
- body = {
348
- data: app_ids.map do |id|
349
- {
350
- type: "apps",
351
- id: id
352
- }
353
- end
354
- }
355
-
356
- delete(path, nil, body)
357
- end
358
-
359
- def delete_beta_tester_from_beta_groups(beta_tester_id: nil, beta_group_ids: [])
360
- # DELETE
361
- # https://appstoreconnect.apple.com/iris/v1/betaTesters/<beta_tester_id>/relationships/betaGroups
362
- path = "betaTesters/#{beta_tester_id}/relationships/betaGroups"
363
- body = {
364
- data: beta_group_ids.map do |id|
365
- {
366
- type: "betaGroups",
367
- id: id
368
- }
369
- end
370
- }
371
-
372
- delete(path, nil, body)
373
- end
374
-
375
- #
376
- # betaTesterMetrics
377
- #
378
-
379
- def get_beta_tester_metrics(filter: {}, includes: nil, limit: nil, sort: nil)
380
- # GET
381
- # https://appstoreconnect.apple.com/iris/v1/betaTesterMetrics
382
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
383
- get("betaTesterMetrics", params)
384
- end
385
-
386
- #
387
- # builds
388
- #
389
-
390
- def get_builds(filter: {}, includes: "buildBetaDetail,betaBuildMetrics", limit: 10, sort: "uploadedDate", cursor: nil)
391
- # GET
392
- # https://appstoreconnect.apple.com/iris/v1/builds
393
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort, cursor: cursor)
394
- get("builds", params)
395
- end
396
-
397
- def get_build(build_id: nil, includes: nil)
398
- # GET
399
- # https://appstoreconnect.apple.com/iris/v1/builds/<build_id>?
400
- params = build_params(filter: nil, includes: includes, limit: nil, sort: nil, cursor: nil)
401
- get("builds/#{build_id}", params)
402
- end
403
-
404
- def patch_builds(build_id: nil, attributes: {})
405
- # PATCH
406
- # https://appstoreconnect.apple.com/iris/v1/builds/<build_id>
407
- path = "builds/#{build_id}"
408
-
409
- body = {
410
- data: {
411
- attributes: attributes,
412
- id: build_id,
413
- type: "builds"
414
- }
415
- }
416
-
417
- patch(path, body)
418
- end
419
-
420
- #
421
- # buildBetaDetails
422
- #
423
-
424
- def get_build_beta_details(filter: {}, includes: nil, limit: nil, sort: nil)
425
- # GET
426
- # https://appstoreconnect.apple.com/iris/v1/buildBetaDetails
427
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
428
- get("buildBetaDetails", params)
429
- end
430
-
431
- def patch_build_beta_details(build_beta_details_id: nil, attributes: {})
432
- # PATCH
433
- # https://appstoreconnect.apple.com/iris/v1/buildBetaDetails/<build_beta_details_id>
434
- path = "buildBetaDetails/#{build_beta_details_id}"
435
-
436
- body = {
437
- data: {
438
- attributes: attributes,
439
- id: build_beta_details_id,
440
- type: "buildBetaDetails"
441
- }
442
- }
443
-
444
- patch(path, body)
445
- end
446
-
447
- #
448
- # buildDeliveries
449
- #
450
-
451
- def get_build_deliveries(filter: {}, includes: nil, limit: nil, sort: nil)
452
- # GET
453
- # https://appstoreconnect.apple.com/iris/v1/buildDeliveries
454
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
455
- get("buildDeliveries", params)
456
- end
457
-
458
- #
459
- # preReleaseVersions
460
- #
461
-
462
- def get_pre_release_versions(filter: {}, includes: nil, limit: nil, sort: nil)
463
- # GET
464
- # https://appstoreconnect.apple.com/iris/v1/preReleaseVersions
465
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
466
- get("preReleaseVersions", params)
467
- end
468
-
469
- #
470
- # users
471
- #
472
-
473
- def get_users(filter: {}, includes: nil, limit: nil, sort: nil)
474
- # GET
475
- # https://appstoreconnect.apple.com/iris/v1/users
476
- params = build_params(filter: filter, includes: includes, limit: limit, sort: sort)
477
- get("users", params)
478
- end
479
-
480
- protected
481
-
482
- def handle_response(response)
483
- if (200...300).cover?(response.status) && (response.body.nil? || response.body.empty?)
484
- return
485
- end
486
-
487
- raise InternalServerError, "Server error got #{response.status}" if (500...600).cover?(response.status)
488
-
489
- unless response.body.kind_of?(Hash)
490
- raise UnexpectedResponse, response.body
491
- end
492
-
493
- raise UnexpectedResponse, response.body['error'] if response.body['error']
494
-
495
- raise UnexpectedResponse, handle_errors(response) if response.body['errors']
496
-
497
- raise UnexpectedResponse, "Temporary App Store Connect error: #{response.body}" if response.body['statusCode'] == 'ERROR'
498
-
499
- return Spaceship::ConnectAPI::Response.new(body: response.body, status: response.status)
500
- end
501
-
502
- def handle_errors(response)
503
- # Example error format
504
- # {
505
- # "errors" : [ {
506
- # "id" : "ce8c391e-f858-411b-a14b-5aa26e0915f2",
507
- # "status" : "400",
508
- # "code" : "PARAMETER_ERROR.INVALID",
509
- # "title" : "A parameter has an invalid value",
510
- # "detail" : "'uploadedDate3' is not a valid field name",
511
- # "source" : {
512
- # "parameter" : "sort"
513
- # }
514
- # } ]
515
- # }
516
-
517
- return response.body['errors'].map do |error|
518
- "#{error['title']} - #{error['detail']}"
519
- end.join(" ")
520
- end
521
-
522
- private
523
-
524
- # used to assert all of the named parameters are supplied values
525
- #
526
- # @raises NameError if the values are nil
527
- def assert_required_params(method_name, binding)
528
- parameter_names = method(method_name).parameters.map { |_, v| v }
529
- parameter_names.each do |name|
530
- if local_variable_get(binding, name).nil?
531
- raise NameError, "`#{name}' is a required parameter"
532
- end
533
- end
534
- end
535
-
536
- def local_variable_get(binding, name)
537
- if binding.respond_to?(:local_variable_get)
538
- binding.local_variable_get(name)
539
- else
540
- binding.eval(name.to_s)
541
- end
542
- end
543
-
544
- def provider_id
545
- return team_id if self.provider.nil?
546
- self.provider.provider_id
547
- end
548
- end
549
- end
550
- # rubocop:enable Metrics/ClassLength
551
- end