Class: Nucleo::Webhook

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

Class Method Summary collapse

Class Method Details

.register_site(site) ⇒ Boolean

Registers a new site. Responds true or false if the webhook was successful.

Parameters:

  • Hash

    :site (dump of Site model expected)

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/nucleo/webhook.rb', line 8

def self.register_site(site)
  method = :post
  path = 'sites'

  # Convert id into site_id (as expected from Site model)
  site['site_id'] = site['id']

  body = site.to_json

  begin
    response = Nucleo::request(method, path, body)
  rescue NucleoRequestError => e
    print e.message
  end

  response
end