## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / # # frozen_string_literal: true module Twilio module REST class Oauth < Domain class V1 < Version class TokenList < ListResource ## # Initialize the TokenList # @param [Version] version Version that contains the resource # @return [TokenList] TokenList def initialize(version) super(version) # Path Solution @solution = {} @uri = "/token" end ## # Create the TokenInstance # @param [String] grant_type Grant type is a credential representing resource # owner's authorization which can be used by client to obtain access token. # @param [String] client_sid A 34 character string that uniquely identifies this # OAuth App. # @param [String] client_secret The credential for confidential OAuth App. # @param [String] code JWT token related to the authorization code grant type. # @param [String] code_verifier A code which is generation cryptographically. # @param [String] device_code JWT token related to the device code grant type. # @param [String] refresh_token JWT token related to the refresh token grant type. # @param [String] device_id The Id of the device associated with the token # (refresh token). # @return [TokenInstance] Created TokenInstance def create(grant_type: nil, client_sid: nil, client_secret: :unset, code: :unset, code_verifier: :unset, device_code: :unset, refresh_token: :unset, device_id: :unset) data = Twilio::Values.of({ 'GrantType' => grant_type, 'ClientSid' => client_sid, 'ClientSecret' => client_secret, 'Code' => code, 'CodeVerifier' => code_verifier, 'DeviceCode' => device_code, 'RefreshToken' => refresh_token, 'DeviceId' => device_id, }) payload = @version.create('POST', @uri, data: data) TokenInstance.new(@version, payload, ) end ## # Provide a user friendly representation def to_s '#' end end class TokenPage < Page ## # Initialize the TokenPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @return [TokenPage] TokenPage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of TokenInstance # @param [Hash] payload Payload response from the API # @return [TokenInstance] TokenInstance def get_instance(payload) TokenInstance.new(@version, payload, ) end ## # Provide a user friendly representation def to_s '' end end class TokenInstance < InstanceResource ## # Initialize the TokenInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @return [TokenInstance] TokenInstance def initialize(version, payload) super(version) # Marshaled Properties @properties = { 'access_token' => payload['access_token'], 'refresh_token' => payload['refresh_token'], 'id_token' => payload['id_token'], 'refresh_token_expires_at' => Twilio.deserialize_iso8601_datetime(payload['refresh_token_expires_at']), 'access_token_expires_at' => Twilio.deserialize_iso8601_datetime(payload['access_token_expires_at']), } end ## # @return [String] Token which carries the necessary information to access a Twilio resource directly def access_token @properties['access_token'] end ## # @return [String] Token which carries the information necessary to get a new access token def refresh_token @properties['refresh_token'] end ## # @return [String] The id_token def id_token @properties['id_token'] end ## # @return [Time] The RFC 2822 date and time in GMT when the refresh token expires def refresh_token_expires_at @properties['refresh_token_expires_at'] end ## # @return [Time] The RFC 2822 date and time in GMT when the access token expires def access_token_expires_at @properties['access_token_expires_at'] end ## # Provide a user friendly representation def to_s "" end ## # Provide a detailed, user friendly representation def inspect "" end end end end end end