Sha256: 3e77bdebaaa29d9deaf339f6fe6e19c20f35fe8e8f67b5434b592bba27252f3d

Contents?: true

Size: 1023 Bytes

Versions: 1

Compression:

Stored size: 1023 Bytes

Contents

require "r6api/version"
require "httparty"

module R6API
	module UbisoftProfile
		def get_profile(username)
			self.class.get("https://api-ubiservices.ubi.com/v2/profiles?nameOnPlatform=#{username}&platformType=uplay", 
				auth_header).parsed_response
		end
	end

	module RainbowPlayer
		def get_player(platform, user_id)
			self.class.get("https://uplaywebcenter.ubi.com/v1/stats/playerStats/?game=RSIX7&locale=en-GB&platform=#{platform}&userId=" +
				"#{user_id}", auth_header).parsed_response
		end
	end

	class RainbowError < StandardError
	end

	class API
		include HTTParty
		include UbisoftProfile
		include RainbowPlayer

		attr_accessor :ubiid, :auth_token

		base_uri "https://api-ubiservices.ubi.com"

		def initialize(ubiid=nil, auth_token=nil)
			raise RainbowError, 'Missing Auth token or Ubi AppId' unless ubiid && auth_token
			@ubiid = ubiid
			@auth_token = auth_token
		end

		def auth_header
			{
				headers: {
					"Ubi-AppId" => ubiid,
					"Authorization" => auth_token
				}
			}

		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
r6api-0.1.0 lib/r6api.rb