Sha256: 694bab0d6109c6e0dd97361965d19d4f47358b0927b181a3b9a9a92e234c014f

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class BookingSync < OmniAuth::Strategies::OAuth2
      option :name, 'bookingsync'

      option :client_options, {
        :site => 'https://www.bookingsync.com/'
      }

      uid { raw_info["id"] }

      info do
        {
          :business_name => raw_info['business_name']
        }
      end

      def raw_info
        @raw_info ||= access_token.get('/api/v3/accounts').parsed['accounts'].first
      end

      def authorize_params
        super.tap do |params|
          if request.params["account_id"]
            params[:account_id] = request.params["account_id"]
          end
        end
      end
    end
  end
end

OAuth2::Response::CONTENT_TYPES['application/vnd.api+json'] ||= :json

OmniAuth.config.add_camelization 'bookingsync', 'BookingSync'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-bookingsync-0.2.0 lib/omniauth/strategies/bookingsync.rb