Class: CronjobService::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/cronjob_service.rb

Class Method Summary collapse

Class Method Details

.push(project_id, cron_identifier, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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