Class: CDEKApiClient::Entities::Webhook

Inherits:
Object
  • Object
show all
Includes:
Validatable
Defined in:
lib/cdek_api_client/entities/webhook.rb

Overview

Represents a webhook entity in the CDEK API. Each webhook includes attributes such as url, type, and event types.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validatable

included, #validate!

Constructor Details

#initialize(url:, type:, event_types:) ⇒ Webhook

Initializes a new Webhook object.

Parameters:

  • url (String)

    the URL where the webhook will send data.

  • type (String)

    the type of webhook.

  • event_types (Array<String>)

    the list of event types for the webhook.

Raises:

  • (ArgumentError)

    if any attribute validation fails.



24
25
26
27
28
29
# File 'lib/cdek_api_client/entities/webhook.rb', line 24

def initialize(url:, type:, event_types:)
  @url = url
  @type = type
  @event_types = event_types
  validate!
end

Instance Attribute Details

#event_typesObject

Returns the value of attribute event_types.



12
13
14
# File 'lib/cdek_api_client/entities/webhook.rb', line 12

def event_types
  @event_types
end

#typeObject

Returns the value of attribute type.



12
13
14
# File 'lib/cdek_api_client/entities/webhook.rb', line 12

def type
  @type
end

#urlObject

Returns the value of attribute url.



12
13
14
# File 'lib/cdek_api_client/entities/webhook.rb', line 12

def url
  @url
end

Instance Method Details

#to_json(*_args) ⇒ String

Converts the Webhook object to a JSON representation.

Returns:

  • (String)

    the JSON representation of the Webhook.



34
35
36
37
38
39
40
# File 'lib/cdek_api_client/entities/webhook.rb', line 34

def to_json(*_args)
  {
    url: @url,
    type: @type,
    event_types: @event_types
  }.to_json
end