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"

Instance Attribute Summary collapse

Attributes included from Model

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#attr_mapping, included, #initialize, #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_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.



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

def build_beta_detail
  @build_beta_detail
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

#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.



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

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(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



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 109

def self.all(app_id: nil, version: nil, build_number: nil, platform: nil, processing_states: "PROCESSING,FAILED,INVALID,VALID", includes: ESSENTIAL_INCLUDES, sort: "-uploadedDate", limit: 30)
  resps = Spaceship::ConnectAPI.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(build_id: nil, includes: ESSENTIAL_INCLUDES) ⇒ Object



128
129
130
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 128

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

.typeObject



49
50
51
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 49

def self.type
  return "builds"
end

Instance Method Details

#add_beta_groups(beta_groups: nil) ⇒ Object



136
137
138
139
140
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 136

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

#app_idObject



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

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

#app_versionObject

Helpers



57
58
59
60
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 57

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

#bundle_idObject



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

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

#expire!Object



166
167
168
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 166

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

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



142
143
144
145
146
147
148
149
150
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 142

def get_beta_build_localizations(filter: {}, includes: nil, limit: nil, sort: nil)
  resps = Spaceship::ConnectAPI.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(filter: {}, includes: nil, limit: nil, sort: nil) ⇒ Object



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

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

#platformObject



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

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

#post_beta_app_review_submissionObject



162
163
164
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 162

def post_beta_app_review_submission
  return Spaceship::ConnectAPI.post_beta_app_review_submissions(build_id: id)
end

#processed?Boolean

Returns:

  • (Boolean)


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

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

#ready_for_beta_submission?Boolean

Returns:

  • (Boolean)


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

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_internal_testing?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 81

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



91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 91

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(attributes: nil) ⇒ Object



132
133
134
# File 'spaceship/lib/spaceship/connect_api/models/build.rb', line 132

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