Class: ZendeskAPI::Middleware::Request::UrlBasedAccessToken

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/zendesk_api/middleware/request/url_based_access_token.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, token) ⇒ UrlBasedAccessToken

Returns a new instance of UrlBasedAccessToken


7
8
9
10
# File 'lib/zendesk_api/middleware/request/url_based_access_token.rb', line 7

def initialize(app, token)
  super(app)
  @token = token
end

Instance Method Details

#call(env) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/zendesk_api/middleware/request/url_based_access_token.rb', line 12

def call(env)
  if env[:url].query
    env[:url].query += '&'
  else
    env[:url].query = ''
  end

  env[:url].query += "access_token=#{@token}"

  @app.call(env)
end