Sha256: 4270b6a991aceca5a4021925eb1bc655097d89313e79c41b9ea847d87630659a

Contents?: true

Size: 754 Bytes

Versions: 139

Compression:

Stored size: 754 Bytes

Contents

module Services
  module Authorization
    class GetAuthorizationUri
      CALLBACK_PATH = '/oauth/callback'.freeze

      def initialize(request:)
        @request = request
      end

      def call
        check_presence_of_credentials

        ::Hubspot::OAuthHelper.authorize_url(
          client_id: ENV['HUBSPOT_CLIENT_ID'],
          redirect_uri: redirect_uri,
          scope: %w[contacts]
        )
      end

      private

      def redirect_uri
        @request.protocol + @request.host_with_port + CALLBACK_PATH
      end

      def check_presence_of_credentials
        return if ENV['HUBSPOT_CLIENT_ID'].present?

        raise(ExceptionHandler::HubspotError.new, 'Please specify HUBSPOT_CLIENT_ID in .env')
      end
    end
  end
end

Version data entries

139 entries across 21 versions & 1 rubygems

Version Path
hubspot-api-client-9.0.0 sample-apps/companies-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-9.0.0 sample-apps/contacts-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-9.0.0 sample-apps/rate-limits-redis-sample-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-9.0.0 sample-apps/oauth-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-9.0.0 sample-apps/leaky-bucket-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-9.0.0 sample-apps/retry-middleware-sample-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-9.0.0 sample-apps/timeline-events-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.1 sample-apps/oauth-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.1 sample-apps/rate-limits-redis-sample-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.1 sample-apps/companies-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.1 sample-apps/retry-middleware-sample-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.1 sample-apps/timeline-events-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.1 sample-apps/contacts-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.1 sample-apps/leaky-bucket-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.0 sample-apps/rate-limits-redis-sample-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.0 sample-apps/retry-middleware-sample-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.0 sample-apps/leaky-bucket-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.0 sample-apps/companies-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.0 sample-apps/oauth-app/app/lib/services/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.0 sample-apps/timeline-events-app/app/lib/services/authorization/get_authorization_uri.rb