fastlane 2.150.0.rc1 → 2.150.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,71 @@
1
+ require_relative '../model'
2
+ require_relative './app_preview'
3
+
4
+ module Spaceship
5
+ class ConnectAPI
6
+ class AppPreviewSet
7
+ include Spaceship::ConnectAPI::Model
8
+
9
+ attr_accessor :preview_type
10
+
11
+ attr_accessor :app_previews
12
+
13
+ module PreviewType
14
+ IPHONE_35 = "IPHONE_35"
15
+ IPHONE_40 = "IPHONE_40"
16
+ IPHONE_47 = "IPHONE_47"
17
+ IPHONE_55 = "IPHONE_55"
18
+ IPHONE_58 = "IPHONE_58"
19
+ IPHONE_65 = "IPHONE_65"
20
+
21
+ IPAD_97 = "IPAD_97"
22
+ IPAD_105 = "IPAD_105"
23
+ IPAD_PRO_3GEN_11 = "IPAD_PRO_3GEN_11"
24
+ IPAD_PRO_129 = "IPAD_PRO_129"
25
+ IPAD_PRO_3GEN_129 = "IPAD_PRO_3GEN_129"
26
+
27
+ DESKTOP = "DESKTOP"
28
+
29
+ ALL = [
30
+ IPHONE_35,
31
+ IPHONE_40,
32
+ IPHONE_47,
33
+ IPHONE_55,
34
+ IPHONE_58,
35
+ IPHONE_65,
36
+
37
+ IPAD_97,
38
+ IPAD_105,
39
+ IPAD_PRO_3GEN_11,
40
+ IPAD_PRO_129,
41
+ IPAD_PRO_3GEN_129,
42
+
43
+ DESKTOP
44
+ ]
45
+ end
46
+
47
+ attr_mapping({
48
+ "previewType" => "preview_type",
49
+
50
+ "appPreviews" => "app_previews"
51
+ })
52
+
53
+ def self.type
54
+ return "appPreviewSets"
55
+ end
56
+
57
+ #
58
+ # API
59
+ #
60
+
61
+ def self.all(filter: {}, includes: nil, limit: nil, sort: nil)
62
+ resp = Spaceship::ConnectAPI.get_app_preview_sets(filter: filter, includes: includes, limit: limit, sort: sort)
63
+ return resp.to_models
64
+ end
65
+
66
+ def upload_preview(path: nil)
67
+ return Spaceship::ConnectAPI::AppPreview.create(app_preview_set_id: id, path: path)
68
+ end
69
+ end
70
+ end
71
+ end
@@ -1,4 +1,6 @@
1
1
  require_relative '../model'
2
+ require_relative '../file_uploader'
3
+
2
4
  module Spaceship
3
5
  class ConnectAPI
4
6
  class AppScreenshot
@@ -76,30 +78,8 @@ module Spaceship
76
78
 
77
79
  post_resp = Spaceship::ConnectAPI.post_app_screenshot(app_screenshot_set_id: app_screenshot_set_id, attributes: post_attributes).to_models.first
78
80
 
79
- # {
80
- # "method": "PUT",
81
- # "url": "https://some-url-apple-gives-us",
82
- # "length": 57365,
83
- # "offset": 0,
84
- # "requestHeaders": [
85
- # {
86
- # "name": "Content-Type",
87
- # "value": "image/png"
88
- # }
89
- # ]
90
- # }
91
81
  upload_operation = post_resp.upload_operations.first
92
-
93
- headers = {}
94
- upload_operation["requestHeaders"].each do |hash|
95
- headers[hash["name"]] = hash["value"]
96
- end
97
-
98
- Faraday.put(
99
- upload_operation["url"],
100
- payload,
101
- headers
102
- )
82
+ Spaceship::ConnectAPI::FileUploader.upload(upload_operation, payload)
103
83
 
