Class: Twilio::REST::Api::V2010::AccountContext::TokenList

Inherits:
ListResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/token.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid: nil) ⇒ TokenList

Initialize the TokenList

Parameters:

  • version (Version)

    Version that contains the resource



28
29
30
31
32
33
34
35
# File 'lib/twilio-ruby/rest/api/v2010/account/token.rb', line 28

def initialize(version, account_sid: nil)
    super(version)
    
    # Path Solution
    @solution = { account_sid:  }
    @uri = "/Accounts/#{@solution[:account_sid]}/Tokens.json"
    
end

Instance Method Details

#create(ttl: :unset) ⇒ TokenInstance

Create the TokenInstance

Parameters:

  • ttl (String) (defaults to: :unset)

    The duration in seconds for which the generated credentials are valid. The default value is 86400 (24 hours).

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/twilio-ruby/rest/api/v2010/account/token.rb', line 40

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)
    TokenInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
    )
end

#create_with_metadata(ttl: :unset) ⇒ TokenInstance

Create the TokenInstanceMetadata

Parameters:

  • ttl (String) (defaults to: :unset)

    The duration in seconds for which the generated credentials are valid. The default value is 86400 (24 hours).

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/twilio-ruby/rest/api/v2010/account/token.rb', line 66

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)
    token_instance = TokenInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
    )
    .new(
        @version,
        token_instance,
        response.headers,
        response.status_code
    )
end

#to_sObject

Provide a user friendly representation



98
99
100
# File 'lib/twilio-ruby/rest/api/v2010/account/token.rb', line 98

def to_s
    '#<Twilio.Api.V2010.TokenList>'
end