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_local_profile(data) ⇒ Object
returns the profileId of the new Mimic profile.
-
.create_profile(data) ⇒ Object
returns the profileId of the new Mimic profile.
-
.local_profile_id(name) ⇒ Object
returns the profile_id from its name.
-
.local_profiles ⇒ Object
returns the profileId of the new Mimic profile TODO: validar posibles errores.
- .mla_local_port ⇒ Object
- .mla_version ⇒ Object
-
.remove_local_profile(profile_id) ⇒ Object
returns the profileId of the new Mimic profile.
-
.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_local_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_local_profile(data) url = "http://127.0.0.1:#{BlackStack::StealthBrowserAutomation::Multilogin::mla_local_port.to_s}/api/v2/localprofile/create" uri = URI(url) Net::HTTP.start(uri.host, uri.port, :use_ssl => false, :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 local profile: #{res.to_s}" if !res.has_key?('uuid') return res['uuid'] end end |
.create_profile(data) ⇒ Object
returns the profileId of the new Mimic profile
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/stealth_browser_automation.rb', line 89 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 |
.local_profile_id(name) ⇒ Object
returns the profile_id from its name. If not exists a profile with such name, it returns nil.
82 83 84 85 86 |
# File 'lib/stealth_browser_automation.rb', line 82 def self.local_profile_id(name) h = self.local_profiles.select { |h| h['name'] == name }.first return nil if h.nil? h['sid'] end |
.local_profiles ⇒ Object
returns the profileId of the new Mimic profile TODO: validar posibles errores
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/stealth_browser_automation.rb', line 67 def self.local_profiles() url = "http://127.0.0.1:#{BlackStack::StealthBrowserAutomation::Multilogin::mla_local_port.to_s}/api/v2/localprofile/list" uri = URI.parse(url) res = Net::HTTP.start(uri.host, uri.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http| req = Net::HTTP::Get.new(uri) #req['Content-Type'] = 'application/json' #req.body = {}.to_json res = JSON.parse(http.request(req).body) #raise "Error creating Multilogin local profile: #{res.to_s}" if res['status'] != 'OK' return res } 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_local_profile(profile_id) ⇒ Object
returns the profileId of the new Mimic profile
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/stealth_browser_automation.rb', line 52 def self.remove_local_profile(profile_id) url = "http://127.0.0.1:#{BlackStack::StealthBrowserAutomation::Multilogin::mla_local_port.to_s}/api/v2/localprofile/remove" uri = URI.parse(url) res = Net::HTTP.start(uri.host, uri.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http| req = Net::HTTP::Post.new(uri) req['Content-Type'] = 'application/json' req.body = [profile_id].to_json res = JSON.parse(http.request(req).body) raise "Error creating Multilogin local profile: #{res.to_s}" if res['status'] != 'OK' return } end |
.remove_profile(profile_id) ⇒ Object
returns the profileId of the new Mimic profile
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/stealth_browser_automation.rb', line 103 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 |