-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create Singleton NetworkHandler class * Make NetworkHandler responsible of tracking request
- Loading branch information
Showing
4 changed files
with
53 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'clamp' | ||
require_relative 'osproject' | ||
require_relative 'osproject_ios' | ||
require_relative 'osproject_android' | ||
|
||
class NetworkHandler | ||
@instance = new | ||
|
||
private_class_method :new | ||
|
||
def self.instance | ||
@instance | ||
end | ||
|
||
def send_track_from_message(app_id, platform, lang, success_mesage, append_message) | ||
actions_taken = success_mesage.gsub(" * ", "").gsub("\n",";") | ||
actions_taken += append_message | ||
send_track_actions(app_id, platform, lang, actions_taken) | ||
end | ||
|
||
def send_track_actions(app_id, platform, lang, actions_taken) | ||
uri = URI.parse('https://api.onesignal.com/api/v1/track') | ||
|
||
http = Net::HTTP.new(uri.host, uri.port) | ||
http.use_ssl = true | ||
|
||
request = Net::HTTP::Post.new(uri.request_uri) | ||
request.set_form_data({}) | ||
request['app_id'] = app_id | ||
request['OS-Usage-Data'] = 'lib-name=' + OSProject.tool_name + ',lib-version=' + OSProject.version + ',lib-os=' + OSProject.os + ',lib-type=' + platform + ',lib-lang=' + lang + ',lib-actions=' + actions_taken | ||
|
||
response = http.request(request) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ def has_sdk? | |
end | ||
|
||
def self.version | ||
'1.0' | ||
'0.0.0' | ||
end | ||
|
||
def self.os | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters