Class: Unit::Webhook::CreateWebhookRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/webhook/create_webhook_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, url, token, content_type, delivery_mode, include_resources = nil, subscription_type = nil) ⇒ CreateWebhookRequest

Returns a new instance of CreateWebhookRequest.

Parameters:

  • label (String)
  • url (String)
  • token (String)
  • content_type (String)
  • delivery_mode (String)
  • include_resources (Boolean) (defaults to: nil)
    • optional

  • subscription_type (String) (defaults to: nil)
    • optional



18
19
20
21
22
23
24
25
26
27
# File 'lib/unit/models/webhook/create_webhook_request.rb', line 18

def initialize(label, url, token, content_type, delivery_mode,
               include_resources = nil, subscription_type = nil)
  @label = label
  @url = url
  @token = token
  @content_type = content_type
  @delivery_mode = delivery_mode
  @include_resources = include_resources
  @subscription_type = subscription_type
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



8
9
10
# File 'lib/unit/models/webhook/create_webhook_request.rb', line 8

def content_type
  @content_type
end

#delivery_modeObject

Returns the value of attribute delivery_mode.



8
9
10
# File 'lib/unit/models/webhook/create_webhook_request.rb', line 8

def delivery_mode
  @delivery_mode
end

#include_resourcesObject

Returns the value of attribute include_resources.



8
9
10
# File 'lib/unit/models/webhook/create_webhook_request.rb', line 8

def include_resources
  @include_resources
end

#labelObject

Returns the value of attribute label.



8
9
10
# File 'lib/unit/models/webhook/create_webhook_request.rb', line 8

def label
  @label
end

#subscription_typeObject

Returns the value of attribute subscription_type.



8
9
10
# File 'lib/unit/models/webhook/create_webhook_request.rb', line 8

def subscription_type
  @subscription_type
end

#tokenObject

Returns the value of attribute token.



8
9
10
# File 'lib/unit/models/webhook/create_webhook_request.rb', line 8

def token
  @token
end

#urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/unit/models/webhook/create_webhook_request.rb', line 8

def url
  @url
end

Instance Method Details

#to_json_apiObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/unit/models/webhook/create_webhook_request.rb', line 29

def to_json_api
  payload = {
    data: {
      type: "webhook",
      attributes: {
        label: label,
        url: url,
        token: token,
        contentType: content_type,
        deliveryMode: delivery_mode,
        includeResources: include_resources,
        subscriptionType: subscription_type
      }
    }
  }
  payload[:data][:attributes].compact!
  payload.to_json
end