Class: OmniAuth::Strategies::FreshBooks
- Inherits:
-
OAuth
- Object
- OAuth
- OmniAuth::Strategies::FreshBooks
- Defined in:
- lib/omniauth/strategies/freshbooks.rb
Instance Method Summary collapse
Instance Method Details
#callback_phase ⇒ Object
59 60 61 62 |
# File 'lib/omniauth/strategies/freshbooks.rb', line 59 def callback_phase ..site = session["oauth"][name.to_s]["site"] if session["oauth"].present? super end |
#raw_info ⇒ Object
64 65 66 |
# File 'lib/omniauth/strategies/freshbooks.rb', line 64 def raw_info @raw_info ||= MultiXml.parse(access_token.post("/api/2.1/xml-in", '<?xml version="1.0" encoding="utf-8"?><request method="staff.current"></request>').body).fetch("response").fetch("staff") end |
#redirect(*args) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/omniauth/strategies/freshbooks.rb', line 36 def redirect(*args) session["oauth"][name.to_s].merge!({ "site" => ..site }) super end |
#request_phase ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/omniauth/strategies/freshbooks.rb', line 43 def request_phase ..site = .site.presence || session["omniauth.params"]["site"].presence unless ..site OmniAuth::Form.build(title: (.title.presence || "FreshBooks Authentication")) do |form| form.text_field "URL", "site" end.to_response else super end rescue URI::InvalidURIError return fail!(:invalid_site) rescue Net::HTTPRetriableError return fail!(:invalid_site) end |