Class: SmartRecruiters::WebhooksResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/smartrecruiters/resources/webhooks.rb

Constant Summary collapse

WEBHOOK_API =
'webhooks-api/v201907'

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from SmartRecruiters::Resource

Instance Method Details

#activate(webhook_id:, **attributes) ⇒ Object



24
25
26
# File 'lib/smartrecruiters/resources/webhooks.rb', line 24

def activate(webhook_id:, **attributes)
  put_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}/activation", body: attributes)
end

#callbacks_log(webhook_id:, **params) ⇒ Object



28
29
30
31
# File 'lib/smartrecruiters/resources/webhooks.rb', line 28

def callbacks_log(webhook_id:, **params)
  response = get_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}/callbacks-log", params: params)
  Collection.from_response(response, type: CallbacksLog)
end

#create(**attributes) ⇒ Object



12
13
14
# File 'lib/smartrecruiters/resources/webhooks.rb', line 12

def create(**attributes)
  Webhook.new post_request("#{WEBHOOK_API}/subscriptions", body: attributes).body
end

#delete(webhook_id:) ⇒ Object



20
21
22
# File 'lib/smartrecruiters/resources/webhooks.rb', line 20

def delete(webhook_id:)
  delete_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}")
end

#generate_secret(webhook_id:, **attributes) ⇒ Object



33
34
35
# File 'lib/smartrecruiters/resources/webhooks.rb', line 33

def generate_secret(webhook_id:, **attributes)
  Object.new post_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}/secret-key", body: attributes).body
end

#list(**params) ⇒ Object



7
8
9
10
# File 'lib/smartrecruiters/resources/webhooks.rb', line 7

def list(**params)
  response = get_request("#{WEBHOOK_API}/subscriptions", params: params)
  Collection.from_response(response, type: Webhook)
end

#retrieve(webhook_id:) ⇒ Object



16
17
18
# File 'lib/smartrecruiters/resources/webhooks.rb', line 16

def retrieve(webhook_id:)
  Webhook.new get_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}").body
end

#retrieve_secret(webhook_id:) ⇒ Object



37
38
39
# File 'lib/smartrecruiters/resources/webhooks.rb', line 37

def retrieve_secret(webhook_id:)
  Object.new get_request("#{WEBHOOK_API}/subscriptions/#{webhook_id}/secret-key").body
end