Class: Twilio::REST::Verify::V2::ServiceContext::AccessTokenList

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

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid: nil) ⇒ AccessTokenList

Initialize the AccessTokenList

Parameters:

  • version (Version)

    Version that contains the resource



28
29
30
31
32
33
34
35
# File 'lib/twilio-ruby/rest/verify/v2/service/access_token.rb', line 28

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

Instance Method Details

#create(identity: nil, factor_type: nil, factor_friendly_name: :unset, ttl: :unset) ⇒ AccessTokenInstance

Create the AccessTokenInstance

Parameters:

  • identity (String) (defaults to: nil)

    The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, and generated by your external system, such as your user’s UUID, GUID, or SID.

  • factor_type (FactorTypes) (defaults to: nil)
  • factor_friendly_name (String) (defaults to: :unset)

    The friendly name of the factor that is going to be created with this access token

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

    How long, in seconds, the access token is valid. Can be an integer between 60 and 300. Default is 60.

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/twilio-ruby/rest/verify/v2/service/access_token.rb', line 43

def create(
    identity: nil, 
    factor_type: nil, 
    factor_friendly_name: :unset, 
    ttl: :unset
)

    data = Twilio::Values.of({
        'Identity' => identity,
        'FactorType' => factor_type,
        'FactorFriendlyName' => factor_friendly_name,
        'Ttl' => ttl,
    })

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

#create_with_metadata(identity: nil, factor_type: nil, factor_friendly_name: :unset, ttl: :unset) ⇒ AccessTokenInstance

Create the AccessTokenInstanceMetadata

Parameters:

  • identity (String) (defaults to: nil)

    The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, and generated by your external system, such as your user’s UUID, GUID, or SID.

  • factor_type (FactorTypes) (defaults to: nil)
  • factor_friendly_name (String) (defaults to: :unset)

    The friendly name of the factor that is going to be created with this access token

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

    How long, in seconds, the access token is valid. Can be an integer between 60 and 300. Default is 60.

Returns:



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/twilio-ruby/rest/verify/v2/service/access_token.rb', line 78

def (
  identity: nil, 
  factor_type: nil, 
  factor_friendly_name: :unset, 
  ttl: :unset
)

    data = Twilio::Values.of({
        'Identity' => identity,
        'FactorType' => factor_type,
        'FactorFriendlyName' => factor_friendly_name,
        'Ttl' => ttl,
    })

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

#to_sObject

Provide a user friendly representation



116
117
118
# File 'lib/twilio-ruby/rest/verify/v2/service/access_token.rb', line 116

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