Class: RDStation::Webhooks
- Inherits:
-
Object
- Object
- RDStation::Webhooks
show all
- Includes:
- HTTParty, RetryableRequest
- Defined in:
- lib/rdstation/webhooks.rb
Constant Summary
RetryableRequest::MAX_RETRIES
Instance Method Summary
collapse
#refresh_access_token, #retry_possible?, #retryable_request
Constructor Details
#initialize(authorization:) ⇒ Webhooks
Returns a new instance of Webhooks.
6
7
8
|
# File 'lib/rdstation/webhooks.rb', line 6
def initialize(authorization:)
@authorization = authorization
end
|
Instance Method Details
#all ⇒ Object
10
11
12
13
14
15
|
# File 'lib/rdstation/webhooks.rb', line 10
def all
retryable_request(@authorization) do |authorization|
response = self.class.get(base_url, headers: authorization.)
ApiResponse.build(response)
end
end
|
#by_uuid(uuid) ⇒ Object
17
18
19
20
21
22
|
# File 'lib/rdstation/webhooks.rb', line 17
def by_uuid(uuid)
retryable_request(@authorization) do |authorization|
response = self.class.get(base_url(uuid), headers: authorization.)
ApiResponse.build(response)
end
end
|
#create(payload) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/rdstation/webhooks.rb', line 24
def create(payload)
retryable_request(@authorization) do |authorization|
response = self.class.post(base_url, headers: authorization., body: payload.to_json)
ApiResponse.build(response)
end
end
|
#delete(uuid) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/rdstation/webhooks.rb', line 38
def delete(uuid)
retryable_request(@authorization) do |authorization|
response = self.class.delete(base_url(uuid), headers: authorization.)
return webhook_deleted_message unless response.body
RDStation::ErrorHandler.new(response).raise_error
end
end
|
#update(uuid, payload) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/rdstation/webhooks.rb', line 31
def update(uuid, payload)
retryable_request(@authorization) do |authorization|
response = self.class.put(base_url(uuid), headers: authorization., body: payload.to_json)
ApiResponse.build(response)
end
end
|