pindo 4.7.2 → 4.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,8 +8,8 @@ module Pindo
8
8
  module AppStoreInAppPurchase
9
9
 
10
10
  def get_price_tier_dict
11
-
12
- iap_tier_file = File.join(File.expand_path('./', __dir__), 'iap_tier.json')
11
+
12
+ iap_tier_file = File.join(File.expand_path('./', __dir__), 'iap_tier.json')
13
13
  iap_tier_json = JSON.parse(File.read(iap_tier_file))
14
14
 
15
15
  return iap_tier_json
@@ -41,14 +41,14 @@ module Pindo
41
41
  iap_item["localizations_id"] = temp_item[:id]
42
42
  end
43
43
  if !purchase_item[:relationships][:app_store_review_screenshot].nil? && !purchase_item[:relationships][:app_store_review_screenshot][:data].nil? && !purchase_item[:relationships][:app_store_review_screenshot][:data][:id].nil?
44
- iap_item["review_screenshot_id"] = purchase_item[:relationships][:app_store_review_screenshot][:data][:id]
44
+ iap_item["review_screenshot_id"] = purchase_item[:relationships][:app_store_review_screenshot][:data][:id]
45
45
  end
46
-
46
+
47
47
  if !iap_item["localizations_id"].nil? && !in_app_purchases_response.nil? && !in_app_purchases_response[:included].nil?
48
48
  localizations_item = in_app_purchases_response[:included].find { |item| item[:type].eql?("inAppPurchaseLocalizations") && item[:id].eql?(iap_item["localizations_id"])}
49
49
 
50
50
  iap_item["display_name"] = localizations_item[:attributes][:name]
51
- iap_item["description"] = localizations_item[:attributes][:description]
51
+ iap_item["description"] = localizations_item[:attributes][:description]
52
52
  end
53
53
 
54
54
  iap_item["review_screenshot"] = nil
@@ -57,14 +57,14 @@ module Pindo
57
57
  # if !iap_item["review_screenshot_id"].nil? && !in_app_purchases_response.nil? && !in_app_purchases_response[:included].nil?
58
58
  # iap_item = in_app_purchases_response[:included].find { |item| item[:type].eql?("inAppPurchaseAppStoreReviewScreenshots") && item[:id].eql?(iap_item["review_screenshot_id"])}
59
59
  # end
60
-
60
+
61
61
  iap_item["price"] = get_purchase_item_price(appstore_client:appstore_client, in_app_purchase_id:purchase_item[:id])
62
62
 
63
63
  iap_item.delete("localizations_id")
64
64
  iap_item.delete("review_screenshot_id")
65
65
  in_app_purchase_items << iap_item
66
66
  end
67
- end
67
+ end
68
68
 
69
69
  in_app_purchase_items.sort! { | itema, itemb | itema["product_id"] <=> itemb["product_id"]}
70
70
 
@@ -112,14 +112,14 @@ module Pindo
112
112
  app_sharedsecrets_item = post_result_data["data"]
113
113
  # puts JSON.pretty_generate(app_sharedsecrets_item)
114
114
  end
115
- end
115
+ end
116
116
  end
117
-
117
+
118
118
  if !app_sharedsecrets_item.nil?
119
119
  # puts JSON.pretty_generate(app_sharedsecrets_item)
120
120
  scecrets_id = app_sharedsecrets_item["attributes"]["secret"]
121
121
  end
122
-
122
+
123
123
  rescue => err
124
124
  puts err
125
125
  puts "获取App Shared Secret失败!"
@@ -144,7 +144,7 @@ module Pindo
144
144
  purchase_item["purchase_id"] = iap_item[:id]
145
145
  purchase_item["state"] = iap_item[:attributes][:state]
146
146
  end
147
- end
147
+ end
148
148
  end
149
149
  end
150
150
 
@@ -153,22 +153,23 @@ module Pindo
153
153
 
154
154
  puts "购买项:" + purchase_item["product_id"]
155
155
  if purchase_item["purchase_id"].nil?
156
- create_purchase_item(appstore_client:appstore_client, app_id:app_id, purchase_item:purchase_item)
156
+ create_purchase_item(appstore_client:appstore_client, app_id:app_id, purchase_item:purchase_item)
157
157
  end
158
-
158
+
159
159
  if !purchase_item["purchase_id"].nil?
160
160
  in_app_purchase_id = purchase_item["purchase_id"]
161
161
 
162
162
  if !purchase_item["state"].nil? && purchase_item["state"].to_s.eql?("APPROVED")
163
163
  puts " 购买项已经上线, 只能修改价格"
