Class: QiwiObserver::WebhookRemoval
- Inherits:
-
Object
- Object
- QiwiObserver::WebhookRemoval
- Defined in:
- lib/qiwi_observer/webhook/webhook_removal.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(hook_id) ⇒ WebhookRemoval
constructor
A new instance of WebhookRemoval.
Constructor Details
#initialize(hook_id) ⇒ WebhookRemoval
Returns a new instance of WebhookRemoval.
5 6 7 8 9 10 11 |
# File 'lib/qiwi_observer/webhook/webhook_removal.rb', line 5 def initialize(hook_id) @token = QiwiObserver.config.token @hook_id = hook_id raise ArgumentError, "QiwiObserver must be configure with token" if @token.nil? raise ArgumentError, "Hook ID must be set" unless hook_id end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/qiwi_observer/webhook/webhook_removal.rb', line 13 def call uri = URI("https://edge.qiwi.com/payment-notifier/v1/hooks/#{@hook_id}") request = prepare_a_request(uri) http = connect_to_api(uri) response = http.request(request) return WebhookResponse.new(success: true, body: response.body) if response.is_a?(Net::HTTPOK) return WebhookResponse.new(success: false, body: [response.code, response.]) end |