class CronjobService::Notifier

Public Class Methods

push(project_id, cron_identifier, options = {}) click to toggle source
# File lib/cronjob_service.rb, line 11
def self.push(project_id, cron_identifier, options = {})
  raise "project_id missing" if project_id.nil?
  raise "cron_identifier missing" if cron_identifier.nil?

  base_url = "https://dashboard.smart-village.app/api/v1/cronjob"
  post_url = "#{base_url}/#{project_id}?title=#{cron_identifier}"

  begin
    uri = URI.parse(post_url)
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    request = Net::HTTP::Post.new(uri.request_uri, {})
    request.body = ({ title: cron_identifier }.merge(options)).to_json

    # Send the request
    response = http.request(request)
  rescue => e
   puts "https://dashboard.smart-village.app Error: #{e.inspect}"
  end
end