Class: SmstoolsApi::Middleware::Request::Authorization
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- SmstoolsApi::Middleware::Request::Authorization
- 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
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, client) ⇒ Authorization
constructor
A new instance of Authorization.
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
#client ⇒ Object (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 |