Class: SmsRu::Callbacks

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_ru/callbacks.rb

Overview

Manages callback (webhook) URLs that SMS.ru notifies with delivery statuses. Reached via SmsRu#callbacks, e.g. ‘client.callbacks.add(“https://…”)`. Each method returns the full Array of registered URLs after the change.

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Callbacks

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 Callbacks.

Parameters:

  • request (Method)

    the client’s bound ‘request` method



10
11
12
# File 'lib/sms_ru/callbacks.rb', line 10

def initialize(request)
  @request = request
end

Instance Method Details

#add(url) ⇒ Array<String>

Registers a callback URL.

Parameters:

  • url (String)

    the webhook URL to register

Returns:

  • (Array<String>)

    all registered URLs after the change

Raises:



19
# File 'lib/sms_ru/callbacks.rb', line 19

def add(url) = urls(@request.call("/callback/add", url: url))

#listArray<String>

Lists the registered callback URLs.

Returns:

  • (Array<String>)

    all registered URLs

Raises:



32
# File 'lib/sms_ru/callbacks.rb', line 32

def list = urls(@request.call("/callback/get"))

#remove(url) ⇒ Array<String>

Removes a callback URL.

Parameters:

  • url (String)

    the webhook URL to remove

Returns:

  • (Array<String>)

    all registered URLs after the change

Raises:



26
# File 'lib/sms_ru/callbacks.rb', line 26

def remove(url) = urls(@request.call("/callback/del", url: url))