Whatsapp send and Zammad autologin fixes

This commit is contained in:
Darren Clarke 2023-09-08 16:34:13 +02:00
parent a3d6b786e1
commit 9e68be7225
15 changed files with 153 additions and 100 deletions

View file

@ -4,9 +4,8 @@ require 'json'
require 'net/http'
require 'net/https'
require 'uri'
require 'rest-client'
class CdrWhatsappAPI
class CdrWhatsappApi
def initialize(api_url, token)
@token = token
@last_update = 0
@ -20,15 +19,15 @@ class CdrWhatsappAPI
end
ret
end
def get(api)
url = "#{@api_url}/bots/#{@token}/#{api}"
JSON.parse(RestClient.get(url, { accept: :json }).body)
JSON.parse(Faraday.get(url, { Accept: "application/json" }).body)
end
def post(api, params = {})
url = "#{@api_url}/bots/#{@token}/#{api}"
JSON.parse(RestClient.post(url, params, { accept: :json }).body)
JSON.parse(Faraday.post(url, params.to_json, { "Content-Type": "application/json", Accept: "application/json" }).body)
end
def fetch_self