104
84
  patch_attributes = {
105
85
  uploaded: true,
@@ -1,4 +1,5 @@
1
1
  require_relative '../model'
2
+ require_relative './app_preview_set'
2
3
  require_relative './app_screenshot_set'
3
4
 
4
5
  module Spaceship
@@ -51,6 +52,21 @@ module Spaceship
51
52
  Spaceship::ConnectAPI.delete_app_store_version_localization(app_store_version_localization_id: id)
52
53
  end
53
54
 
55
+ #
56
+ # App Preview Sets
57
+ #
58
+
59
+ def get_app_preview_sets(filter: {}, includes: "appPreviews", limit: nil, sort: nil)
60
+ filter ||= {}
61
+ filter["appStoreVersionLocalization"] = id
62
+ return Spaceship::ConnectAPI::AppPreviewSet.all(filter: filter, includes: includes, limit: limit, sort: sort)
63
+ end
64
+
65
+ def create_app_preview_set(attributes: nil)
66
+ resp = Spaceship::ConnectAPI.post_app_preview_set(app_store_version_localization_id: id, attributes: attributes)
67
+ return resp.to_models.first
68
+ end
69
+
54
70
  #
55
71
  # App Screenshot Sets
56
72
  #
@@ -0,0 +1,27 @@
1
+ require_relative '../model'
2
+ module Spaceship
3
+ class ConnectAPI
4
+ class Territory
5
+ include Spaceship::ConnectAPI::Model
6
+
7
+ attr_accessor :currency
8
+
9
+ attr_mapping({
10
+ "currency" => "currency"
11
+ })
12
+
13
+ def self.type
14
+ return "territories"
15
+ end
16
+
17
+ #
18
+ # API
19
+ #
20
+
21
+ def self.all(filter: {}, includes: nil, limit: 180, sort: nil)
22
+ resps = Spaceship::ConnectAPI.get_territories(filter: {}, includes: nil, limit: nil, sort: nil).all_pages
23
+ return resps.flat_map(&:to_models)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -28,7 +28,7 @@ module Spaceship
28
28
  # app
29
29
  #
30
30
 
31
- def post_app(name: nil, version_string: nil, sku: nil, primary_locale: nil, bundle_id: nil, platforms: nil)
31
+ def post_app(name: nil, version_string: nil, sku: nil, primary_locale: nil, bundle_id: nil, platforms: nil, territory_ids: nil, available_in_new_territories: true)
32
32
  included = []
33
33
  included << {
34
34
  type: "appInfos",
@@ -89,91 +89,168 @@ module Spaceship
89
89
  }
90
90
  end
91
91
 
92
+ relationships = {
93
+ appStoreVersions: {
94
+ data: app_store_verions_data
95
+ },
96
+ appInfos: {
97
+ data: [
98
+ {
99
+ type: "appInfos",
100
+ id: "${new-appInfo-id}"
101
+ }
102
+ ]
103
+ }
104
+ }
105
+
92
106
  body = {
93
107
  data: {
94
108
  type: "apps",
95
109
  attributes: {
96
110
  sku: sku,
97
111
  primaryLocale: primary_locale,
98
- bundleId: bundle_id
112
+ bundleId: bundle_id,
113
+ availableInNewTerritories: !!available_in_new_territories
114
+ },
115
+ relationships: relationships
116
+ },
117
+ included: included
118
+ }
119
+
120
+ Client.instance.post("apps", body)
121
+ end
122
+
123
+ def patch_app(app_id: nil, attributes: {}, app_price_tier_id: nil, territory_ids: nil)
124
+ relationships = {}
125
+ included = []
126
+
127
+ # Price tier
128
+ unless app_price_tier_id.nil?
129
+ relationships[:prices] = {
130
+ data: [
131
+ {
132
+ type: "appPrices",
133
+ id: "${price1}"
134
+ }
135
+ ]
136
+ }
137
+
138
+ included << {
139
+ type: "appPrices",
140
+ id: "${price1}",
141
+ attributes: {
142
+ startDate: nil
99
143
  },
100
144
  relationships: {
101
- appStoreVersions: {
102
- data: app_store_verions_data
145
+ app: {
146
+ data: {
147
+ type: "apps",
148
+ id: app_id
149
+ }
103
150
  },
104
- appInfos: {
105
- data: [
106
- {
107
- type: "appInfos",
108
- id: "${new-appInfo-id}"
109
- }
110
- ]
151
+ priceTier: {
152
+ data: {
153
+ type: "appPriceTiers",
154
+ id: app_price_tier_id.to_s
155
+ }
111
156
  }
112
157
  }
113
- },
114
- included: included
158
+ }
159
+ end
160
+
161
+ # Territories
162
+ territories_data = (territory_ids || []).map do |id|
163
+ { type: "territories", id: id }
164
+ end
165
+ unless territories_data.empty?
166
+ relationships[:availableTerritories] = {
167
+ data: territories_data
168
+ }
169
+ end
170
+
171
+ # Data
172
+ data = {
173
+ type: "apps",
174
+ id: app_id
115
175
  }
176
+ data[:attributes] = attributes unless attributes.empty?
177
+ data[:relationships] = relationships unless relationships.empty?
116
178
 
117
- Client.instance.post("apps", body)
179
+ # Body
180
+ body = {
181
+ data: data
182
+ }
183
+ body[:included] = included unless included.empty?
184
+
185
+ Client.instance.patch("apps/#{app_id}", body)
118
186
  end
119
187
 
120
- def patch_app(app_id: nil, attributes: {})
188
+ #
189
+ # appPreview
190
+ #
191
+
192
+ def post_app_preview(app_preview_set_id: nil, attributes: {})
121
193
  body = {
122
194
  data: {
123
- type: "apps",
124
- id: app_id,
195
+ type: "appPreviews",
196
+ attributes: attributes,
197
+ relationships: {
198
+ appPreviewSet: {
199
+ data: {
200
+ type: "appPreviewSets",
201
+ id: app_preview_set_id
202
+ }
203
+ }
204
+ }
205
+ }
206
+ }
207
+
208
+ Client.instance.post("appPreviews", body)
209
+ end
210
+
211
+ def patch_app_preview(app_preview_id: nil, attributes: {})
212
+ body = {
213
+ data: {
214
+ type: "appPreviews",
215
+ id: app_preview_id,
125
216
  attributes: attributes
126
217
  }
127
218
  }
128
219
 
129
- Client.instance.patch("apps/#{app_id}", body)
220
+ Client.instance.patch("appPreviews/#{app_preview_id}", body)
130
221
  end
131
222
 
132
- def patch_app_app_prices(app_id: nil, app_price_tier_id: nil)
223
+ def delete_app_preview(app_preview_id: nil)
224
+ params = Client.instance.build_params(filter: nil, includes: nil, limit: nil, sort: nil)
225
+ Client.instance.delete("appPreviews/#{app_preview_id}", params)
226
+ end
227
+
228
+ #
229
+ # appPreviewSets
230
+ #
231
+
232
+ def get_app_preview_sets(filter: {}, includes: nil, limit: nil, sort: nil)
233
+ params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)
234
+ Client.instance.get("appPreviewSets", params)
235
+ end
236
+
237
+ def post_app_preview_set(app_store_version_localization_id: nil, attributes: {})
133
238
  body = {
134
239
  data: {
135
- type: "apps",
136
- id: app_id,
137
- attributes: {
138
- availableInNewTerritories: true
139
- },
240
+ type: "appPreviewSets",
241
+ attributes: attributes,
140
242
  relationships: {
141
- prices: {
142
- data: [
143
- {
144
- type: "appPrices",
145
- id: "${price1}"
146
- }
147
- ]
148
- }
149
- }
150
- },
151
- included: [
152
- {
153
- type: "appPrices",
154
- id: "${price1}",
155
- attributes: {
156
- startDate: nil
157
- },
158
- relationships: {
159
- app: {
160
- data: {
161
- type: "apps",
162
- id: app_id
163
- }
164
- },
165
- priceTier: {
166
- data: {
167
- type: "appPriceTiers",
168
- id: app_price_tier_id.to_s
169
- }
243
+ appStoreVersionLocalization: {
244
+ data: {
245
+ type: "appStoreVersionLocalizations",
246
+ id: app_store_version_localization_id
170
247
  }
171
248
  }
172
249
  }
173
- ]
250
+ }
174
251
  }
175
252
 
176
- Client.instance.patch("apps/#{app_id}", body)
253
+ Client.instance.post("appPreviewSets", body)
177
254
  end
178
255
 
179
256
  #
@@ -323,27 +400,70 @@ module Spaceship
323
400
  Client.instance.patch("appInfos/#{app_info_id}", body)
324
401
  end
325
402
 
326
- def patch_app_info_categories(app_info_id: nil, primary_category_id: nil, secondary_category_id: nil, primary_subcategory_one_id: nil, primary_subcategory_two_id: nil, secondary_subcategory_one_id: nil, secondary_subcategory_two_id: nil)
327
- relationships = {
328
- primaryCategory: {
403
+ #
404
+ # Adding the key will create/update (if value) or delete if nil
405
+ # Not including a key will leave as is
406
+ # category_id_map: {
407
+ # primary_category_id: "GAMES",
408
+ # primary_subcategory_one_id: "PUZZLE",
409
+ # primary_subcategory_two_id: "STRATEGY",
410
+ # secondary_category_id: nil,
411
+ # secondary_subcategory_one_id: nil,
412
+ # secondary_subcategory_two_id: nil
413
+ # }
414
+ #
415
+ def patch_app_info_categories(app_info_id: nil, category_id_map: nil)
416
+ category_id_map ||= {}
417
+ primary_category_id = category_id_map[:primary_category_id]
418
+ primary_subcategory_one_id = category_id_map[:primary_subcategory_one_id]
419
+ primary_subcategory_two_id = category_id_map[:primary_subcategory_two_id]
420
+ secondary_category_id = category_id_map[:secondary_category_id]
421
+ secondary_subcategory_one_id = category_id_map[:secondary_subcategory_one_id]
422
+ secondary_subcategory_two_id = category_id_map[:secondary_subcategory_two_id]
423
+
424
+ relationships = {}
425
+
426
+ # Only update if key is included (otherwise category will be removed)
427
+ if category_id_map.include?(:primary_category_id)
428
+ relationships[:primaryCategory] = {
329
429
  data: primary_category_id ? { type: "appCategories", id: primary_category_id } : nil
330
- },
331
- secondaryCategory: {
332
- data: secondary_category_id ? { type: "appCategories", id: secondary_category_id } : nil
333
- },
334
- primarySubcategoryOne: {
430
+ }
431
+ end
432
+
433
+ # Only update if key is included (otherwise category will be removed)
434
+ if category_id_map.include?(:primary_subcategory_one_id)
435
+ relationships[:primarySubcategoryOne] = {
335
436
  data: primary_subcategory_one_id ? { type: "appCategories", id: primary_subcategory_one_id } : nil
336
- },
337
- primarySubcategoryTwo: {
437
+ }
438
+ end
439
+
440
+ # Only update if key is included (otherwise category will be removed)
441
+ if category_id_map.include?(:primary_subcategory_two_id)
442
+ relationships[:primarySubcategoryTwo] = {
338
443
  data: primary_subcategory_two_id ? { type: "appCategories", id: primary_subcategory_two_id } : nil
339
- },
340
- secondarySubcategoryOne: {
444
+ }
445
+ end
446
+
447
+ # Only update if key is included (otherwise category will be removed)
448
+ if category_id_map.include?(:secondary_category_id)
449
+ relationships[:secondaryCategory] = {
450
+ data: secondary_category_id ? { type: "appCategories", id: secondary_category_id } : nil
451
+ }
452
+ end
453
+
454
+ # Only update if key is included (otherwise category will be removed)
455
+ if category_id_map.include?(:secondary_subcategory_one_id)
456
+ relationships[:secondarySubcategoryOne] = {
341
457
  data: secondary_subcategory_one_id ? { type: "appCategories", id: secondary_subcategory_one_id } : nil
342
- },
343
- secondarySubcategoryTwo: {
458
+ }
459
+ end
460
+
461
+ # Only update if key is included (otherwise category will be removed)
462
+ if category_id_map.include?(:secondary_subcategory_two_id)
463
+ relationships[:secondarySubcategoryTwo] = {
344
464
  data: secondary_subcategory_two_id ? { type: "appCategories", id: secondary_subcategory_two_id } : nil
345
465
  }
346
- }
466
+ end
347
467
 
348
468
  data = {
349
469
  type: "appInfos",
@@ -698,6 +818,15 @@ module Spaceship
698
818
  params = Client.instance.build_params(filter: nil, includes: nil, limit: nil, sort: nil)
699
819
  Client.instance.delete("idfaDeclarations/#{idfa_declaration_id}", params)
700
820
  end
821
+
822
+ #
823
+ # territories
824
+ #
825
+
826
+ def get_territories(filter: {}, includes: nil, limit: nil, sort: nil)
827
+ params = Client.instance.build_params(filter: nil, includes: nil, limit: nil, sort: nil)
828
+ Client.instance.get("territories", params)
829
+ end
701
830
  end
702
831
  end
703
832
  end