2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-03-31 17:19:02 +02:00
|
|
|
class APITchap::API
|
|
|
|
class ResourceNotFound < StandardError
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.get_hs(email)
|
|
|
|
call([API_TCHAP_URL, "info?medium=email&address=#{email}"].join('/'))
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def self.call(url)
|
|
|
|
response = Typhoeus.get(url)
|
|
|
|
|
|
|
|
if response.success?
|
|
|
|
response.body
|
|
|
|
else
|
|
|
|
message = response.code == 0 ? response.return_message : response.code.to_s
|
|
|
|
Rails.logger.error "[APITchap] Error on #{url}: #{message}"
|
|
|
|
raise ResourceNotFound
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|