164
- create_purchase_item_price(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
164
+ create_purchase_item_price(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
165
165
  else
166
166
  sleep(1)
167
- update_purchase_item_name(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
168
- create_purchase_item_price(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
167
+ update_purchase_item_name(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
168
+ update_purchase_item_territory_availability(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
169
+ create_purchase_item_price(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
169
170
  upload_purchase_item_screenshots(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
170
- create_purchase_item_localization(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
171
- update_purchase_item_name(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
171
+ create_purchase_item_localization(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
172
+ update_purchase_item_name(appstore_client:appstore_client, in_app_purchase_id:in_app_purchase_id, purchase_item:purchase_item)
172
173
 
173
174
  end
174
175
  end
@@ -187,27 +188,26 @@ module Pindo
187
188
  name:purchase_item["reference_name"],
188
189
  product_id:purchase_item["product_id"],
189
190
  in_app_purchase_type:purchase_item["in_app_purchase_type"],
190
- available_in_all_territories:true,
191
191
  review_note:purchase_item["review_note"],
192
192
  relationships: {
193
193
  app:{
194
194
  data:{
195
- id: appstore_app_id,
195
+ id: appstore_app_id,
196
196
  type: 'apps'
197
197
  }
198
198
  }
199
199
  }
200
200
  )
201
-
201
+
202
202
  if !response.nil? && !response[:data].nil? && !response[:data][:id].nil?
203
203
 
204
204
  purchase_id = !response[:data][:id]
205
205
  purchase_item["purchase_id"] = response[:data][:id]
206
206
  return purchase_id
207
- else !response.nil? && !response[:errors].nil?
207
+ else !response.nil? && !response[:errors].nil?
208
208
  # puts JSON.pretty_generate(response)
209
209
  response[:errors].each do |error_item|
210
- if error_item[:status].to_s.eql?("409") && error_item[:code].to_s.eql?("ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE") && error_item[:source][:pointer].to_s.eql?("/data/attributes/name")
210
+ if error_item[:status].to_s.eql?("409") && error_item[:code].to_s.eql?("ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE") && error_item[:source][:pointer].to_s.eql?("/data/attributes/name")
211
211
  err_msg = " !!!!!" + purchase_item["product_id"] + " 购买项创建失败!!!, Reference Name重复!!!"
212
212
  raise Informative, err_msg
213
213
  end
@@ -223,12 +223,11 @@ module Pindo
223
223
  end
224
224
 
225
225
  def update_purchase_item_name(appstore_client:nil, in_app_purchase_id:nil, purchase_item:nil)
226
-
226
+
227
227
  puts " 更新Reference Name"
228
228
  begin
229
229
  response = appstore_client.update_in_app_purchase(
230
230
  name:purchase_item["reference_name"],
231
- available_in_all_territories:true,
232
231
  review_note:purchase_item["review_note"],
233
232
  id:in_app_purchase_id
234
233
  )
@@ -238,10 +237,46 @@ module Pindo
238
237
  end
239
238
  end
240
239
 
240
+ def update_purchase_item_territory_availability(appstore_client:nil, in_app_purchase_id:nil, purchase_item:nil)
241
+
242
+ puts " 设置Territory Availability"
243
+ response = appstore_client.list_all_availability(
244
+ limit:200
245
+ )
246
+ # puts JSON.pretty_generate(response)
247
+
248
+ availableTerritories_data = []
249
+ if !response.nil? && !response[:data].nil?
250
+ response[:data].each do |territory_item|
251
+ new_territory_item = {}
252
+ new_territory_item["id"] = territory_item[:id]
253
+ new_territory_item["type"] = territory_item[:type]
254
+ availableTerritories_data << new_territory_item
255
+ end
256
+ end
257
+
258
+ response = appstore_client.modify_in_app_purchase_territory_availablity(
259
+ available_in_new_territories:true,
260
+ relationships: {
261
+ inAppPurchase:{
262
+ data:{
263
+ id: in_app_purchase_id,
264
+ type: 'inAppPurchases'
265
+ }
266
+ },
267
+ availableTerritories:{
268
+ data:availableTerritories_data
269
+ }
270
+ }
271
+ )
272
+
273
+ # puts JSON.pretty_generate(response)
274
+
275
+ end
241
276
 
242
- def create_purchase_item_localization(appstore_client:nil, in_app_purchase_id:nil, purchase_item:nil)
277
+ def create_purchase_item_localization(appstore_client:nil, in_app_purchase_id:nil, purchase_item:nil)
243
278
 
244
- puts " 更新Display Name"
279
+ puts " 更新Display Name"
245
280
  begin
246
281
 
247
282
  response = appstore_client.list_in_app_purchase_all_localizations(
@@ -262,7 +297,7 @@ module Pindo
262
297
  purchase_item["localization"][locale]["display_name"] = purchase_item["localization"][locale]["display_name"] || display_name
263
298
  purchase_item["localization"][locale]["description"] = purchase_item["localization"][locale]["description"] || description
264
299
  end
265
-
300
+
266
301
  end
267
302
 
268
303
 
@@ -295,7 +330,7 @@ module Pindo
295
330
  )
296
331
 
297
332
  # puts JSON.pretty_generate(response)
298
-
333
+
299
334
  end
300
335
 
301
336
  end
@@ -343,16 +378,13 @@ module Pindo
343
378
  include: 'territory',
344
379
  filter: {
345
380
  territory: 'USA',
346
- price_tier: purchase_item["price_tier"]
347
381
  },
348
- limit:100
382
+ limit:800
349
383
  )
350
384
  # puts JSON.pretty_generate(respose_price)
351
385
 
352
-
353
386
  price_id = nil
354
387
 
355
-
356
388
  respose_price[:data].each do |price_item|
357
389
  if price_item[:attributes][:customer_price].to_s.eql?(purchase_item["price"].to_s)
358
390
  price_id = price_item[:id]
@@ -360,8 +392,9 @@ module Pindo
360
392
  puts " 更新价格 :" + purchase_item["price"] +"$"
361
393
  end
362
394
  end
395
+
363
396
  if !price_id.nil?
364
- in_app_purchase = appstore_client.create_in_app_purchase_price_schedule(
397
+ purchase_response = appstore_client.create_in_app_purchase_price_schedule(
365
398
  relationships: {
366
399
  manual_prices: {
367
400
  data: [
@@ -376,34 +409,34 @@ module Pindo
376
409
  type: 'inAppPurchases',
377
410
  id: in_app_purchase_id
378
411
  }
412
+ },
413
+ baseTerritory: {
414
+ data: {
415
+ type: 'territories',
416
+ id: 'USA'
417
+ }
379
418
  }
380
- },
419
+ },
381
420
  included: [
382
421
  {
383
- type: 'inAppPurchasePrices',
384
- id: '${price1}',
385
- attributes: {
386
- startDate: nil
387
- },
388
- relationships: {
389
- inAppPurchaseV2: {
390
- data: {
391
- type: 'inAppPurchases',
392
- id: in_app_purchase_id
393
- }
422
+ type: 'inAppPurchasePrices',
423
+ id: '${price1}',
424
+ attributes: {
425
+ startDate: nil
394
426
  },
395
- inAppPurchasePricePoint: {
396
- data: {
397
- type: 'inAppPurchasePricePoints',
398
- id: price_id
399
- }
427
+ relationships: {
428
+ inAppPurchasePricePoint: {
429
+ data: {
430
+ type: 'inAppPurchasePricePoints',
431
+ id: price_id
432
+ }
433
+ }
400
434
  }
401
435
  }
402
- }
403
- ]
404
- )
436
+ ])
437
+ # puts JSON.pretty_generate(purchase_response)
405
438
  end
406
-
439
+
407
440
  rescue => err
408
441
  puts "创建价格失败: " + purchase_item["product_id"]
409
442
  puts err
@@ -427,16 +460,16 @@ module Pindo
427
460
  need_upload_screenshot = true
428
461
 
429
462
  if !response_iap_screenshot[:data].nil? && !response_iap_screenshot[:data][:attributes].nil? && !response_iap_screenshot[:data][:attributes][:asset_delivery_state].nil? && !response_iap_screenshot[:data][:attributes][:asset_delivery_state][:state].nil?
430
-
463
+
431
464
  if response_iap_screenshot[:data][:attributes][:asset_delivery_state][:state].to_s.eql?("COMPLETE")
432
-
465
+
433
466
  if !response_iap_screenshot[:data].nil? && !response_iap_screenshot[:data][:attributes].nil? && !response_iap_screenshot[:data][:attributes][:source_file_checksum].nil?
434
467
 
435
468
  if checksum.to_s.eql?(response_iap_screenshot[:data][:attributes][:source_file_checksum].to_s)
436
469
 
437
470
  puts " 有截屏,截屏未修改,无需重新上传"
438
471
  need_upload_screenshot = false
439
-
472
+
440
473
  end
441
474
  end
442
475
  end
@@ -460,13 +493,13 @@ module Pindo
460
493
  relationships: {
461
494
  inAppPurchaseV2:{
462
495
  data:{
463
- id: in_app_purchase_id,
496
+ id: in_app_purchase_id,
464
497
  type: 'inAppPurchases'
465
498
  }
466
499
  }
467
500
  }
468
501
  )
469
-
502
+
470
503
  # puts JSON.pretty_generate(response_iap_screenshot)
471
504
  upload_id = response_iap_screenshot[:data][:id]
472
505
  upload_operations = response_iap_screenshot[:data][:attributes][:upload_operations]
@@ -481,7 +514,7 @@ module Pindo
481
514
  res = conn.put(upload_operation[:url], bytes[offset, length], headers)
482
515
  end
483
516
 
484
-
517
+
485
518
 
486
519
  in_app_purchase = appstore_client.update_in_app_purchase_app_store_review_screenshot(
487
520
  id:upload_id,
@@ -495,7 +528,7 @@ module Pindo
495
528
  puts " 存在图片,无需上传...."
496
529
  end
497
530
 
498
-
531
+
499
532
 
500
533
  rescue => err
501
534
  puts err
@@ -556,38 +589,38 @@ module Pindo
556
589
 
557
590
  puts
558
591
  puts "**已存在订阅组的数目** : #{subscription_groups_response[:data].size}"
559
- puts
592
+ puts
560
593
 
561
594
  subscription_groups_response[:data].each do |old_subscription_group_item|
562
595
  subscription_group_items.each do |new_subscription_group_item|
563
596
  if !old_subscription_group_item[:attributes].nil? && old_subscription_group_item[:attributes][:reference_name].to_s.eql?(new_subscription_group_item["group_reference_name"])
564
597
  new_subscription_group_item["group_id"] = old_subscription_group_item[:id]
565
598
  end
566
- end
599
+ end
567
600
  end
568
601
  end
569
602
 
570
603
  subscription_group_items.each do |new_subscription_group_item|
571
604
 
572
605
  if new_subscription_group_item["group_id"].nil?
573
- if subscription_groups_response[:data].size > 0
606
+ if subscription_groups_response[:data].size > 0
574
607
  puts
575
608
  answer = agree("请确认要创建新的Subscription Group(Y/n):")
576
609
  unless answer
577
610
  raise Informative, "修改iap.json文件 !!! group_reference_name不一致会创建新的Subscription Group !!!"
578
- end
611
+ end
579
612
  end
580
- create_subscription_group_item(appstore_client:appstore_client, app_id:app_id, subscription_group_item:new_subscription_group_item)
613
+ create_subscription_group_item(appstore_client:appstore_client, app_id:app_id, subscription_group_item:new_subscription_group_item)
581
614
  end
582
-
615
+
583
616
  if !new_subscription_group_item["group_id"].nil?
584
617
 
585
618
  subscription_group_id = new_subscription_group_item["group_id"]
586
619
 
587
- create_subscription_group_localization(appstore_client:appstore_client, subscription_group_id:new_subscription_group_item["group_id"], subscription_group_item:new_subscription_group_item)
620
+ create_subscription_group_localization(appstore_client:appstore_client, subscription_group_id:new_subscription_group_item["group_id"], subscription_group_item:new_subscription_group_item)
588
621
  sleep(1)
589
622
  subscription_items = new_subscription_group_item["subscription_items"]
590
- create_subscription_items(appstore_client:appstore_client, subscription_group_id:subscription_group_id, subscription_items:subscription_items)
623
+ create_subscription_items(appstore_client:appstore_client, subscription_group_id:subscription_group_id, subscription_items:subscription_items)
591
624
 
592
625
  end
593
626
  end
@@ -595,7 +628,7 @@ module Pindo
595
628
 
596
629
  end
597
630
 
598
- def create_subscription_group_item(appstore_client:nil, app_id:nil, subscription_group_item:nil)
631
+ def create_subscription_group_item(appstore_client:nil, app_id:nil, subscription_group_item:nil)
599
632
 
600
633
  begin
601
634
  group_response = appstore_client.create_subscription_group(
@@ -603,7 +636,7 @@ module Pindo
603
636
  relationships: {
604
637
  app:{
605
638
  data:{
606
- id: app_id,
639
+ id: app_id,
607
640
  type: 'apps'
608
641
  }
609
642
  }
@@ -615,10 +648,10 @@ module Pindo
615
648
 
616
649
  end
617
650
 
618
- def create_subscription_group_localization(appstore_client:nil, subscription_group_id:nil, subscription_group_item:nil)
651
+ def create_subscription_group_localization(appstore_client:nil, subscription_group_id:nil, subscription_group_item:nil)
619
652
  begin
620
653
 
621
-
654
+
622
655
  response = appstore_client.list_all_subscription_group_localizations(
623
656
  id:subscription_group_id,
624
657
  limit:200
@@ -638,7 +671,7 @@ module Pindo
638
671
  subscription_group_item["localization"][locale]["group_display_name"] = subscription_group_item["localization"][locale]["group_display_name"] || group_display_name
639
672
  subscription_group_item["localization"][locale]["custom_app_name"] = subscription_group_item["localization"][locale]["custom_app_name"] || custom_app_name
640
673
  end
641
-
674
+
642
675
  end
643
676
 
644
677
 
@@ -671,10 +704,10 @@ module Pindo
671
704
  }
672
705
  )
673
706
  # puts JSON.pretty_generate(response)
674
-
707
+
675
708
  end
676
709
 
677
-
710
+
678
711
 
679
712
  end
680
713
 
@@ -687,11 +720,11 @@ module Pindo
687
720
 
688
721
  end
689
722
 
690
-
691
- def get_subscription_items(appstore_client:nil, subscription_group_id:nil)
723
+
724
+ def get_subscription_items(appstore_client:nil, subscription_group_id:nil)
692
725
  subscription_items = []
693
726
 
694
- tier_json = get_price_tier_dict
727
+ tier_json = get_price_tier_dict
695
728
  items_dict = tier_json["subscription_duration"]
696
729
  subscription_period_dict = items_dict.invert
697
730
 
@@ -728,7 +761,7 @@ module Pindo
728
761
  localizations_item = subscription_response[:included].find { |item| item[:type].eql?("subscriptionLocalizations") && item[:id].eql?(new_subscription_item["localizations_id"])}
729
762
 
730
763
  new_subscription_item["display_name"] = localizations_item[:attributes][:name]
731
- new_subscription_item["description"] = localizations_item[:attributes][:description]
764
+ new_subscription_item["description"] = localizations_item[:attributes][:description]
732
765
  end
733
766
 
734
767
 
@@ -737,7 +770,7 @@ module Pindo
737
770
  else
738
771
  new_subscription_item.delete("subscription_free_trial")
739
772
  end
740
-
773
+
741
774
  new_subscription_item["price"] = get_subscription_item_price(appstore_client:appstore_client, subscription_id:old_subscription_item[:id])
742
775
  new_subscription_item.delete("localizations_id")
743
776
 
@@ -752,12 +785,12 @@ module Pindo
752
785
 
753
786
  end
754
787
 
755
- def create_subscription_items(appstore_client:nil, subscription_group_id:nil, subscription_items:nil)
788
+ def create_subscription_items(appstore_client:nil, subscription_group_id:nil, subscription_items:nil)
756
789
 
757
790
 
758
791
  subscription_items = subscription_items || []
759
792
  subscription_items.sort! { | itema, itemb | itema["product_id"] <=> itemb["product_id"]}
760
-
793
+
761
794
  #查询是否存在group
762
795
  subscription_response = appstore_client.list_all_subscription_for_subscription_group(id: subscription_group_id, limit:50)
763
796
  # puts JSON.pretty_generate(subscription_response)
@@ -769,51 +802,52 @@ module Pindo
769
802
  new_subscription_item["subscription_id"] = old_subscription_item[:id]
770
803
  new_subscription_item["state"] = old_subscription_item[:attributes][:state]
771
804
  end
772
- end
805
+ end
773
806
  end
774
807
  end
775
808
 
776
809
  subscription_items.each do |new_subscription_item|
777
810
  puts " 订阅项:" + new_subscription_item["product_id"]
778
811
  if new_subscription_item["subscription_id"].nil?
779
- create_subscription_item(appstore_client:appstore_client, subscription_group_id:subscription_group_id, subscription_item:new_subscription_item)
812
+ create_subscription_item(appstore_client:appstore_client, subscription_group_id:subscription_group_id, subscription_item:new_subscription_item)
780
813
  end
781
-
814
+
782
815
  if !new_subscription_item["subscription_id"].nil?
783
816
  subscription_id = new_subscription_item["subscription_id"]
784
817
  puts " 订阅项id: #{subscription_id}"
785
-
818
+
786
819
  sleep(1)
787
820
  if !new_subscription_item["state"].nil? && new_subscription_item["state"].to_s.eql?("APPROVED")
788
821
  puts " 订阅项已经上线, 只能修改价格"
789
822
  create_subscription_item_price(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
790
823
  update_subscription_item_introductory_offer(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
791
824
  else
792
-
793
- update_subscription_item_attributes(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
794
- create_subscription_item_localization(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
795
- update_subscription_item_screenshots(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
825
+
826
+ update_subscription_item_attributes(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
827
+ create_subscription_item_territory_availability(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
828
+ create_subscription_item_localization(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
829
+ update_subscription_item_screenshots(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
796
830
 
797
831
  create_subscription_item_price(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
798
832
  delete_subscription_item_introductory_offer(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
799
- update_subscription_item_period(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
833
+ update_subscription_item_period(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
800
834
  update_subscription_item_introductory_offer(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
801
835
  end
802
836
 
803
837
 
804
-
838
+
805
839
  end
806
840
  end
807
841
 
808
842
 
809
843
  # subscription_items.each do |new_subscription_item|
810
844
  # puts " 订阅项:" + new_subscription_item["product_id"]
811
-
845
+
812
846
  # if !new_subscription_item["subscription_id"].nil?
813
847
  # subscription_id = new_subscription_item["subscription_id"]
814
848
 
815
- # create_subscription_item_price_with_singlefunc(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
816
- # if new_subscription_item["subscription_free_trial"].nil?
849
+ # create_subscription_item_price_with_singlefunc(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
850
+ # if new_subscription_item["subscription_free_trial"].nil?
817
851
  # delete_subscription_item_introductory_offer_with_singlefunc(appstore_client:appstore_client, subscription_id:subscription_id)
818
852
  # end
819
853
 
@@ -824,14 +858,14 @@ module Pindo
824
858
  subscription_items.each do |new_subscription_item|
825
859
 
826
860
  if !new_subscription_item["subscription_id"].nil?
827
-
861
+
828
862
  if !new_subscription_item["state"].nil? && new_subscription_item["state"].to_s.eql?("APPROVED")
829
863
 
830
864
  else
831
865
  subscription_id = new_subscription_item["subscription_id"]
832
- create_subscription_item_localization(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
866
+ create_subscription_item_localization(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:new_subscription_item)
833
867
  end
834
-
868
+
835
869
  end
836
870
  end
837
871
 
@@ -842,13 +876,12 @@ module Pindo
842
876
 
843
877
 
844
878
 
845
- def create_subscription_item(appstore_client:nil, subscription_group_id:nil, subscription_item:nil)
879
+ def create_subscription_item(appstore_client:nil, subscription_group_id:nil, subscription_item:nil)
846
880
  #创建购买项
847
881
  begin
848
882
  response = appstore_client.create_subscription(
849
883
  name:subscription_item["reference_name"],
850
884
  product_id:subscription_item["product_id"],
851
- available_in_all_territories:true,
852
885
  family_sharable:false,
853
886
  review_note:subscription_item["review_note"],
854
887
  subscription_period:subscription_item["subscription_duration"],
@@ -856,7 +889,7 @@ module Pindo
856
889
  relationships: {
857
890
  group:{
858
891
  data:{
859
- id: subscription_group_id,
892
+ id: subscription_group_id,
860
893
  type: 'subscriptionGroups'
861
894
  }
862
895
  }
@@ -864,16 +897,16 @@ module Pindo
864
897
  )
865
898
 
866
899
  # puts JSON.pretty_generate(response)
867
-
900
+
868
901
  if !response.nil? && !response[:data].nil? && !response[:data][:id].nil?
869
902
 
870
903
  purchase_id = !response[:data][:id]
871
904
  subscription_item["subscription_id"] = response[:data][:id]
872
905
  return purchase_id
873
- else !response.nil? && !response[:errors].nil?
906
+ else !response.nil? && !response[:errors].nil?
874
907
  # puts JSON.pretty_generate(response)
875
908
  response[:errors].each do |error_item|
876
- if error_item[:status].to_s.eql?("409") && error_item[:code].to_s.eql?("ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE") && error_item[:source][:pointer].to_s.eql?("/data/attributes/name")
909
+ if error_item[:status].to_s.eql?("409") && error_item[:code].to_s.eql?("ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE") && error_item[:source][:pointer].to_s.eql?("/data/attributes/name")
877
910
  err_msg = " !!!!!" + subscription_item["product_id"] + " 购买项创建失败!!! Reference Name重复!!!"
878
911
  raise Informative, err_msg
879
912
  end
@@ -888,14 +921,13 @@ module Pindo
888
921
  end
889
922
  end
890
923
 
891
- def update_subscription_item_attributes(appstore_client:nil, subscription_id:nil, subscription_item:nil)
924
+ def update_subscription_item_attributes(appstore_client:nil, subscription_id:nil, subscription_item:nil)
892
925
  puts " 更新Reference Name"
893
926
 
894
927
  begin
895
928
  response = appstore_client.update_subscription(
896
929
  id:subscription_id,
897
930
  name:subscription_item["reference_name"],
898
- available_in_all_territories:true,
899
931
  family_sharable:false,
900
932
  review_note:subscription_item["review_note"],
901
933
  group_level:1
@@ -907,10 +939,10 @@ module Pindo
907
939
  purchase_id = !response[:data][:id]
908
940
  subscription_item["subscription_id"] = response[:data][:id]
909
941
  return purchase_id
910
- else !response.nil? && !response[:errors].nil?
942
+ else !response.nil? && !response[:errors].nil?
911
943
  # puts JSON.pretty_generate(response)
912
944
  response[:errors].each do |error_item|
913
- if error_item[:status].to_s.eql?("409") && error_item[:code].to_s.eql?("ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE") && error_item[:source][:pointer].to_s.eql?("/data/attributes/name")
945
+ if error_item[:status].to_s.eql?("409") && error_item[:code].to_s.eql?("ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE") && error_item[:source][:pointer].to_s.eql?("/data/attributes/name")
914
946
  err_msg = " !!!!!" + subscription_item["product_id"] + " 购买项更新失败!!! Reference Name重复!!!"
915
947
  raise Informative, err_msg
916
948
  end
@@ -918,14 +950,14 @@ module Pindo
918
950
  err_msg = subscription_item["product_id"] + " 购买项更新失败!!!"
919
951
  # puts JSON.pretty_generate(response)
920
952
  end
921
-
953
+
922
954
  rescue => err
923
955
  puts err
924
956
  end
925
957
  end
926
958
 
927
- def update_subscription_item_period(appstore_client:nil, subscription_id:nil, subscription_item:nil)
928
-
959
+ def update_subscription_item_period(appstore_client:nil, subscription_id:nil, subscription_item:nil)
960
+
929
961
  begin
930
962
  puts " 设置订阅的周期: #{subscription_item["subscription_duration"]}"
931
963
  response = appstore_client.update_subscription(
@@ -939,18 +971,54 @@ module Pindo
939
971
  purchase_id = !response[:data][:id]
940
972
  subscription_item["subscription_id"] = response[:data][:id]
941
973
  return purchase_id
942
- else !response.nil? && !response[:errors].nil?
974
+ else !response.nil? && !response[:errors].nil?
943
975
  puts " !!!! 设置订阅的周期失败 !!!!"
944
976
  end
945
-
977
+
946
978
  rescue => err
947
979
  puts err
948
980
  puts " !!!! 设置订阅的周期失败 !!!!"
949
981
  end
950
982
  end
951
983
 
952
- def create_subscription_item_localization(appstore_client:nil, subscription_id:nil, subscription_item:nil)
953
- puts " 更新Display Name"
984
+ def create_subscription_item_territory_availability(appstore_client:nil, subscription_id:nil, subscription_item:nil)
985
+
986
+ puts " 设置订阅的Territory Availability"
987
+ response = appstore_client.list_all_availability(
988
+ limit:200
989
+ )
990
+ # puts JSON.pretty_generate(response)
991
+
992
+ availableTerritories_data = []
993
+ if !response.nil? && !response[:data].nil?
994
+ response[:data].each do |territory_item|
995
+ new_territory_item = {}
996
+ new_territory_item["id"] = territory_item[:id]
997
+ new_territory_item["type"] = territory_item[:type]
998
+ availableTerritories_data << new_territory_item
999
+ end
1000
+ end
1001
+ response = appstore_client.modify_subscription_territory_availability(
1002
+ available_in_new_territories:true,
1003
+ relationships: {
1004
+ subscription:{
1005
+ data:{
1006
+ id: subscription_id,
1007
+ type: 'subscriptions'
1008
+ }
1009
+ },
1010
+ availableTerritories:{
1011
+ data:availableTerritories_data
1012
+ }
1013
+ }
1014
+ )
1015
+
1016
+ # puts JSON.pretty_generate(response)
1017
+ end
1018
+
1019
+
1020
+ def create_subscription_item_localization(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1021
+ puts " 更新Display Name"
954
1022
  begin
955
1023
  # 更新购买项描述多语言
956
1024
  response = appstore_client.list_subscription_all_localizations(
@@ -970,7 +1038,7 @@ module Pindo
970
1038
  subscription_item["localization"][locale]["display_name"] = subscription_item["localization"][locale]["display_name"] || display_name
971
1039
  subscription_item["localization"][locale]["description"] = subscription_item["localization"][locale]["description"] || description
972
1040
  end
973
-
1041
+
974
1042
  end
975
1043
 
976
1044
  # puts JSON.pretty_generate(response)
@@ -1004,10 +1072,10 @@ module Pindo
1004
1072
  )
1005
1073
 
1006
1074
  # puts JSON.pretty_generate(response)
1007
-
1075
+
1008
1076
  end
1009
1077
 
1010
-
1078
+
1011
1079
 
1012
1080
  end
1013
1081
 
@@ -1019,7 +1087,7 @@ module Pindo
1019
1087
  end
1020
1088
 
1021
1089
 
1022
- def get_subscription_item_price(appstore_client:nil, subscription_id:nil)
1090
+ def get_subscription_item_price(appstore_client:nil, subscription_id:nil)
1023
1091
 
1024
1092
  itc_usa_latest_price = 0
1025
1093
 
@@ -1032,8 +1100,8 @@ module Pindo
1032
1100
  limit:200
1033
1101
  )
1034
1102
  # puts JSON.pretty_generate(respose_price)
1035
-
1036
- if !respose_price[:included].nil?
1103
+
1104
+ if !respose_price[:included].nil?
1037
1105
  # respose_price[:included].each do |include_item|
1038
1106
  # if include_item[:type].to_s.eql?("subscriptionPricePoints")
1039
1107
  # itc_usa_latest_price = include_item[:attributes][:customer_price]
@@ -1050,7 +1118,7 @@ module Pindo
1050
1118
 
1051
1119
  end
1052
1120
 
1053
- def create_subscription_item_price(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1121
+ def create_subscription_item_price(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1054
1122
 
1055
1123
  puts " 更新价格 "
1056
1124
  begin
@@ -1074,15 +1142,15 @@ module Pindo
1074
1142
  )
1075
1143
  # puts JSON.pretty_generate(respose_price)
1076
1144
 
1077
-
1078
- if !respose_price[:data].nil?
1145
+
1146
+ if !respose_price[:data].nil?
1079
1147
  respose_price[:data].each_with_index do |data_item, data_index|
1080
1148
  if data_item[:type].to_s.eql?("subscriptionPrices")
1081
1149
  temp_id = data_item[:id]
1082
1150
  temp_price_point_id = data_item[:relationships][:subscription_price_point][:data][:id]
1083
1151
  price_point_item = respose_price[:included].find { |e| e[:id].eql?(temp_price_point_id) }
1084
1152
 
1085
- itc_usa_price = price_point_item[:attributes][:customer_price]
1153
+ itc_usa_price = price_point_item[:attributes][:customer_price]
1086
1154
  data_string = data_item[:attributes][:start_date].nil? ? "无" : data_item[:attributes][:start_date]
1087
1155
  puts " 线上价格#{data_index} :" + itc_usa_price +"$" + " 生效日期 : " + data_string
1088
1156
  end
@@ -1096,7 +1164,7 @@ module Pindo
1096
1164
  end
1097
1165
 
1098
1166
 
1099
- if !respose_price[:included].nil?
1167
+ if !respose_price[:included].nil?
1100
1168
  include_item = respose_price[:included].last
1101
1169
  if include_item[:type].to_s.eql?("subscriptionPricePoints")
1102
1170
  itc_usa_latest_price = include_item[:attributes][:customer_price]
@@ -1108,7 +1176,7 @@ module Pindo
1108
1176
  if !itc_usa_latest_price.nil? && itc_usa_latest_price.to_s.eql?(subscription_item["price"].to_s)
1109
1177
  need_modify_price = false
1110
1178
  end
1111
-
1179
+
1112
1180
  end
1113
1181
 
1114
1182
 
@@ -1169,7 +1237,7 @@ module Pindo
1169
1237
  limit:200
1170
1238
  )
1171
1239
  # puts JSON.pretty_generate(respose_equalizations_id)
1172
-
1240
+
1173
1241
  price_change_relationships_data = {
1174
1242
  newSubscriptionPricePoints:{
1175
1243
  data:[]
@@ -1192,14 +1260,14 @@ module Pindo
1192
1260
 
1193
1261
  index_num = 0
1194
1262
 
1195
- relationships_data[:prices][:data] << {
1196
- type: "subscriptionPrices",
1197
- id: "${newprice-#{index_num}}"
1263
+ relationships_data[:prices][:data] << {
1264
+ type: "subscriptionPrices",
1265
+ id: "${newprice-#{index_num}}"
1198
1266
  }
1199
1267
 
1200
1268
 
1201
1269
  included_data << {
1202
- type: "subscriptionPrices",
1270
+ type: "subscriptionPrices",
1203
1271
  id: "${newprice-#{index_num}}",
1204
1272
  attributes: attributes,
1205
1273
  relationships:{
@@ -1222,12 +1290,12 @@ module Pindo
1222
1290
  respose_equalizations_id[:data].each do |price_local_item|
1223
1291
 
1224
1292
  local_price_point_id = price_local_item[:id]
1225
- relationships_data[:prices][:data] << {
1226
- type: "subscriptionPrices",
1227
- id: "${newprice-#{index_num}}"
1293
+ relationships_data[:prices][:data] << {
1294
+ type: "subscriptionPrices",
1295
+ id: "${newprice-#{index_num}}"
1228
1296
  }
1229
1297
  included_data << {
1230
- type: "subscriptionPrices",
1298
+ type: "subscriptionPrices",
1231
1299
  id: "${newprice-#{index_num}}",
1232
1300
  attributes: attributes,
1233
1301
  relationships:{
@@ -1251,25 +1319,25 @@ module Pindo
1251
1319
 
1252
1320
  # puts JSON.pretty_generate(relationships_data)
1253
1321
  # puts JSON.pretty_generate(included_data)
1254
-
1255
1322
 
1256
1323
 
1257
- if subscription_item["state"].to_s.eql?("APPROVED")
1258
1324
 
1259
-
1325
+ if subscription_item["state"].to_s.eql?("APPROVED")
1326
+
1327
+
1260
1328
 
1261
1329
  respose_response = appstore_client.list_subscription_all_price(
1262
1330
  id:subscription_id,
1263
1331
  include:"subscriptionPricePoint",
1264
1332
  limit:200
1265
1333
  )
1266
-
1334
+
1267
1335
  all_price_data = []
1268
-
1336
+
1269
1337
 
1270
1338
  next_respose_response = respose_response
1271
1339
  all_price_data = all_price_data + respose_response[:data]
1272
- while !next_respose_response.nil? && !next_respose_response[:links].nil? && !next_respose_response[:links][:next].nil?
1340
+ while !next_respose_response.nil? && !next_respose_response[:links].nil? && !next_respose_response[:links][:next].nil?
1273
1341
 
1274
1342
  cursor = nil
1275
1343
  # puts next_respose_response[:links][:next]
@@ -1291,20 +1359,20 @@ module Pindo
1291
1359
  # puts "all_price_data.size: #{all_price_data.size}"
1292
1360
 
1293
1361
  # puts "respose_response[:included].size : #{respose_response[:included].size }"
1294
- if !itc_usa_latest_start_date.nil? && !respose_response.nil? && !respose_response[:links].nil? && !respose_response[:links][:next].nil?
1362
+ if !itc_usa_latest_start_date.nil? && !respose_response.nil? && !respose_response[:links].nil? && !respose_response[:links][:next].nil?
1295
1363
  last_data_items = all_price_data.select { |e| e[:attributes][:start_date].eql?(itc_usa_latest_start_date)}
1296
1364
  else
1297
1365
  last_data_items = all_price_data
1298
1366
  end
1299
1367
 
1300
-
1368
+
1301
1369
  if last_data_items.size > 0
1302
1370
  last_data_items.each do |last_data_item|
1303
1371
  if last_data_item[:type].to_s.eql?("subscriptionPrices")
1304
1372
  price_change_relationships_data[:currentSubscriptionPricePoints][:data] << {
1305
1373
  type:"subscriptionPricePoints",
1306
1374
  id: last_data_item[:relationships][:subscription_price_point][:data][:id]
1307
- }
1375
+ }
1308
1376
  end
1309
1377
  end
1310
1378
  end
@@ -1388,22 +1456,22 @@ module Pindo
1388
1456
  end
1389
1457
 
1390
1458
 
1391
- def update_subscription_item_introductory_offer(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1392
- puts " 设置Introductory Offer : "
1459
+ def update_subscription_item_introductory_offer(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1460
+ puts " 设置Introductory Offer : "
1393
1461
  if !subscription_item["subscription_free_trial"].nil? && subscription_item["subscription_free_trial"].to_s.eql?("3d")
1394
- puts " 3天 试用"
1462
+ puts " 3天 试用"
1395
1463
  create_subscription_item_introductory_offer(appstore_client:appstore_client, subscription_id:subscription_id, subscription_item:subscription_item)
1396
1464
  else
1397
- puts " 无试用"
1398
- end
1465
+ puts " 无试用"
1466
+ end
1399
1467
 
1400
1468
  end
1401
1469
 
1402
- def create_subscription_item_introductory_offer(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1470
+ def create_subscription_item_introductory_offer(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1471
+
1403
1472
 
1404
-
1405
1473
  begin
1406
-
1474
+
1407
1475
  territory_response = appstore_client.list_subscription_territory_availability(
1408
1476
  id:subscription_id,
1409
1477
  limit:200
@@ -1423,13 +1491,13 @@ module Pindo
1423
1491
  index_num = 0
1424
1492
  territory_response[:data].each do |territory_item|
1425
1493
  local_territory_id = territory_item[:id]
1426
- relationships_data[:introductoryOffers][:data] << {
1427
- type: "subscriptionIntroductoryOffers",
1428
- id: "${newIntroOffer-#{index_num}}"
1494
+ relationships_data[:introductoryOffers][:data] << {
1495
+ type: "subscriptionIntroductoryOffers",
1496
+ id: "${newIntroOffer-#{index_num}}"
1429
1497
  }
1430
1498
 
1431
1499
  included_data << {
1432
- type: "subscriptionIntroductoryOffers",
1500
+ type: "subscriptionIntroductoryOffers",
1433
1501
  id: "${newIntroOffer-#{index_num}}",
1434
1502
  attributes: {
1435
1503
  duration:"THREE_DAYS",
@@ -1455,12 +1523,12 @@ module Pindo
1455
1523
  relationships: relationships_data,
1456
1524
  included: included_data
1457
1525
  )
1458
- puts " 3天 试用 设置成功!"
1526
+ puts " 3天 试用 设置成功!"
1459
1527
  # puts JSON.pretty_generate(response)
1460
1528
  end
1461
1529
 
1462
1530
  rescue => err
1463
- puts " !!!! 设置Introductory Offer 失败 !!! "
1531
+ puts " !!!! 设置Introductory Offer 失败 !!! "
1464
1532
  puts err
1465
1533
  end
1466
1534
 
@@ -1468,7 +1536,7 @@ module Pindo
1468
1536
  end
1469
1537
 
1470
1538
 
1471
- def delete_subscription_item_introductory_offer(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1539
+ def delete_subscription_item_introductory_offer(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1472
1540
 
1473
1541
  begin
1474
1542
 
@@ -1482,27 +1550,27 @@ module Pindo
1482
1550
  if !introductory_response[:data].nil? && introductory_response[:data].size > 0
1483
1551
 
1484
1552
  # puts JSON.pretty_generate(introductory_response[:data])
1485
- puts " 线上有试用,先删除"
1553
+ puts " 线上有试用,先删除"
1486
1554
  temp_data = [];
1487
1555
 
1488
1556
  introductory_response[:data].each do |introductory_item|
1489
1557
  temp_data << {id: introductory_item[:id]}
1490
1558
  end
1491
1559
 
1492
-
1560
+
1493
1561
  introductory_response = appstore_client.delete_introductory_offers_for_subscription(
1494
1562
  id:subscription_id,
1495
1563
  data:temp_data
1496
1564
  )
1497
1565
 
1498
- puts " 线上试用删除成功!!!"
1566
+ puts " 线上试用删除成功!!!"
1499
1567
  # puts JSON.pretty_generate(introductory_response)
1500
1568
  else
1501
- puts " 线上无试用, 无需删除!!!"
1569
+ puts " 线上无试用, 无需删除!!!"
1502
1570
  end
1503
1571
 
1504
1572
  rescue => err
1505
- puts " !!!! 删除 试用 失败 !!!!"
1573
+ puts " !!!! 删除 试用 失败 !!!!"
1506
1574
  puts err
1507
1575
  end
1508
1576
 
@@ -1510,9 +1578,9 @@ module Pindo
1510
1578
 
1511
1579
 
1512
1580
 
1513
- def delete_subscription_item_introductory_offer_with_singlefunc(appstore_client:nil, subscription_id:nil)
1581
+ def delete_subscription_item_introductory_offer_with_singlefunc(appstore_client:nil, subscription_id:nil)
1582
+
1514
1583
 
1515
-
1516
1584
  begin
1517
1585
 
1518
1586
  response = appstore_client.list_subscription_introductory_offer_resoure_ids(
@@ -1529,11 +1597,11 @@ module Pindo
1529
1597
  index_item = index_item +1
1530
1598
 
1531
1599
 
1532
- puts " 删除" + index_item.to_s+ "地区的Introductory Offer"
1600
+ puts " 删除" + index_item.to_s+ "地区的Introductory Offer"
1533
1601
 
1534
1602
  ret = appstore_client.delete_subscription_introductory_offer(id:price_point_item[:id])
1535
1603
  # puts JSON.pretty_generate(ret)
1536
-
1604
+
1537
1605
  end
1538
1606
 
1539
1607
  end
@@ -1547,9 +1615,9 @@ module Pindo
1547
1615
  end
1548
1616
 
1549
1617
 
1550
- def create_subscription_item_introductory_offer_with_singlefunc(appstore_client:nil, subscription_id:nil, price_point_id:nil, territory:nil)
1618
+ def create_subscription_item_introductory_offer_with_singlefunc(appstore_client:nil, subscription_id:nil, price_point_id:nil, territory:nil)
1551
1619
 
1552
- puts " 设置Introductory Offer"
1620
+ puts " 设置Introductory Offer"
1553
1621
  begin
1554
1622
 
1555
1623
  response = appstore_client.create_subscription_introductory_offer(
@@ -1575,7 +1643,7 @@ module Pindo
1575
1643
  id: territory
1576
1644
  }
1577
1645
  }
1578
-
1646
+
1579
1647
  },
1580
1648
  included:[{
1581
1649
  type: "subscriptionPrices",
@@ -1592,7 +1660,7 @@ module Pindo
1592
1660
 
1593
1661
 
1594
1662
 
1595
- def create_subscription_item_price_with_singlefunc(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1663
+ def create_subscription_item_price_with_singlefunc(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1596
1664
  puts " 更新价格"
1597
1665
  begin
1598
1666
 
@@ -1636,13 +1704,13 @@ module Pindo
1636
1704
  )
1637
1705
 
1638
1706
 
1639
-
1707
+
1640
1708
  if !subscription_item["subscription_free_trial"].nil? && subscription_item["subscription_free_trial"].to_s.eql?("3d")
1641
-
1642
- create_subscription_item_introductory_offer_with_singlefunc(appstore_client:appstore_client, subscription_id:subscription_id, price_point_id:price_point_id, territory:'USA')
1709
+
1710
+ create_subscription_item_introductory_offer_with_singlefunc(appstore_client:appstore_client, subscription_id:subscription_id, price_point_id:price_point_id, territory:'USA')
1643
1711
  end
1644
1712
 
1645
-
1713
+
1646
1714
 
1647
1715
 
1648
1716
  respose_price = appstore_client.list_subscription_price_points_equalizations(
@@ -1654,7 +1722,7 @@ module Pindo
1654
1722
 
1655
1723
  index_item = 1
1656
1724
  if !respose_price[:data].nil?
1657
-
1725
+
1658
1726
  respose_price[:data].each do |price_local_item|
1659
1727
  index_item = index_item +1
1660
1728
 
@@ -1681,26 +1749,26 @@ module Pindo
1681
1749
  )
1682
1750
 
1683
1751
  # puts JSON.pretty_generate(respose_price)
1684
-
1752
+
1685
1753
  if !subscription_item["subscription_free_trial"].nil? && subscription_item["subscription_free_trial"].to_s.eql?("3d")
1686
-
1687
- create_subscription_item_introductory_offer_with_singlefunc(appstore_client:appstore_client, subscription_id:subscription_id, price_point_id:price_point_id, territory:territory_id)
1754
+
1755
+ create_subscription_item_introductory_offer_with_singlefunc(appstore_client:appstore_client, subscription_id:subscription_id, price_point_id:price_point_id, territory:territory_id)
1688
1756
  end
1689
-
1757
+
1690
1758
  end
1691
1759
 
1692
1760
  end
1693
1761
 
1694
1762
 
1695
1763
  end
1696
-
1764
+
1697
1765
  rescue => err
1698
1766
  puts "创建价格失败: " + subscription_item["product_id"]
1699
1767
  puts err
1700
1768
  end
1701
1769
  end
1702
1770
 
1703
- def update_subscription_item_screenshots(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1771
+ def update_subscription_item_screenshots(appstore_client:nil, subscription_id:nil, subscription_item:nil)
1704
1772
  puts " 更新截屏"
1705
1773
  begin
1706
1774
  response_iap_screenshot = appstore_client.read_review_screenshot_for_subscription(id:subscription_id)
@@ -1718,15 +1786,15 @@ module Pindo
1718
1786
  need_upload_screenshot = true
1719
1787
 
1720
1788
  if !response_iap_screenshot[:data].nil? && !response_iap_screenshot[:data][:attributes].nil? && !response_iap_screenshot[:data][:attributes][:asset_delivery_state].nil? && !response_iap_screenshot[:data][:attributes][:asset_delivery_state][:state].nil?
1721
-
1789
+
1722
1790
  if response_iap_screenshot[:data][:attributes][:asset_delivery_state][:state].to_s.eql?("COMPLETE")
1723
-
1791
+
1724
1792
  if !response_iap_screenshot[:data].nil? && !response_iap_screenshot[:data][:attributes].nil? && !response_iap_screenshot[:data][:attributes][:source_file_checksum].nil?
1725
1793
 
1726
1794
  if checksum.to_s.eql?(response_iap_screenshot[:data][:attributes][:source_file_checksum].to_s)
1727
1795
  puts " 有截屏,截屏未修改,无需重新上传"
1728
1796
  need_upload_screenshot = false
1729
-
1797
+
1730
1798
  end
1731
1799
  end
1732
1800
  end
@@ -1749,13 +1817,13 @@ module Pindo
1749
1817
  relationships: {
1750
1818
  subscription:{
1751
1819
  data:{
1752
- id: subscription_id,
1820
+ id: subscription_id,
1753
1821
  type: 'subscriptions'
1754
1822
  }
1755
1823
  }
1756
1824
  }
1757
1825
  )
1758
-
1826
+
1759
1827
  # puts JSON.pretty_generate(response_iap_screenshot)
1760
1828
 
1761
1829
  if !response_iap_screenshot[:data].nil? && !response_iap_screenshot[:data][:id].nil?
@@ -1773,7 +1841,7 @@ module Pindo
1773
1841
  res = conn.put(upload_operation[:url], bytes[offset, length], headers)
1774
1842
  end
1775
1843
 
1776
-
1844
+
1777
1845
 
1778
1846
  in_app_purchase = appstore_client.update_subscription_review_screenshot(
1779
1847
  id:upload_id,
@@ -1788,7 +1856,7 @@ module Pindo
1788
1856
 
1789
1857
  puts " 存在图片,无需上传...."
1790
1858
  end
1791
-
1859
+
1792
1860
 
1793
1861
 
1794
1862