Sha256: d740f55aedecf2a07af6ec9f28744cd0ef2db86e0b6d56d1706e67c586e4a40f

Contents?: true

Size: 838 Bytes

Versions: 1

Compression:

Stored size: 838 Bytes

Contents

require "omniauth-oauth"
require "multi_xml"

module OmniAuth
  module Strategies

    class MapMyHike < OmniAuth::Strategies::OAuth
      option :name, "mapmyhike"

      option :client_options, {
        :site => "http://api.mapmyfitness.com/3.1"
      }

      uid { raw_info['result']['output']['user']['user_id'] }

      info do
        {
          :email => raw_info['result']['output']['user']['email'],
          :first_name => raw_info['result']['output']['user']['first_name'],
          :last_name => raw_info['result']['output']['user']['last_name']
        }
      end

      extra do
        { 'raw_info' => raw_info }
      end

      def raw_info
        @raw_info ||= MultiXml.parse(access_token.get("/users/get_user?o=xml").body)
      end

    end

  end
end

OmniAuth.config.add_camelization 'mapmyhike', 'MapMyHike'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-mapmyhike-0.1.1 lib/omniauth/strategies/mapmyhike.rb