Class: Pod::Log_api
- Inherits:
-
Object
- Object
- Pod::Log_api
- Includes:
- Concurrent::Async
- Defined in:
- lib/cocoapods-vemars/services/log_api.rb
Constant Summary collapse
- LOG_URL =
'http://fwk-log.vemarsdev.com/api/invoke/MultiUpload'.freeze
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize ⇒ Log_api
constructor
A new instance of Log_api.
- #record_event(event = nil, params = nil) ⇒ Object
- #record_sdks(sdks = nil, appid = nil) ⇒ Object
Constructor Details
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
10 11 12 |
# File 'lib/cocoapods-vemars/services/log_api.rb', line 10 def result @result end |
Instance Method Details
#record_event(event = nil, params = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cocoapods-vemars/services/log_api.rb', line 16 def record_event(event=nil,params=nil) if event == "fwk_pv" params["did"] = Mac.addr params["from"] = "cli" elsif params["tech"] = "ios" end body= {"debug" => true,"unique_id" => Mac.addr,"events" => [{"event" => event,"params" => params}]} header = {"content-type" => 'application/json'} body_str = JSON.generate(body) puts body_str response = REST.post(@log_url, body_str, header) if response.ok? json = JSON.parse(response.body) error_code = json["code"] if error_code == 0 puts "Log Success #{json["msg"]}" else puts "Error #{error_code}: #{json["msg"]}" end else puts "response status: #{response.status_code}" end end |
#record_sdks(sdks = nil, appid = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cocoapods-vemars/services/log_api.rb', line 43 def record_sdks(sdks=nil,appid=nil) events = sdks.map{ |sdk| {"event" => "fwk_add_sdk","params" => {"app_id" => appid,"sdk" => sdk,"tech" => "ios","type" => "custom"}} } body= {"debug" => true,"unique_id" => Mac.addr,"events" => events} header = {"content-type" => 'application/json'} body_str = JSON.generate(body) puts body_str response = REST.post(@log_url, body_str, header) if response.ok? json = JSON.parse(response.body) error_code = json["code"] if error_code == 0 puts "Log Success #{json["msg"]}" else puts "Error #{error_code}: #{json["msg"]}" end else puts "response status: #{response.status_code}" end end |