cocoapods-byte-panglem-beta 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: afddde5a0deee3c6ea7d6ab6c1e1501230d9174f04198b00dfb978ffe7ad9a62
4
+ data.tar.gz: c79ed3bf0e38953f98c04f0a52966a7f00fc4a0a82e14c8f948ca158a3d70563
5
+ SHA512:
6
+ metadata.gz: fafbce7c60b4909aa1ede07766633b6d2d5c6e323e1f2f09be681d2f1d70839492bdc905c557c8336c376526edc300fa583c5f878a9acda05f4bbe90ee5e3910
7
+ data.tar.gz: 3d5f88d697c042b72b086b3bf9044c6e99799c08f2034bf267e806a41c59ce7c1f5922844811a06b4569fc708dd4ca21512b01bd00fd43b577405c3d0d35e6d4
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-byte-panglem.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2023 zhangtianhao.1230@bytedance.com <zhangtianhao.1230@bytedance.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # cocoapods-byte-panglem
2
+
3
+ A description of cocoapods-byte-panglem.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-byte-panglem
8
+
9
+ ## Usage
10
+
11
+ $ pod spec panglem POD_NAME
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-byte-panglem-beta/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-byte-panglem-beta'
8
+ spec.version = CocoapodsBytePanglem::VERSION
9
+ spec.authors = ['zhangtianhao.1230@bytedance.com']
10
+ spec.email = ['zhangtianhao.1230@bytedance.com']
11
+ spec.description = %q{A short description of cocoapods-byte-panglem.}
12
+ spec.summary = %q{A longer description of cocoapods-byte-panglem.}
13
+ spec.homepage = 'https://github.com/EXAMPLE/cocoapods-byte-panglem'
14
+ spec.license = 'MIT'
15
+
16
+ # spec.files = Dir['lib/**/*']
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+ spec.add_dependency "cocoapods", '>= 1.1.1', '< 2.0'
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rake'
24
+ spec.add_development_dependency 'highline'
25
+ end
@@ -0,0 +1,213 @@
1
+ ##Copyright 2023 ByteDance Ltd. and/or its affiliates
2
+ ##SPDX-License-Identifier: MIT
3
+
4
+ require_relative 'tool'
5
+ require_relative 'recorder'
6
+ require 'highline'
7
+
8
+
9
+
10
+ module PM
11
+
12
+ # 处理器
13
+ #
14
+ class Analyzer
15
+
16
+ def self.resolve_release_target(target, specs)
17
+
18
+ is_exist, hash = PM::Lockfile.read_from_path(File.expand_path("#{Pod::Config.instance.installation_root}/Podfile.pangle"))
19
+ if is_exist
20
+ ## 校验.pangle文件有无改动
21
+ checksum = hash.delete("RECODER_CHECKSUM")
22
+ verified_checksum = Digest::SHA1.hexdigest(hash.inspect).encode('UTF-8') if checksum.respond_to?(:encode)
23
+ if verified_checksum != checksum
24
+ raise "[cocoapods-byte-panglem-beta][error] Podfile.pangle file verification failed, you should not modify this file, please delete this file, re-execute 'pod iinstall', if you confirm that it has not been modified, please contact us "
25
+ end
26
+ result = UpdateResut.from_hash(hash)
27
+ ## 校验Pangle SDK是否符合预期
28
+ pm_spec = specs.find do |spec|
29
+ result.sdk_name==Pod::Specification.root_name(spec.spec.name)
30
+ end
31
+ if pm_spec.nil?
32
+ raise "[cocoapods-byte-panglem-beta][error] #{result.sdk_name} not found}"
33
+ end
34
+ if pm_spec.spec.version.version != result.sdk_original_version
35
+ raise "[cocoapods-byte-panglem-beta][error] #{result.sdk_name} version has change(#{result.sdk_original_version}->#{pm_spec.spec.version.version}),After generating the Podfile.panglewe file, you may have made some changes in the podfile, causing the version of Pangle SDK to change. Please change 'use_pangm_sdk_update! :is_release => true
36
+ ',delete':is_release => true' and re-execute 'pod install'"
37
+ end
38
+ if result.is_sdk_update
39
+ title_options = { :verbose_prefix => '-> '.green }
40
+ Pod::UserInterface.titled_section("[cocoapods-byte-panglem-beta][info] will change pangle sdk version , the current version will change from #{result.sdk_original_version} to #{result.sdk_target_version}", title_options)
41
+ specs.delete_if{|spec|
42
+ Pod::Specification.root_name(spec.spec.name) == result.sdk_name && spec.spec.version.version == result.sdk_original_version
43
+ }
44
+ result.sdk_list.each{ |spec|
45
+ specs << Pod::Resolver::ResolverSpecification.new(spec, false, spec.spec_source)
46
+ }
47
+
48
+ if result.is_rely_update
49
+ specs.delete_if{|spec|
50
+ Pod::Specification.root_name(spec.spec.name) == result.rely_name && spec.spec.version.version == result.rely_original_version
51
+ }
52
+ result.rely_list.each{ |spec|
53
+ specs << Pod::Resolver::ResolverSpecification.new(spec, false, spec.spec_source)
54
+ }
55
+ end
56
+ end
57
+ specs.sort_by!{|spec| spec.spec.name}
58
+ specs
59
+ else
60
+ raise "[cocoapods-byte-panglem-beta][error] #{File.expand_path("#{Pod::Config.instance.installation_root}/Podfile.pangle")} not found, please check"
61
+ end
62
+ end
63
+
64
+ def self.resolve_last(target, specs)
65
+ is_update_finish = false
66
+ sdk_spec = nil
67
+ adapter_list = []
68
+ ## SDK 场景下不需要
69
+ if false
70
+ pm_spec = nil
71
+ adn_specs = specs.select do |spec|
72
+ name = spec.spec.name
73
+ if name == PM::BuildConfig.mediation_name
74
+ pm_spec = spec
75
+ target.PM_build_config.PM_info = PM::PMInfo.new(spec.spec.name, spec.spec.version.version)
76
+ end
77
+ if PM::Adn_Adapter.is_adapter?(name)
78
+ adn_note = target.PM_build_config.find_note PM::Adn_Adapter.get_adn name
79
+ adn_note.adapter_name = name
80
+ adn_note.adapter_original_version = spec.spec.version.version
81
+ elsif PM::Adn_Adapter.is_adn?(name)
82
+ adn_note = target.PM_build_config.find_note name
83
+ adn_note.adn_version = spec.spec.version.version
84
+ end
85
+ target.PM_build_config.is_adn_update_or_detect?(name)
86
+ end
87
+ # raise " error: Ads-Mediation-CN not found,please check" if pm_spec == nil
88
+ adn_info_list = adn_specs.map{|adn_spec|
89
+ adn_note = target.PM_build_config.find_note adn_spec.spec.name
90
+ adn_note.adn_version = adn_spec.spec.version.version
91
+ {"adn_name" => PM::Adn_Adapter.get_adn_abbreviation(adn_spec.spec.name),"adn_version" => adn_spec.spec.version.version}
92
+ # {"adn_name" => "ks","adn_version" => adn_spec.spec.version.version}
93
+
94
+ # {"adn_name" => adn_spec.spec.name,"adn_version" => adn_spec.spec.version.version, "auto_update" => adn_note.auto_update, "load_detect" => adn_note.load_detect, "adapter_name" => adn_note.adapter_name, "adapter_version" => adn_note.adapter_original_version}
95
+ } if pm_spec
96
+ end
97
+ specs.map do |spec|
98
+ if PM::MapRelations.is_sdk?(spec.spec.name)
99
+ sdk_spec = spec
100
+ elsif PM::MapRelations.is_adapter?(spec.spec.name)
101
+ map = {}
102
+ map["adapter"] = PM::MapRelations.get_adapter_from_adn_abbreviation(spec.spec.name)
103
+ map["adapter_version"] = spec.spec.version.version
104
+ adapter_list << map
105
+ else
106
+ end
107
+ end
108
+
109
+ raise "[cocoapods-byte-panglem-beta][error] Ads-Global-Beta not found,please add" if sdk_spec == nil
110
+ PM::Recorder.instance.adapter_list = adapter_list
111
+ # is_exist, wish_info = read_user_wishes
112
+ wish_info = nil
113
+ response_data = request_adapter sdk_spec.spec.version.version ,adapter_list, wish_info
114
+ result = PM::SpecificationInfo.get_specfication response_data, sdk_spec
115
+ ## 1. 判断sdk是否要更新, YES 则将旧的全部删除, 新的全部挂载
116
+ ## 2. 判断rely 是否要更新, YES 则同上
117
+ if result.is_sdk_update
118
+ ## 这里截断,询问是否更新
119
+ cli = HighLine.new
120
+ # is_allow_update =cli.ask("[cocoapods-byte-panglem-beta][info] Whether to allow automatic upgrade of pangle sdk(#{result.sdk_original_version} to #{result.sdk_target_version}),yes/no?")
121
+ is_allow_update = 'yes'
122
+ if is_allow_update == 'yes' or is_allow_update == 'y' or is_allow_update == 'Y'
123
+ title_options = { :verbose_prefix => '-> '.green }
124
+ Pod::UserInterface.titled_section("[cocoapods-byte-panglem-beta][info] will change pangle sdk version , the current version will change from #{result.sdk_original_version} to #{result.sdk_target_version}", title_options)
125
+ specs.delete_if{|spec|
126
+ Pod::Specification.root_name(spec.spec.name) == result.sdk_name && spec.spec.version.version == result.sdk_original_version
127
+ }
128
+ result.sdk_list.each{ |spec|
129
+ specs << Pod::Resolver::ResolverSpecification.new(spec, false, spec.spec_source)
130
+ }
131
+
132
+ if result.is_rely_update
133
+ specs.delete_if{|spec|
134
+ Pod::Specification.root_name(spec.spec.name) == result.rely_name && spec.spec.version.version == result.rely_original_version
135
+ }
136
+ result.rely_list.each{ |spec|
137
+ specs << Pod::Resolver::ResolverSpecification.new(spec, false, spec.spec_source)
138
+ }
139
+ end
140
+ specs.sort_by!{|spec| spec.spec.name}
141
+ is_update_finish = true
142
+ request_track result.sdk_original_version, result.sdk_target_version, result.sdk_target_version, response_data["code"], response_data["message"]
143
+
144
+ else
145
+ wish_info = {"no_auto_update"=>true,"timestamp" =>Time.now.to_i}
146
+ recode_user_wishes wish_info
147
+ end
148
+ end
149
+ is_update_finish
150
+ end
151
+
152
+ def self.recode_user_wishes(wish_info)
153
+ PM::Lockfile.new(wish_info.to_hash).write_to_disk(File.expand_path("#{Pod::Config.instance.installation_root}/pangle.temp"))
154
+ end
155
+
156
+ def self.read_user_wishes()
157
+ PM::Lockfile.read_from_path(File.expand_path("#{Pod::Config.instance.installation_root}/pangle.temp"))
158
+ end
159
+
160
+ def self.delete_invalid_adapters(target, specs)
161
+ un_den_adn_list= PM::Adn_Adapter.get_all_adn - specs.map(&:spec).map(&:name).map do |item|
162
+ PM::Adn_Adapter.is_adn?(item) ? Pod::Specification.root_name(item) : nil
163
+ end.compact.uniq
164
+ un_den_adapter_list = []
165
+ un_den_adapter_list = un_den_adn_list.map {|item|
166
+ PM::Adn_Adapter.get_adapter item
167
+ }
168
+ specs.delete_if { |spec|
169
+ result = un_den_adapter_list.include?(Pod::Specification.root_name(spec.spec.name)) && !PM::Recorder.instance.global_note.auto_load_whitelist.keys.include?(Pod::Specification.root_name(spec.spec.name))
170
+ if result
171
+ title_options = { :verbose_prefix => '-> '.red}
172
+ Pod::UserInterface.titled_section("remove #{spec.spec.name}", title_options)
173
+ end
174
+ result
175
+ }
176
+ end
177
+
178
+ def self.request_adapter(version, adapter_list, wish_info = nil)
179
+
180
+ package_name = PM::MProject.get_package_name
181
+ body = Hash["package_name"=>package_name, "pangle_sdk_version"=>version, "os_type"=>"ios","adapter"=>adapter_list,"beta_config"=>1]
182
+ if wish_info
183
+ body["media_prefer"] = wish_info
184
+ end
185
+ data = PM::Network.request_adapter(body,PM::Recorder.instance.use_service_local)
186
+ data
187
+ end
188
+
189
+ def self.request_track(old_ad_sdk_version, new_ad_sdk_version, target_ad_sdk_version, code, message)
190
+ package_name = PM::MProject.get_package_name
191
+ plugin_version = CocoapodsBytePanglem::Version.version
192
+ event_extra = Hash["old_ad_sdk_version" => old_ad_sdk_version, "new_ad_sdk_version" => new_ad_sdk_version, "target_ad_sdk_version" => target_ad_sdk_version, "package_name" => package_name,"plugin_version"=>plugin_version,"error_code"=>code,"error_msg"=>message].to_json
193
+ stats_list = []
194
+ stats_list << Hash["event_extra" => event_extra, "is_ad_event"=> 1, "type"=>"update_version_code","os"=>"ios","beta_config"=>1]
195
+
196
+ message = Hash["ts"=>Time.now.to_i,"stats_list"=>stats_list].to_json
197
+ body = Hash["message"=>message,"cypher"=>0]
198
+ PM::Network.request_track(body,old_ad_sdk_version)
199
+ end
200
+
201
+ def self.is_update?(value)
202
+ is_auto_update?(value) || is_stable_update?(value)
203
+ end
204
+
205
+ def self.is_auto_update?(value)
206
+ value == PM::BuildConfig.update_value_last_version
207
+ end
208
+
209
+ def self.is_stable_update?(value)
210
+ value == PM::BuildConfig.update_value_last_stable_version
211
+ end
212
+ end
213
+ end
@@ -0,0 +1,4 @@
1
+ ##Copyright 2023 ByteDance Ltd. and/or its affiliates
2
+ ##SPDX-License-Identifier: MIT
3
+
4
+ require 'cocoapods-byte-panglem-beta/command/panglem'
@@ -0,0 +1,178 @@
1
+ ##Copyright 2023 ByteDance Ltd. and/or its affiliates
2
+ ##SPDX-License-Identifier: MIT
3
+
4
+
5
+ module PM
6
+
7
+ # 配置项key
8
+ #
9
+ class BuildConfig
10
+
11
+ def self.get_load_key
12
+ :gm_auto_load
13
+ end
14
+
15
+ def self.get_update_key
16
+ :gm_auto_update
17
+ end
18
+
19
+ def self.get_load_detect_key
20
+ :gm_load_detect
21
+ end
22
+
23
+ def self.get_load_whitelist_key
24
+ :auto_load_whitelist
25
+ end
26
+
27
+ def self.get_is_release_key
28
+ :is_release
29
+ end
30
+
31
+ def self.get_use_service_local_key
32
+ :use_service_local
33
+ end
34
+
35
+ def self.update_value_last_version
36
+ return "last" ## 最新版本
37
+ end
38
+
39
+ def self.update_value_last_stable_version
40
+ return "last_stable" ## 最新稳定版本
41
+ end
42
+
43
+ def self.update_value_non
44
+ return "not_update" ## 不自动更新
45
+ end
46
+
47
+ def self.mediation_name
48
+ return "Ads-Global-Beta"
49
+ end
50
+
51
+ def self.rely_name
52
+ return "BURelyFoundation_Global"
53
+ end
54
+
55
+ def self.get_all_config
56
+ [BuildConfig.get_update_key,BuildConfig.get_load_key,BuildConfig.get_load_detect_key]
57
+ end
58
+ end
59
+
60
+ # admob:
61
+ # IS:IronSourcePangleAdapter
62
+ # max:
63
+ # tradplus:
64
+ # pod 'TradPlusAdSDK/PangleAdapter', '9.9.0'
65
+
66
+ # topon:
67
+
68
+ # pod '','6.2.66'
69
+
70
+ # adn mediation adapter 三者之间的映射关系, mediation后续会用到
71
+ class MapRelations
72
+
73
+ ADNADAPTER = Hash[
74
+ ## sdk 不需要
75
+ # 'Ads-CN' => 'ABUAdCsjAdapter',
76
+ 'UnityAds' => 'ABUAdUnityAdapter',
77
+ 'Google-Mobile-Ads-SDK'=> 'ABUAdAdmobAdapter',
78
+ 'BaiduMobAdSDK'=> 'ABUAdBaiduAdapter',
79
+ 'GDTMobSDK'=> 'ABUAdGdtAdapter',
80
+ 'SigmobAd-iOS'=> 'ABUAdSigmobAdapter',
81
+ 'KSAdSDK'=> 'ABUAdKsAdapter',
82
+ 'KlevinAdSDK'=> 'ABUAdKlevinAdapter',
83
+ 'MintegralAdSDK'=> 'ABUAdMintegralAdapter',
84
+ ].freeze
85
+
86
+ ## sdk 被接入adapter的映射关系
87
+ SERVERMAPADAPTER = Hash[
88
+
89
+ 'GoogleMobileAdsMediationPangle'=> 'admob',
90
+ 'IronSourcePangleAdapter'=> 'ironsource',
91
+ 'AppLovinMediationByteDanceAdapter'=> 'max',
92
+ 'TradPlusAdSDK/PangleAdapter'=> 'tradplus',
93
+ 'AnyThinkiOS/AnyThinkPangleAdapter'=> 'topon',
94
+ ].freeze
95
+
96
+ SERVERMAPADN = Hash[
97
+ 'UnityAds' => 'unity',
98
+ 'Google-Mobile-Ads-SDK'=> 'admob',
99
+ 'BaiduMobAdSDK'=> 'baidu',
100
+ 'GDTMobSDK'=> 'gdt',
101
+ 'SigmobAd-iOS'=> 'sigmob',
102
+ 'KSAdSDK'=> 'ks',
103
+ 'KlevinAdSDK'=> 'klevin',
104
+ 'MintegralAdSDK'=> 'mtg',
105
+ ].freeze
106
+
107
+ SDKNAME = "Ads-Global-Beta".freeze
108
+ SDKRELY = "BURelyFoundation_Global".freeze
109
+ SHOULD_REMOVE = [SDKNAME,SDKRELY]
110
+
111
+ def self.is_adn?(name)
112
+ name == SDKNAME
113
+ end
114
+
115
+ def self.get_adn_abbreviation(name)
116
+ SERVERMAPADN[name]
117
+ end
118
+
119
+ def self.get_adapter_from_adn_abbreviation(name)
120
+ SERVERMAPADAPTER[name]
121
+ end
122
+
123
+ def self.is_adn?(name)
124
+ ADNADAPTER.has_key?(name)
125
+ end
126
+
127
+ def self.is_sdk?(name)
128
+ SDKNAME==name
129
+ end
130
+
131
+ def self.is_adapter?(name)
132
+ SERVERMAPADAPTER.has_key?(name)
133
+ end
134
+
135
+ def self.should_remove_requirements?(name)
136
+ SHOULD_REMOVE.include?(name)
137
+ end
138
+
139
+ def self.get_adapter(name)
140
+ adapter = ''
141
+ if is_adn?(name)
142
+ adapter = ADNADAPTER[name]
143
+ end
144
+ adapter
145
+ end
146
+
147
+ def self.get_adn(name)
148
+ adn_name = ''
149
+ if is_adapter?(name)
150
+ ## .index 在调试时候会报错
151
+ ADNADAPTER.select{ |key, value|
152
+ if value == name
153
+ adn_name = key
154
+ break
155
+ end
156
+ true
157
+ }
158
+ end
159
+ adn_name
160
+ end
161
+
162
+ def self.get_all_adapter
163
+ ADNADAPTER.values
164
+ end
165
+
166
+ def self.get_all_adn
167
+ ADNADAPTER.keys
168
+ end
169
+
170
+ def self.get_sdk
171
+ SDKNAME
172
+ end
173
+
174
+
175
+ end
176
+
177
+
178
+ end
@@ -0,0 +1,11 @@
1
+ ##Copyright 2023 ByteDance Ltd. and/or its affiliates
2
+ ##SPDX-License-Identifier: MIT
3
+
4
+ module CocoapodsBytePanglem
5
+ VERSION = "0.0.1"
6
+ class Version
7
+ def self.version
8
+ VERSION
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,68 @@
1
+ ##Copyright 2023 ByteDance Ltd. and/or its affiliates
2
+ ##SPDX-License-Identifier: MIT
3
+
4
+ require 'uri'
5
+ require 'net/http'
6
+ require 'net/https'
7
+ require 'json'
8
+
9
+ module PM
10
+ # 网络请求
11
+ class Network
12
+ ## post请求
13
+ def Network.post (url,body)
14
+ # puts "start net request:#{body}"
15
+ uri = URI.parse(url)
16
+ https = Net::HTTP.new(uri.host,uri.port)
17
+ https.use_ssl = true ## 正式时请打开
18
+ request = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})
19
+ # request["Cookie"]="__union_admin_sess_cookie=232301_noduimkpdwrbyrkr1qih; _ssa_userphone=; _ssa_username=zhangtianhao.1230"
20
+ request.body = body.to_json
21
+ if PM::Recorder.instance.is_debug
22
+ puts "[cocoapods-byte-panglem-beta][debug] 网络请求信息: #{body.to_json}, url:#{url}"
23
+ end
24
+ res = https.request(request)
25
+
26
+ if res.code == "200"
27
+ data = JSON.parse(res.body)
28
+ if PM::Recorder.instance.is_debug
29
+ puts "[cocoapods-byte-panglem-beta][debug] 网络返回信息: #{data}"
30
+ end
31
+ return data
32
+ else
33
+ ## 网络请求异常的提示
34
+ puts "[cocoapods-byte-panglem-beta][error] response code = #{res.code}, message = #{res.message}"
35
+ end
36
+ nil
37
+ end
38
+
39
+ def Network.request_adapter(body, is_debug = false)
40
+ if is_debug
41
+ url = URI.parse('http://localhost:8080/index.html')
42
+ http = Net::HTTP.new(url.host, url.port)
43
+ request = Net::HTTP::Get.new(url.path, initheader = {'Content-Type' =>'application/json'})
44
+ response = http.request(request)
45
+ if PM::Recorder.instance.is_debug
46
+ puts "[cocoapods-byte-panglem-beta][debug] 网络请求信息: #{body.to_json}, url:#{url}"
47
+ end
48
+ data = JSON.parse(response.body)
49
+ if PM::Recorder.instance.is_debug
50
+ puts "[cocoapods-byte-panglem-beta][debug] 网络返回信息: #{data}"
51
+ end
52
+
53
+ data
54
+ else
55
+ data = post("https://open-api.pangleglobal.com/union/media/open_api/auto_upgrade/config",body)
56
+ end
57
+ end
58
+
59
+ def Network.request_track(body, version_code)
60
+ ## https://api16-access-sg.pangle.io/api/ad/union/sdk/stats/batch/
61
+ url = "https://api16-access-sg.pangle.io/api/ad/union/sdk/stats/batch/"+"?aid=5000546&version_code=#{version_code}&device_platform=iphone"
62
+ data = post(url,body)
63
+ data
64
+ end
65
+ end
66
+
67
+
68
+ end