Class: GrowsurfRuby::Resources::Campaign::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/growsurf_ruby/resources/campaign/webhooks.rb,
sig/growsurf_ruby/resources/campaign/webhooks.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Webhooks

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Webhooks.

Parameters:



151
152
153
# File 'lib/growsurf_ruby/resources/campaign/webhooks.rb', line 151

def initialize(client:)
  @client = client
end

Instance Method Details

#create(id, payload_url:, events: nil, is_enabled: nil, secret: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::Webhook

Adds a webhook to the program.

Parameters:

  • id (String)

    Path param: GrowSurf program ID.

  • payload_url (String)

    Body param: The URL that receives webhook deliveries.

  • events (Array<Symbol, GrowsurfRuby::Models::Campaign::WebhookEvent>)

    Body param: The events this webhook is subscribed to. When omitted, it is subscri

  • is_enabled (Boolean)

    Body param

  • secret (String)

    Body param: Write-only. Used to sign deliveries (the GrowSurf-Signature HMAC hea

  • request_options (GrowsurfRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



44
45
46
47
48
49
50
51
52
53
# File 'lib/growsurf_ruby/resources/campaign/webhooks.rb', line 44

def create(id, params)
  parsed, options = GrowsurfRuby::Campaign::WebhookCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["campaign/%1$s/webhooks", id],
    body: parsed,
    model: GrowsurfRuby::Models::Campaign::Webhook,
    options: options
  )
end

#delete(webhook_id, id:, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::WebhookDeleteResponse

Removes a webhook by id.

Parameters:

  • webhook_id (String)

    The webhook id (primary for the program's primary webhook).

  • id (String)

    GrowSurf program ID.

  • request_options (GrowsurfRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/growsurf_ruby/resources/campaign/webhooks.rb', line 104

def delete(webhook_id, params)
  parsed, options = GrowsurfRuby::Campaign::WebhookDeleteParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["campaign/%1$s/webhooks/%2$s", id, webhook_id],
    model: GrowsurfRuby::Models::Campaign::WebhookDeleteResponse,
    options: options
  )
end

#list(id, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::WebhookListResponse

Lists a program's webhooks (secrets are never returned).

Parameters:

Returns:



16
17
18
19
20
21
22
23
# File 'lib/growsurf_ruby/resources/campaign/webhooks.rb', line 16

def list(id, params = {})
  @client.request(
    method: :get,
    path: ["campaign/%1$s/webhooks", id],
    model: GrowsurfRuby::Models::Campaign::WebhookListResponse,
    options: params[:request_options]
  )
end

#test(webhook_id, id:, event: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::WebhookTestResponse

Sends a live test event to a webhook using its stored URL and secret.

Parameters:

  • webhook_id (String)

    Path param: The webhook id (primary for the program's primary webhook).

  • id (String)

    Path param: GrowSurf program ID.

  • event (Symbol, GrowsurfRuby::Models::Campaign::WebhookEvent)

    Body param: The event to simulate. When omitted, the webhook's first enabled even

  • request_options (GrowsurfRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/growsurf_ruby/resources/campaign/webhooks.rb', line 133

def test(webhook_id, params)
  parsed, options = GrowsurfRuby::Campaign::WebhookTestParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["campaign/%1$s/webhooks/%2$s/test", id, webhook_id],
    body: parsed,
    model: GrowsurfRuby::Models::Campaign::WebhookTestResponse,
    options: options
  )
end

#update(webhook_id, id:, events: nil, is_enabled: nil, payload_url: nil, secret: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::Webhook

Updates a webhook by id.

Parameters:

  • webhook_id (String)

    Path param: The webhook id (primary for the program's primary webhook).

  • id (String)

    Path param: GrowSurf program ID.

  • events (Array<Symbol, GrowsurfRuby::Models::Campaign::WebhookEvent>)

    Body param

  • is_enabled (Boolean)

    Body param

  • payload_url (String)

    Body param

  • secret (String)

    Body param: Write-only.

  • request_options (GrowsurfRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/growsurf_ruby/resources/campaign/webhooks.rb', line 76

def update(webhook_id, params)
  parsed, options = GrowsurfRuby::Campaign::WebhookUpdateParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["campaign/%1$s/webhooks/%2$s", id, webhook_id],
    body: parsed,
    model: GrowsurfRuby::Models::Campaign::Webhook,
    options: options
  )
end