Class: Unit::Webhook::PatchWebhookRequest

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(webhook_id, label, url, content_type, token, include_resources = nil, subscription_type = nil) ⇒ PatchWebhookRequest

Returns a new instance of PatchWebhookRequest.

Parameters:

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

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



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

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

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



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

def content_type
  @content_type
end

#include_resourcesObject (readonly)

Returns the value of attribute include_resources.



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

def include_resources
  @include_resources
end

#labelObject (readonly)

Returns the value of attribute label.



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

def label
  @label
end

#subscription_typeObject (readonly)

Returns the value of attribute subscription_type.



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

def subscription_type
  @subscription_type
end

#tokenObject (readonly)

Returns the value of attribute token.



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

def token
  @token
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

#webhook_idObject (readonly)

Returns the value of attribute webhook_id.



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

def webhook_id
  @webhook_id
end

Instance Method Details

#to_json_apiObject



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

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