-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the Webhook Endpoint resource
- Loading branch information
1 parent
9bc6ae8
commit 94e40c5
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stripe | ||
class WebhookEndpoint < APIResource | ||
extend Stripe::APIOperations::Create | ||
include Stripe::APIOperations::Save | ||
include Stripe::APIOperations::Delete | ||
extend Stripe::APIOperations::List | ||
|
||
OBJECT_NAME = "webhook_endpoint".freeze | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require ::File.expand_path("../../test_helper", __FILE__) | ||
|
||
module Stripe | ||
class WebhookEndpointTest < Test::Unit::TestCase | ||
should "be listable" do | ||
webhook_endpoints = Stripe::WebhookEndpoint.list | ||
assert_requested :get, "#{Stripe.api_base}/v1/webhook_endpoints" | ||
assert webhook_endpoints.data.is_a?(Array) | ||
assert webhook_endpoints.first.is_a?(Stripe::WebhookEndpoint) | ||
end | ||
|
||
should "be retrievable" do | ||
webhook_endpoint = Stripe::WebhookEndpoint.retrieve("we_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/webhook_endpoints/we_123" | ||
assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint) | ||
end | ||
|
||
should "be creatable" do | ||
webhook_endpoint = Stripe::WebhookEndpoint.create( | ||
enabled_events: ['*'], | ||
url: 'https://stripe.com' | ||
) | ||
assert_requested :post, "#{Stripe.api_base}/v1/webhook_endpoints" | ||
assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint) | ||
end | ||
|
||
should "be saveable" do | ||
webhook_endpoint = Stripe::WebhookEndpoint.retrieve("we_123") | ||
webhook_endpoint.enabled_events = ['*'] | ||
webhook_endpoint.save | ||
assert_requested :post, "#{Stripe.api_base}/v1/webhook_endpoints/#{webhook_endpoint.id}" | ||
end | ||
|
||
should "be updateable" do | ||
webhook_endpoint = Stripe::WebhookEndpoint.update("we_123", enabled_events: ['*']) | ||
assert_requested :post, "#{Stripe.api_base}/v1/webhook_endpoints/we_123" | ||
assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint) | ||
end | ||
end | ||
end |