Class: Twilio::REST::Verify::V2::ServiceContext::EntityContext::ChallengeContext::NotificationList

Inherits:
ListResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid: nil, identity: nil, challenge_sid: nil) ⇒ NotificationList

Initialize the NotificationList

Parameters:

  • Version that contains the resource



30
31
32
33
34
35
36
37
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb', line 30

def initialize(version, service_sid: nil, identity: nil, challenge_sid: nil)
    super(version)
    
    # Path Solution
    @solution = { service_sid: service_sid, identity: identity, challenge_sid: challenge_sid }
    @uri = "/Services/#{@solution[:service_sid]}/Entities/#{@solution[:identity]}/Challenges/#{@solution[:challenge_sid]}/Notifications"
    
end

Instance Method Details

#create(ttl: :unset) ⇒ NotificationInstance

Create the NotificationInstance

Parameters:

  • (defaults to: :unset)

    How long, in seconds, the notification is valid. Can be an integer between 0 and 300. Default is 300. Delivery is attempted until the TTL elapses, even if the device is offline. 0 means that the notification delivery is attempted immediately, only once, and is not stored for future delivery.

Returns:

  • Created NotificationInstance



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb', line 42

def create(
    ttl: :unset
)

    data = Twilio::Values.of({
        'Ttl' => ttl,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.create('POST', @uri, data: data, headers: headers)
    NotificationInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        challenge_sid: @solution[:challenge_sid],
    )
end

#create_with_metadata(ttl: :unset) ⇒ NotificationInstance

Create the NotificationInstanceMetadata

Parameters:

  • (defaults to: :unset)

    How long, in seconds, the notification is valid. Can be an integer between 0 and 300. Default is 300. Delivery is attempted until the TTL elapses, even if the device is offline. 0 means that the notification delivery is attempted immediately, only once, and is not stored for future delivery.

Returns:

  • Created NotificationInstance



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb', line 70

def (
  ttl: :unset
)

    data = Twilio::Values.of({
        'Ttl' => ttl,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    notification_instance = NotificationInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        challenge_sid: @solution[:challenge_sid],
    )
    .new(
        @version,
        notification_instance,
        response.headers,
        response.status_code
    )
end

#to_sObject

Provide a user friendly representation



104
105
106
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb', line 104

def to_s
    '#<Twilio.Verify.V2.NotificationList>'
end