Class: Twilio::JWT::ClientCapability::OutgoingClientScope

Inherits:
Object
  • Object
show all
Includes:
Scope
Defined in:
lib/twilio-ruby/jwt/client_capability.rb

Instance Method Summary collapse

Constructor Details

#initialize(application_sid, client_name = nil, params = {}) ⇒ OutgoingClientScope

Returns a new instance of OutgoingClientScope.



60
61
62
63
64
# File 'lib/twilio-ruby/jwt/client_capability.rb', line 60

def initialize(application_sid, client_name = nil, params = {})
  @application_sid = application_sid
  @client_name = client_name
  @params = params
end

Instance Method Details

#_generate_payloadObject



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/twilio-ruby/jwt/client_capability.rb', line 66

def _generate_payload
  prefix = 'scope:client:outgoing'
  application_sid = "appSid=#{CGI.escape(@application_sid)}"
  unless @client_name.nil?
    client_name = "clientName=#{CGI.escape(@client_name)}"
  end
  unless @params.empty?
    params = 'appParams=' + @params.map { |k, v| CGI.escape("#{k}=#{v}") }.join(CGI.escape('&'))
  end

  suffix = [application_sid, client_name, params].compact.join('&')
  [prefix, suffix].join('?')
end