Class: Vonage::Messaging

Inherits:
Namespace
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/vonage/messaging.rb

Defined Under Namespace

Classes: Message

Instance Method Summary collapse

Instance Method Details

#send(to:, from:, **message) ⇒ Object

Send a Message.

Examples:

message = client.messaging.sms(message: "Hello world!")
response = client.messaging.send(to: "447700900000", from: "447700900001", **message)

Parameters:

  • params (Hash)

    a customizable set of options

See Also:



30
31
32
# File 'lib/vonage/messaging.rb', line 30

def send(to:, from:, **message)
  request('/v1/messages', params: {to: to, from: from, **message}, type: Post)
end

#update(message_uuid:, **params) ⇒ Object

Update a Message Object.

‘:message_uuid` is always required. Other parameters will depend on the message channel and the specific action being performed.

Examples:

message = client.messaging.update(message_uuid: "aaaaaaaa-bbbb-4ccc-8ddd-0123456789ab", status: "read")

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (**params):

  • :message_uuid. (required, String)

    the UUID of the message to update.

See Also:



44
45
46
# File 'lib/vonage/messaging.rb', line 44

def update(message_uuid:, **params)
  request("/v1/messages/#{message_uuid}", params: params, type: Patch)
end

#verify_webhook_token(token:, signature_secret: @config.signature_secret) ⇒ Boolean

Validate a JSON Web Token from a Messages API Webhook.

Parameters:

  • :token (String, required)

    The JWT from the Webhook’s Authorization header

  • :signature_secret (String, optional)

    The account signature secret. Required, unless ‘signature_secret` is set in `Config`

Returns:

  • (Boolean)

    true, if the JWT is verified, false otherwise



55
56
57
# File 'lib/vonage/messaging.rb', line 55

def verify_webhook_token(token:, signature_secret: @config.signature_secret)
  JWT.verify_hs256_signature(token: token, signature_secret: signature_secret)
end