cocoapods-byte-panglem 0.0.13

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: 26b854a81df5e6720c7d4811ac2769e670909bfacf64e0dc25d2fc404763c9e6
4
+ data.tar.gz: 208b20bf28b0d10dd192b34328c593dac9b76cd7714365ef45f8b2cd04b773ff
5
+ SHA512:
6
+ metadata.gz: 681642db0afe73dbafce4325eef618d2470f402fa08677d7a6479459e69197775db758068e7b827e3c1eee4878c5a58a47b3a9560063035ea3dad836048a9b7e
7
+ data.tar.gz: '08ef5bb2c679b75bbf7b8bbb744bd24f0853f3fe5e4ef4fc775b78e27527ca43508c5194b0887a709213815fa7f77d612c8cfd5e48d7a85a754c94f0e9a168dd'
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/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-byte-panglem'
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,212 @@
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][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][error] #{result.sdk_name} not found}"
33
+ end
34
+ if pm_spec.spec.version.version != result.sdk_original_version
35
+ raise "[cocoapods-byte-panglem][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][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][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][error] Ads-Global 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
+ response_data = request_adapter sdk_spec.spec.version.version ,adapter_list, wish_info
113
+ result = PM::SpecificationInfo.get_specfication response_data, sdk_spec
114
+ ## 1. 判断sdk是否要更新, YES 则将旧的全部删除, 新的全部挂载
115
+ ## 2. 判断rely 是否要更新, YES 则同上
116
+ if result.is_sdk_update
117
+ ## 这里截断,询问是否更新
118
+ cli = HighLine.new
119
+ is_allow_update =cli.ask("[cocoapods-byte-panglem][info] Whether to allow automatic upgrade of pangle sdk(#{result.sdk_original_version} to #{result.sdk_target_version}),yes/no?")
120
+ # is_allow_update = 'yes'
121
+ if is_allow_update == 'yes' or is_allow_update == 'y' or is_allow_update == 'Y'
122
+ title_options = { :verbose_prefix => '-> '.green }
123
+ Pod::UserInterface.titled_section("[cocoapods-byte-panglem][info] will change pangle sdk version , the current version will change from #{result.sdk_original_version} to #{result.sdk_target_version}", title_options)
124
+ specs.delete_if{|spec|
125
+ Pod::Specification.root_name(spec.spec.name) == result.sdk_name && spec.spec.version.version == result.sdk_original_version
126
+ }
127
+ result.sdk_list.each{ |spec|
128
+ specs << Pod::Resolver::ResolverSpecification.new(spec, false, spec.spec_source)
129
+ }
130
+
131
+ if result.is_rely_update
132
+ specs.delete_if{|spec|
133
+ Pod::Specification.root_name(spec.spec.name) == result.rely_name && spec.spec.version.version == result.rely_original_version
134
+ }
135
+ result.rely_list.each{ |spec|
136
+ specs << Pod::Resolver::ResolverSpecification.new(spec, false, spec.spec_source)
137
+ }
138
+ end
139
+ specs.sort_by!{|spec| spec.spec.name}
140
+ is_update_finish = true
141
+ request_track result.sdk_original_version, result.sdk_target_version, result.sdk_target_version, response_data["code"], response_data["message"]
142
+
143
+ else
144
+ wish_info = {"no_auto_update"=>true,"timestamp" =>Time.now.to_i}
145
+ recode_user_wishes wish_info
146
+ end
147
+ end
148
+ is_update_finish
149
+ end
150
+
151
+ def self.recode_user_wishes(wish_info)
152
+ PM::Lockfile.new(wish_info.to_hash).write_to_disk(File.expand_path("#{Pod::Config.instance.installation_root}/pangle.temp"))
153
+ end
154
+
155
+ def self.read_user_wishes()
156
+ PM::Lockfile.read_from_path(File.expand_path("#{Pod::Config.instance.installation_root}/pangle.temp"))
157
+ end
158
+
159
+ def self.delete_invalid_adapters(target, specs)
160
+ un_den_adn_list= PM::Adn_Adapter.get_all_adn - specs.map(&:spec).map(&:name).map do |item|
161
+ PM::Adn_Adapter.is_adn?(item) ? Pod::Specification.root_name(item) : nil
162
+ end.compact.uniq
163
+ un_den_adapter_list = []
164
+ un_den_adapter_list = un_den_adn_list.map {|item|
165
+ PM::Adn_Adapter.get_adapter item
166
+ }
167
+ specs.delete_if { |spec|
168
+ 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))
169
+ if result
170
+ title_options = { :verbose_prefix => '-> '.red}
171
+ Pod::UserInterface.titled_section("remove #{spec.spec.name}", title_options)
172
+ end
173
+ result
174
+ }
175
+ end
176
+
177
+ def self.request_adapter(version, adapter_list, wish_info = nil)
178
+
179
+ package_name = PM::MProject.get_package_name
180
+ body = Hash["package_name"=>package_name, "pangle_sdk_version"=>version, "os_type"=>"ios","adapter"=>adapter_list]
181
+ if wish_info
182
+ body["media_prefer"] = wish_info
183
+ end
184
+ data = PM::Network.request_adapter(body,PM::Recorder.instance.use_service_local)
185
+ data
186
+ end
187
+
188
+ def self.request_track(old_ad_sdk_version, new_ad_sdk_version, target_ad_sdk_version, code, message)
189
+ package_name = PM::MProject.get_package_name
190
+ plugin_version = CocoapodsBytePanglem::Version.version
191
+ 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
192
+ stats_list = []
193
+ stats_list << Hash["event_extra" => event_extra, "is_ad_event"=> 1, "type"=>"update_version_code","os"=>"ios"]
194
+
195
+ message = Hash["ts"=>Time.now.to_i,"stats_list"=>stats_list].to_json
196
+ body = Hash["message"=>message,"cypher"=>0]
197
+ PM::Network.request_track(body,old_ad_sdk_version)
198
+ end
199
+
200
+ def self.is_update?(value)
201
+ is_auto_update?(value) || is_stable_update?(value)
202
+ end
203
+
204
+ def self.is_auto_update?(value)
205
+ value == PM::BuildConfig.update_value_last_version
206
+ end
207
+
208
+ def self.is_stable_update?(value)
209
+ value == PM::BuildConfig.update_value_last_stable_version
210
+ end
211
+ end
212
+ 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/command/panglem'
@@ -0,0 +1,174 @@
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"
49
+ end
50
+
51
+ def self.get_all_config
52
+ [BuildConfig.get_update_key,BuildConfig.get_load_key,BuildConfig.get_load_detect_key]
53
+ end
54
+ end
55
+
56
+ # admob:
57
+ # IS:IronSourcePangleAdapter
58
+ # max:
59
+ # tradplus:
60
+ # pod 'TradPlusAdSDK/PangleAdapter', '9.9.0'
61
+
62
+ # topon:
63
+
64
+ # pod '','6.2.66'
65
+
66
+ # adn mediation adapter 三者之间的映射关系, mediation后续会用到
67
+ class MapRelations
68
+
69
+ ADNADAPTER = Hash[
70
+ ## sdk 不需要
71
+ # 'Ads-CN' => 'ABUAdCsjAdapter',
72
+ 'UnityAds' => 'ABUAdUnityAdapter',
73
+ 'Google-Mobile-Ads-SDK'=> 'ABUAdAdmobAdapter',
74
+ 'BaiduMobAdSDK'=> 'ABUAdBaiduAdapter',
75
+ 'GDTMobSDK'=> 'ABUAdGdtAdapter',
76
+ 'SigmobAd-iOS'=> 'ABUAdSigmobAdapter',
77
+ 'KSAdSDK'=> 'ABUAdKsAdapter',
78
+ 'KlevinAdSDK'=> 'ABUAdKlevinAdapter',
79
+ 'MintegralAdSDK'=> 'ABUAdMintegralAdapter',
80
+ ].freeze
81
+
82
+ ## sdk 被接入adapter的映射关系
83
+ SERVERMAPADAPTER = Hash[
84
+
85
+ 'GoogleMobileAdsMediationPangle'=> 'admob',
86
+ 'IronSourcePangleAdapter'=> 'ironsource',
87
+ 'AppLovinMediationByteDanceAdapter'=> 'max',
88
+ 'TradPlusAdSDK/PangleAdapter'=> 'tradplus',
89
+ 'AnyThinkiOS/AnyThinkPangleAdapter'=> 'topon',
90
+ ].freeze
91
+
92
+ SERVERMAPADN = Hash[
93
+ 'UnityAds' => 'unity',
94
+ 'Google-Mobile-Ads-SDK'=> 'admob',
95
+ 'BaiduMobAdSDK'=> 'baidu',
96
+ 'GDTMobSDK'=> 'gdt',
97
+ 'SigmobAd-iOS'=> 'sigmob',
98
+ 'KSAdSDK'=> 'ks',
99
+ 'KlevinAdSDK'=> 'klevin',
100
+ 'MintegralAdSDK'=> 'mtg',
101
+ ].freeze
102
+
103
+ SDKNAME = "Ads-Global".freeze
104
+ SDKRELY = "BURelyFoundation_Global".freeze
105
+ SHOULD_REMOVE = [SDKNAME,SDKRELY]
106
+
107
+ def self.is_adn?(name)
108
+ name == SDKNAME
109
+ end
110
+
111
+ def self.get_adn_abbreviation(name)
112
+ SERVERMAPADN[name]
113
+ end
114
+
115
+ def self.get_adapter_from_adn_abbreviation(name)
116
+ SERVERMAPADAPTER[name]
117
+ end
118
+
119
+ def self.is_adn?(name)
120
+ ADNADAPTER.has_key?(name)
121
+ end
122
+
123
+ def self.is_sdk?(name)
124
+ SDKNAME==name
125
+ end
126
+
127
+ def self.is_adapter?(name)
128
+ SERVERMAPADAPTER.has_key?(name)
129
+ end
130
+
131
+ def self.should_remove_requirements?(name)
132
+ SHOULD_REMOVE.include?(name)
133
+ end
134
+
135
+ def self.get_adapter(name)
136
+ adapter = ''
137
+ if is_adn?(name)
138
+ adapter = ADNADAPTER[name]
139
+ end
140
+ adapter
141
+ end
142
+
143
+ def self.get_adn(name)
144
+ adn_name = ''
145
+ if is_adapter?(name)
146
+ ## .index 在调试时候会报错
147
+ ADNADAPTER.select{ |key, value|
148
+ if value == name
149
+ adn_name = key
150
+ break
151
+ end
152
+ true
153
+ }
154
+ end
155
+ adn_name
156
+ end
157
+
158
+ def self.get_all_adapter
159
+ ADNADAPTER.values
160
+ end
161
+
162
+ def self.get_all_adn
163
+ ADNADAPTER.keys
164
+ end
165
+
166
+ def self.get_sdk
167
+ SDKNAME
168
+ end
169
+
170
+
171
+ end
172
+
173
+
174
+ 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.13"
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][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][debug] 网络返回信息: #{data}"
30
+ end
31
+ return data
32
+ else
33
+ ## 网络请求异常的提示
34
+ puts "[cocoapods-byte-panglem][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][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][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