Class: A2A::OAuthFlow::ClientCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/a2a/oauth_flow/client_credentials.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_url:, scopes:, refresh_url: nil) ⇒ ClientCredentials

Returns a new instance of ClientCredentials.



8
9
10
11
12
# File 'lib/a2a/oauth_flow/client_credentials.rb', line 8

def initialize(token_url:, scopes:, refresh_url: nil)
  @token_url = token_url
  @scopes = scopes
  @refresh_url = refresh_url
end

Instance Attribute Details

#refresh_urlObject (readonly)

Returns the value of attribute refresh_url.



6
7
8
# File 'lib/a2a/oauth_flow/client_credentials.rb', line 6

def refresh_url
  @refresh_url
end

#scopesObject (readonly)

Returns the value of attribute scopes.



6
7
8
# File 'lib/a2a/oauth_flow/client_credentials.rb', line 6

def scopes
  @scopes
end

#token_urlObject (readonly)

Returns the value of attribute token_url.



6
7
8
# File 'lib/a2a/oauth_flow/client_credentials.rb', line 6

def token_url
  @token_url
end

Class Method Details

.from_h(hash) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/a2a/oauth_flow/client_credentials.rb', line 14

def self.from_h(hash)
  new(
    scopes: hash.fetch("scopes"),
    token_url: hash.fetch("tokenUrl"),
    refresh_url: hash["refreshUrl"]
  )
end

Instance Method Details

#to_hObject



22
23
24
25
26
27
28
# File 'lib/a2a/oauth_flow/client_credentials.rb', line 22

def to_h
  {
    "tokenUrl" => token_url,
    "scopes" => scopes,
    "refreshUrl" => refresh_url
  }.compact
end