Sha256: 961ac93b1eb32587344f70fb16cc0a96b71292502f86f38f8d1188c86dcce369

Contents?: true

Size: 824 Bytes

Versions: 23

Compression:

Stored size: 824 Bytes

Contents

module Services
  module Hubspot
    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
end

Version data entries

23 entries across 12 versions & 1 rubygems

Version Path
hubspot-api-client-9.0.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-9.0.0 sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.1 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.1 sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.0 sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-8.0.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-7.3.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-7.3.0 sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-7.2.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-7.2.0 sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-7.1.1 sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-7.1.1 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-7.1.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-7.1.0 sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-7.0.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-7.0.0 sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-6.0.0 sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-6.0.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-5.0.0 sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb
hubspot-api-client-5.0.0 sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb