Class: Spaceship::ConnectAPI::Build

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
spaceship/lib/spaceship/connect_api/models/build.rb

Defined Under Namespace

Modules: ProcessingState

Constant Summary collapse

ESSENTIAL_INCLUDES =
"app,buildBetaDetail,preReleaseVersion,buildBundles"

Instance Attribute Summary collapse

Attributes included from Model

#id, #reverse_attr_map

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#attr_mapping, included, #initialize, #reverse_attr_mapping, #to_json, #update_attributes

Instance Attribute Details

#appObject

Returns the value of attribute app.



17
18
19
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 17

def app
  @app
end

#beta_app_review_submissionObject

Returns the value of attribute beta_app_review_submission.



18
19
20
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 18

def beta_app_review_submission
  @beta_app_review_submission
end

#beta_build_localizationsObject

Returns the value of attribute beta_build_localizations.



20
21
22
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 20

def beta_build_localizations
  @beta_build_localizations
end

#beta_build_metricsObject

Returns the value of attribute beta_build_metrics.



19
20
21
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 19

def beta_build_metrics
  @beta_build_metrics
end

#build_beta_detailObject

Returns the value of attribute build_beta_detail.



21
22
23
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 21

def build_beta_detail
  @build_beta_detail
end

#build_bundlesObject

Returns the value of attribute build_bundles.



22
23
24
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 22

def build_bundles
  @build_bundles
end

#expiration_dateObject

Returns the value of attribute expiration_date.



10
11
12
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 10

def expiration_date
  @expiration_date
end

#expiredObject

Returns the value of attribute expired.



11
12
13
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 11

def expired
  @expired
end

#icon_asset_tokenObject

Returns the value of attribute icon_asset_token.



13
14
15
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 13

def icon_asset_token
  @icon_asset_token
end

#individual_testersObject

Returns the value of attribute individual_testers.



24
25
26
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 24

def individual_testers
  @individual_testers
end

#min_os_versionObject

Returns the value of attribute min_os_version.



12
13
14
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 12

def min_os_version
  @min_os_version
end

#pre_release_versionObject

Returns the value of attribute pre_release_version.



23
24
25
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 23

def pre_release_version
  @pre_release_version
end

#processing_stateObject

Returns the value of attribute processing_state.



14
15
16
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 14

def processing_state
  @processing_state
end

#uploaded_dateObject

Returns the value of attribute uploaded_date.



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

def uploaded_date
  @uploaded_date
end

#uses_non_exempt_encryptionObject

Returns the value of attribute uses_non_exempt_encryption.



15
16
17
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 15

def uses_non_exempt_encryption
  @uses_non_exempt_encryption
end

#versionObject

Returns the value of attribute version.



8
9
10
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 8

def version
  @version
end

Class Method Details

.all(client: nil, app_id: nil, version: nil, build_number: nil, platform: nil, processing_states: "PROCESSING,FAILED,INVALID,VALID", includes: ESSENTIAL_INCLUDES, sort: "-uploadedDate", limit: 30) ⇒ Object

API



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 124

def self.all(client: nil, app_id: nil, version: nil, build_number: nil, platform: nil, processing_states: "PROCESSING,FAILED,INVALID,VALID", includes: ESSENTIAL_INCLUDES, sort: "-uploadedDate", limit: 30)
  client ||= Spaceship::ConnectAPI
  resps = client.get_builds(
    filter: { app: app_id, "preReleaseVersion.version" => version, version: build_number, processingState: processing_states },
    includes: includes,
    sort: sort,
    limit: limit
  ).all_pages
  models = resps.flat_map(&:to_models)

  # Filtering after models are fetched since there is no way to do this in a query param filter
  if platform
    models = models.select do |build|
      build.pre_release_version && build.pre_release_version.platform == platform
    end
  end

  return models
end

.get(client: nil, build_id: nil, includes: ESSENTIAL_INCLUDES) ⇒ Object



144
145
146
147
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 144

def self.get(client: nil, build_id: nil, includes: ESSENTIAL_INCLUDES)
  client ||= Spaceship::ConnectAPI
  return client.get_build(build_id: build_id, includes: includes).first
end

.typeObject



55
56
57
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 55

def self.type
  return "builds"
