Class: Authentication::Token

Inherits:
Base
  • Object
show all
Defined in:
lib/haveapi/go_client/authentication/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_version, name, desc) ⇒ Token

Returns a new instance of Token.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/haveapi/go_client/authentication/token.rb', line 19

def initialize(api_version, name, desc)
  super
  @http_header = desc[:http_header]
  @query_parameter = desc[:query_parameter]
  @resource = Resource.new(
    api_version,
    :token,
    desc[:resources][:token],
    prefix: 'auth_token'
  )
  resource.resolve_associations
end

Instance Attribute Details

#http_headerString (readonly)

HTTP header the token is sent in

Returns:

  • (String)


9
10
11
# File 'lib/haveapi/go_client/authentication/token.rb', line 9

def http_header
  @http_header
end

#query_parameterString (readonly)

Query parameter the token is sent in

Returns:

  • (String)


13
14
15
# File 'lib/haveapi/go_client/authentication/token.rb', line 13

def query_parameter
  @query_parameter
end

#resourceResource (readonly)

Resource for token manipulation

Returns:



17
18
19
# File 'lib/haveapi/go_client/authentication/token.rb', line 17

def resource
  @resource
end

Instance Method Details

#custom_actionsArray<Action>

Returns:



51
52
53
54
55
# File 'lib/haveapi/go_client/authentication/token.rb', line 51

def custom_actions
  @custom_actions ||= resource.actions.reject do |a|
    %w[request renew revoke].include?(a.name)
  end
end

#generate(gen) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/haveapi/go_client/authentication/token.rb', line 32

def generate(gen)
  ErbTemplate.render_to_if_changed(
    'authentication/token.go',
    {
      package: gen.package,
      auth: self
    },
    File.join(gen.dst, 'auth_token.go')
  )

  resource.generate(gen)
end

#request_actionAction

Returns:



46
47
48
# File 'lib/haveapi/go_client/authentication/token.rb', line 46

def request_action
  @request_action ||= resource.actions.detect { |a| a.name == 'request' }
end