Sha256: 3609e02c1b317559dca5b3d01ea402b0b167b0ac9ad58fee8d3488b7e73df30f

Contents?: true

Size: 699 Bytes

Versions: 3

Compression:

Stored size: 699 Bytes

Contents

require "faraday/middleware"

module SmstoolsApi
  # @private
  module Middleware
    # @private
    module Request
      class Authorization < Faraday::Middleware

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

        attr_reader :client

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

        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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smstools_api-0.1.7 lib/smstools_api/middleware/request/authorization.rb
smstools_api-0.1.4 lib/smstools_api/middleware/request/authorization.rb
smstools_api-0.1.3 lib/smstools_api/middleware/request/authorization.rb