Class: Authentication::Token
- Inherits:
-
Base
- Object
- Base
- Authentication::Token
- Defined in:
- lib/haveapi/go_client/authentication/token.rb
Instance Attribute Summary collapse
-
#http_header ⇒ String
readonly
HTTP header the token is sent in.
-
#query_parameter ⇒ String
readonly
Query parameter the token is sent in.
-
#resource ⇒ Resource
readonly
Resource for token manipulation.
Instance Method Summary collapse
- #custom_actions ⇒ Array<Action>
- #generate(gen) ⇒ Object
-
#initialize(api_version, name, desc) ⇒ Token
constructor
A new instance of Token.
- #request_action ⇒ Action
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_header ⇒ String (readonly)
HTTP header the token is sent in
9 10 11 |
# File 'lib/haveapi/go_client/authentication/token.rb', line 9 def http_header @http_header end |
#query_parameter ⇒ String (readonly)
Query parameter the token is sent in
13 14 15 |
# File 'lib/haveapi/go_client/authentication/token.rb', line 13 def query_parameter @query_parameter end |
#resource ⇒ Resource (readonly)
Resource for token manipulation
17 18 19 |
# File 'lib/haveapi/go_client/authentication/token.rb', line 17 def resource @resource end |
Instance Method Details
#custom_actions ⇒ Array<Action>
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_action ⇒ Action
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 |