Module: BlackStack::StealthBrowserAutomation::Multilogin
- Defined in:
- lib/stealth_browser_automation.rb
Constant Summary collapse
- @@auth_token =
nil
- @@mla_version =
nil
- @@mla_local_port =
nil
Class Method Summary collapse
- .auth_token ⇒ Object
-
.create_profile(data) ⇒ Object
returns the profileId of the new Mimic profile.
- .mla_local_port ⇒ Object
- .mla_version ⇒ Object
-
.remove_profile(profile_id) ⇒ Object
returns the profileId of the new Mimic profile.
- .set(h) ⇒ Object
Class Method Details
.auth_token ⇒ Object
19 20 21 |
# File 'lib/stealth_browser_automation.rb', line 19 def self.auth_token() @@auth_token end |
.create_profile(data) ⇒ Object
returns the profileId of the new Mimic profile
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/stealth_browser_automation.rb', line 38 def self.create_profile(data) url = "https://api.multiloginapp.com/v2/profile?token=#{BlackStack::StealthBrowserAutomation::Multilogin::auth_token.to_s}&mlaVersion=#{BlackStack::StealthBrowserAutomation::Multilogin::mla_version.to_s}" uri = URI(url) Net::HTTP.start(uri.host, uri.port, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| req = Net::HTTP::Post.new(uri) req['Content-Type'] = 'application/json' req.body = data.to_json res = JSON.parse(http.request(req).body) raise "Error creating Multilogin profile: #{res.to_s}" if !res.has_key?('uuid') return res['uuid'] end end |
.mla_local_port ⇒ Object
27 28 29 |
# File 'lib/stealth_browser_automation.rb', line 27 def self.mla_local_port() @@mla_local_port end |
.mla_version ⇒ Object
23 24 25 |
# File 'lib/stealth_browser_automation.rb', line 23 def self.mla_version() @@mla_version end |
.remove_profile(profile_id) ⇒ Object
returns the profileId of the new Mimic profile
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/stealth_browser_automation.rb', line 52 def self.remove_profile(profile_id) url = "https://api.multiloginapp.com/v1/profile/remove?token=#{BlackStack::StealthBrowserAutomation::Multilogin::auth_token.to_s}&profileId=#{profile_id}" uri = URI.parse(url) req = Net::HTTP::Get.new(url) res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http| http.request(req) } res = JSON.parse(res.body) raise "Error removing Multilogin profile: #{res.to_s}" if !res.has_key?('status') raise "Error removing Multilogin profile: #{res['status'].to_s}" if res['status'] != 'OK' end |
.set(h) ⇒ Object
31 32 33 34 35 |
# File 'lib/stealth_browser_automation.rb', line 31 def self.set(h) @@auth_token = h[:auth_token] @@mla_version = h[:mla_version] @@mla_local_port = h[:mla_local_port] end |