Class: Finnhub::Webhook

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, id: nil, hash: nil) ⇒ Webhook



3
4
5
6
7
# File 'lib/Webhook.rb', line 3

def initialize(client:, id: nil, hash: nil)
  @client = client
  @id = id
  @hash = hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



9
10
11
# File 'lib/Webhook.rb', line 9

def hash
  @hash
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/Webhook.rb', line 9

def id
  @id
end

Instance Method Details

#create(body:) ⇒ Object



11
12
13
14
15
# File 'lib/Webhook.rb', line 11

def create(body:)
  response = @client.request("/webhook/add", method: :post, body: body)
  @id = response[:id]
  response
end

#deleteObject



17
18
19
20
21
# File 'lib/Webhook.rb', line 17

def delete
  response = @client.request("/webhook/delete", method: :post, body: {id: @id})
  @id = nil
  response
end