Class: SmstoolsApi::Middleware::Request::Authorization

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

Constant Summary collapse

ACCEPT =
"accept".freeze
CLIENTID =
"x-client-id".freeze
CLIENTSECRET =
"X-Client-Secret".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, client) ⇒ Authorization

Returns a new instance of Authorization.



16
17
18
19
# File 'lib/smstools_api/middleware/request/authorization.rb', line 16

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

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



14
15
16
# File 'lib/smstools_api/middleware/request/authorization.rb', line 14

def client
  @client
end

Instance Method Details

#call(env) ⇒ Object



21
22
23
24
25
26
# File 'lib/smstools_api/middleware/request/authorization.rb', line 21

def call(env)
  env.request_headers[ACCEPT] = "application/json"
  env.request_headers[CLIENTID] = client.config.client_id
  env.request_headers[CLIENTSECRET] = client.config.client_secret
  @app.call(env)
end