Class: Tamara::Webhooks

Inherits:
ApplicationService show all
Includes:
JsonSchemas::Webhook
Defined in:
lib/tamara/api/webhooks.rb

Constant Summary

Constants included from JsonSchemas::Webhook

JsonSchemas::Webhook::DISPUTE, JsonSchemas::Webhook::ORDER, JsonSchemas::Webhook::TYPES

Constants included from JsonSchemas::Validator

JsonSchemas::Validator::ERROR_MESSAGES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from JsonSchemas::Validator

#validate_params!

Methods inherited from ApplicationService

#call, #initialize

Methods included from Request

#api_token, #error_message, #handle_response_error, #headers, #parsed_response, #response_body, #response_status

Constructor Details

This class inherits a constructor from Tamara::ApplicationService

Class Method Details

.register(type:, events:, url:, headers: {}, opts: {}) ⇒ Object



5
6
7
# File 'lib/tamara/api/webhooks.rb', line 5

def self.register(type:, events:, url:, headers: {}, opts: {})
  new(type: type, events: events, url: url, headers: headers, opts: opts).call
end

Instance Method Details

#call_apiObject



9
10
11
# File 'lib/tamara/api/webhooks.rb', line 9

def call_api
  ::Faraday.post(url, api_params.to_json, headers)
end

#urlObject



13
14
15
# File 'lib/tamara/api/webhooks.rb', line 13

def url
  Tamara.webhooks_uri
end