Class: DigiwinDsp::Resources::WebhookSubscription
- Inherits:
-
Object
- Object
- DigiwinDsp::Resources::WebhookSubscription
- Defined in:
- lib/digiwin_dsp/resources/webhook_subscription.rb
Overview
Registers a webhook callback URL with DSP (DSPOOFFICIAL100, POST /v1/webhook on the webhook_base_url).
Not a Resources::Base subclass — the request envelope is a single ‘request` object (not `request_detail[]` array), the fields are explicit kwargs (not an arbitrary hash), and it targets the webhook_base_url instead of base_url.
Constant Summary collapse
- PATH =
"/v1/webhook"- DEFAULT_PROD =
"OFFICIALWEBSITE"- ACTIONS =
%w[ product/inventory_update wms/logistics/package/update invoice/update ].freeze
- ADDRESS_MAX_LENGTH =
500
Class Method Summary collapse
Instance Method Summary collapse
- #create(action:, address:, platform_id: nil, prod: DEFAULT_PROD) ⇒ Object
-
#initialize(client = nil) ⇒ WebhookSubscription
constructor
A new instance of WebhookSubscription.
Constructor Details
#initialize(client = nil) ⇒ WebhookSubscription
Returns a new instance of WebhookSubscription.
26 27 28 |
# File 'lib/digiwin_dsp/resources/webhook_subscription.rb', line 26 def initialize(client = nil) @client = client || Client.new(base_url: DigiwinDsp.configuration.webhook_base_url) end |
Class Method Details
.create(action:, address:, platform_id: nil, prod: DEFAULT_PROD) ⇒ Object
22 23 24 |
# File 'lib/digiwin_dsp/resources/webhook_subscription.rb', line 22 def self.create(action:, address:, platform_id: nil, prod: DEFAULT_PROD) new.create(action: action, address: address, platform_id: platform_id, prod: prod) end |
Instance Method Details
#create(action:, address:, platform_id: nil, prod: DEFAULT_PROD) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/digiwin_dsp/resources/webhook_subscription.rb', line 30 def create(action:, address:, platform_id: nil, prod: DEFAULT_PROD) validate_args!(action: action, address: address) body = build_body(action: action, address: address, platform_id: platform_id, prod: prod) response = @client.post(PATH, body) response.dig("std_data", "response") || raise(DigiwinDsp::ServerError, "DSP returned execution.code=0 without std_data.response") end |