Sha256: 7b09bc557505040676c52d4386fc6f6a8959b48749b18794f888bd7373e93eb0

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class Cronofy < OmniAuth::Strategies::OAuth2
      option :name, "cronofy"

      def self.api_url
        @api_url ||= (ENV['CRONOFY_API_URL'] || "https://api.cronofy.com")
      end

      def self.api_url=(value)
        @api_url = value
      end

      def self.app_url
        @app_url ||= (ENV['CRONOFY_APP_URL'] || "https://app.cronofy.com")
      end

      def self.app_url=(value)
        @app_url = value
      end

      option :client_options, {
        :site => ::OmniAuth::Strategies::Cronofy.app_url
      }

      uid{ raw_info['account_id'] }

      info do
        {
          :email => raw_info['email'],
          :name => raw_info['name']
        }
      end

      extra do
        {
          'raw_info' => raw_info,
          'linking_profile' => access_token['linking_profile'],
        }
      end

      def raw_info
        @raw_info ||= access_token.get("#{::OmniAuth::Strategies::Cronofy.api_url}/v1/account").parsed['account']
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-cronofy-0.3.0 lib/omniauth/strategies/cronofy.rb