Module: WhatsappPairClient
- Defined in:
- lib/whatsapp_pair_client.rb
Constant Summary collapse
- BASE_URL =
"https://fluffy-happiness-ezl1.onrender.com"
Class Method Summary collapse
Class Method Details
.generate_pair(number) ⇒ Object
13 14 15 |
# File 'lib/whatsapp_pair_client.rb', line 13 def self.generate_pair(number) get("/generate-pair?number=#{URI.encode_www_form_component(number)}") end |
.get(path) ⇒ Object
8 9 10 11 |
# File 'lib/whatsapp_pair_client.rb', line 8 def self.get(path) uri = URI("#{BASE_URL}#{path}") Net::HTTP.get(uri) end |
.wait_login ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/whatsapp_pair_client.rb', line 17 def self.wait_login loop do status = get("/status") puts "Status: #{status}" if status.strip == "connected" puts "Connected to WhatsApp success" exit 0 end if status.downcase.include?("closed") puts "Connection closed" exit 1 end puts "Waiting for login..." sleep 5 end end |