end

Instance Method Details

#add_beta_groups(client: nil, beta_groups: nil) ⇒ Object



155
156
157
158
159
160
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 155

def add_beta_groups(client: nil, beta_groups: nil)
  client ||= Spaceship::ConnectAPI
  beta_groups ||= []
  beta_group_ids = beta_groups.map(&:id)
  return client.add_beta_groups_to_build(build_id: id, beta_group_ids: beta_group_ids)
end

#app_idObject



68
69
70
71
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 68

def app_id
  raise "No app included" unless app
  return app.id
end

#app_versionObject

Helpers



63
64
65
66
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 63

def app_version
  raise "No pre_release_version included" unless pre_release_version
  return pre_release_version.version
end

#bundle_idObject



73
74
75
76
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 73

def bundle_id
  raise "No app included" unless app
  return app.bundle_id
end

#expire!(client: nil) ⇒ Object



189
190
191
192
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 189

def expire!(client: nil)
  client ||= Spaceship::ConnectAPI
  return client.patch_builds(build_id: id, attributes: { expired: true })
end

#get_beta_build_localizations(client: nil, filter: {}, includes: nil, limit: nil, sort: nil) ⇒ Object



162
163
164
165
166
167
168
169
170
171
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 162

def get_beta_build_localizations(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
  client ||= Spaceship::ConnectAPI
  resps = client.get_beta_build_localizations(
    filter: { build: id },
    includes: includes,
    sort: sort,
    limit: limit
  ).all_pages
  return resps.flat_map(&:to_models)
end

#get_build_beta_details(client: nil, filter: {}, includes: nil, limit: nil, sort: nil) ⇒ Object



173
174
175
176
177
178
179
180
181
182
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 173

def get_build_beta_details(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
  client ||= Spaceship::ConnectAPI
  resps = client.get_build_beta_details(
    filter: { build: id },
    includes: includes,
    sort: sort,
    limit: limit
  ).all_pages
  return resps.flat_map(&:to_models)
end

#missing_export_compliance?Boolean

Returns:

  • (Boolean)


100
101
102
103
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 100

def missing_export_compliance?
  raise "No build_beta_detail included" unless build_beta_detail
  return build_beta_detail.missing_export_compliance?
end

#platformObject



78
79
80
81
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 78

def platform
  raise "No pre_release_version included" unless pre_release_version
  return pre_release_version.platform
end

#post_beta_app_review_submission(client: nil) ⇒ Object



184
185
186
187
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 184

def post_beta_app_review_submission(client: nil)
  client ||= Spaceship::ConnectAPI
  return client.post_beta_app_review_submissions(build_id: id)
end

#processed?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 83

def processed?
  return processing_state != ProcessingState::PROCESSING
end

#ready_for_beta_submission?Boolean

Returns:

  • (Boolean)


95
96
97
98
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 95

def ready_for_beta_submission?
  raise "No build_beta_detail included" unless build_beta_detail
  return build_beta_detail.ready_for_beta_submission?
end

#ready_for_external_testing?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 91

def ready_for_external_testing?
  return build_beta_detail.nil? == false && build_beta_detail.ready_for_external_testing?
end

#ready_for_internal_testing?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 87

def ready_for_internal_testing?
  return build_beta_detail.nil? == false && build_beta_detail.ready_for_internal_testing?
end

#to_testflight_buildObject

This is here temporarily until the removal of Spaceship::TestFlight



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 106

def to_testflight_build
  h = {
    'id' => id,
    'buildVersion' => version,
    'uploadDate' => uploaded_date,
    'externalState' => processed? ? Spaceship::TestFlight::Build::BUILD_STATES[:active] : Spaceship::TestFlight::Build::BUILD_STATES[:processing],
    'appAdamId' => app_id,
    'bundleId' => bundle_id,
    'trainVersion' => app_version
  }

  return Spaceship::TestFlight::Build.new(h)
end

#update(client: nil, attributes: nil) ⇒ Object



149
150
151
152
153
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 149

def update(client: nil, attributes: nil)
  client ||= Spaceship::ConnectAPI
  attributes = reverse_attr_mapping(attributes)
  return client.patch_builds(build_id: id, attributes: attributes).first
end