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,13 +4,12 @@ require 'json'
require 'net/http'
require 'net/https'
require 'uri'
require 'rest-client'
class CdrSignalAPI
class CdrSignalApi
def initialize(api_url, token)
@token = token
@last_update = 0
@api = api_url
@api_url = api_url
end
def parse_hash(hash)
@ -22,13 +21,13 @@ class CdrSignalAPI
end
def get(api)
url = "#{@api}/bots/#{@token}/#{api}"
JSON.parse(RestClient.get(url, { accept: :json }).body)
url = "#{@api_url}/bots/#{@token}/#{api}"
JSON.parse(Faraday.get(url, { Accept: "application/json" }).body)
end
def post(api, params = {})
url = "#{@api}/bots/#{@token}/#{api}"
JSON.parse(RestClient.post(url, params, { accept: :json }).body)
url = "#{@api_url}/bots/#{@token}/#{api}"
JSON.parse(Faraday.post(url, params.to_json, { "Content-Type": "application/json", Accept: "application/json" }).body)
end
def fetch_self