Class: Stripe::OAuthService

Inherits:
StripeService show all
Defined in:
lib/stripe/services/oauth_service.rb

Instance Method Summary collapse

Methods inherited from StripeService

#initialize, #request, #request_stream

Constructor Details

This class inherits a constructor from Stripe::StripeService

Instance Method Details

#authorize_url(params = {}, opts = {}) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/stripe/services/oauth_service.rb', line 5

def authorize_url(params = {}, opts = {})
  path = if opts[:express]
           "/express/oauth/authorize"
         else
           "/oauth/authorize"
         end

  params[:client_id] = client_id(params)

  params[:response_type] = "code" if params.include?(:response_type)

  query = Util.encode_parameters(params, :v1)

  connect_api_base = @requestor.config.base_addresses[:connect]
  raise ArgumentError, "connect_api_base cannot be empty" if connect_api_base.nil? || connect_api_base.empty?

  "#{connect_api_base}#{path}?#{query}"
end

#deauthorize(params = {}, opts = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/stripe/services/oauth_service.rb', line 37

def deauthorize(params = {}, opts = {})
  params[:client_id] = client_id(params)

  request(
    method: :post,
    path: "/oauth/deauthorize",
    params: params,
    opts: opts,
    base_address: :connect
  )
end

#token(params = {}, opts = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/stripe/services/oauth_service.rb', line 24

def token(params = {}, opts = {})
  opts = Util.normalize_opts(opts)
  opts[:api_key] = params[:client_secret] if params[:client_secret]

  request(
    method: :post,
    path: "/oauth/token",
    params: params,
    opts: opts,
    base_address: :connect
  )
end