Class: SimpleSpark::Endpoints::RelayWebhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_spark/endpoints/relay_webhooks.rb

Overview

Provides access to the /relay-webhooks endpoint See: developers.sparkpost.com/api/#/reference/relay-webhooks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ RelayWebhooks

Returns a new instance of RelayWebhooks.



8
9
10
# File 'lib/simple_spark/endpoints/relay_webhooks.rb', line 8

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/simple_spark/endpoints/relay_webhooks.rb', line 6

def client
  @client
end

Instance Method Details

#create(values) ⇒ Object

Note:

Example:

Create a relay webhook properties = {

name: "Replies Webhook",
target: "https://webhooks.customer.example/replies",
auth_token: "",
match: {
  protocol: "SMTP",
  domain: "email.example.com"
}

}

Parameters:

  • values (Hash)

    the values to create with



32
33
34
# File 'lib/simple_spark/endpoints/relay_webhooks.rb', line 32

def create(values)
  @client.call(method: :post, path: 'relay-webhooks', body_values: values)
end

#delete(webhook_id) ⇒ Object

Parameters:

  • webhook_id (String)

    the id to retrieve



61
62
63
# File 'lib/simple_spark/endpoints/relay_webhooks.rb', line 61

def delete(webhook_id)
  @client.call(method: :delete, path: "relay-webhooks/#{webhook_id}")
end

#listArray

Returns:

  • (Array)

    a list of Relay Webhook hash objects



15
16
17
# File 'lib/simple_spark/endpoints/relay_webhooks.rb', line 15

def list
  @client.call(method: :get, path: 'relay-webhooks')
end

#retrieve(webhook_id) ⇒ Hash

Parameters:

  • webhook_id (String)

    the id to retrieve

Returns:

  • (Hash)

    an Relay Webhook hash object



40
41
42
# File 'lib/simple_spark/endpoints/relay_webhooks.rb', line 40

def retrieve(webhook_id)
  @client.call(method: :get, path: "relay-webhooks/#{webhook_id}")
end

#update(webhook_id, values) ⇒ Hash

Note:

Example:

Update a relay webhook properties =

name: "New Replies Webhook",
target: "https://webhook.customer.example/replies"

Parameters:

  • webhook_id (String)

    the id to retrieve

  • values (Hash)

    the values to update the relay webhook with

Returns:

  • (Hash)

    an Relay Webhook hash object



54
55
56
# File 'lib/simple_spark/endpoints/relay_webhooks.rb', line 54

def update(webhook_id, values)
  @client.call(method: :put, path: "relay-webhooks/#{webhook_id}", body_values: values)
end