Class: LedgerSync::QuickBooksOnline::OAuthClient::RedirectURIParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ledger_sync/quickbooks_online/oauth_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri:) ⇒ RedirectURIParser

Returns a new instance of RedirectURIParser.



13
14
15
# File 'lib/ledger_sync/quickbooks_online/oauth_client.rb', line 13

def initialize(uri:)
  @uri = uri
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



11
12
13
# File 'lib/ledger_sync/quickbooks_online/oauth_client.rb', line 11

def uri
  @uri
end

Instance Method Details

#codeObject



17
18
19
# File 'lib/ledger_sync/quickbooks_online/oauth_client.rb', line 17

def code
  @code ||= query.fetch('code').first
end

#parsed_uriObject



21
22
23
# File 'lib/ledger_sync/quickbooks_online/oauth_client.rb', line 21

def parsed_uri
  @parsed_uri = URI.parse(uri)
end

#queryObject



25
26
27
# File 'lib/ledger_sync/quickbooks_online/oauth_client.rb', line 25

def query
  @query ||= CGI.parse(parsed_uri.query)
end

#realm_idObject



29
30
31
# File 'lib/ledger_sync/quickbooks_online/oauth_client.rb', line 29

def realm_id
  @realm_id ||= query.fetch('realmId').first
end

#redirect_uriObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/ledger_sync/quickbooks_online/oauth_client.rb', line 33

def redirect_uri
  @redirect_uri ||= begin
    use_uri = parsed_uri.dup
    use_uri.fragment = nil
    use_uri.query = nil
    ret = use_uri.to_s
    ret = ret[0..-2] if ret.end_with?('/')
    ret
  end
end