Class: Trello::Authorization::BasicAuthPolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/trello/authorization.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ BasicAuthPolicy

Returns a new instance of BasicAuthPolicy.



26
27
28
29
# File 'lib/trello/authorization.rb', line 26

def initialize(attrs = {})
  @developer_public_key = attrs[:developer_public_key]  || self.class.developer_public_key
  @member_token         = attrs[:member_token]          || self.class.member_token
end

Class Attribute Details

.developer_public_keyObject

Returns the value of attribute developer_public_key.



17
18
19
# File 'lib/trello/authorization.rb', line 17

def developer_public_key
  @developer_public_key
end

.member_tokenObject

Returns the value of attribute member_token.



17
18
19
# File 'lib/trello/authorization.rb', line 17

def member_token
  @member_token
end

Instance Attribute Details

#developer_public_keyObject

Returns the value of attribute developer_public_key.



24
25
26
# File 'lib/trello/authorization.rb', line 24

def developer_public_key
  @developer_public_key
end

#member_tokenObject

Returns the value of attribute member_token.



24
25
26
# File 'lib/trello/authorization.rb', line 24

def member_token
  @member_token
end

Class Method Details

.authorize(request) ⇒ Object



19
20
21
# File 'lib/trello/authorization.rb', line 19

def authorize(request)
  new.authorize(request)
end

Instance Method Details

#authorize(request) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/trello/authorization.rb', line 31

def authorize(request)
  the_uri = Addressable::URI.parse(request.uri)
  existing_values = the_uri.query_values.nil? ? {} : the_uri.query_values
  new_values = { key: @developer_public_key, token: @member_token }
  the_uri.query_values = new_values.merge existing_values

  Request.new request.verb, the_uri, request.headers, request.body
end