class_name RequestFactory
extends Object

const headers = [
	"Content-Type: application/json",
	"Authentication: Bearer " + Config.Secrets.ApiToken
]
const api_base_path = "/api/v2"
var base_uri: String

func _init(base_uri: String):
	self.base_uri = base_uri + api_base_path

func new_submit_request(score: Score) -> ApiRequest:
	score.ValKey = score.valKey()
	var body = JSON.stringify(score)
	print(body)
	return ApiRequest.new(self.base_uri + "/score/submit/" + Config.ProjectName.to_lower(), self.headers, HTTPClient.METHOD_POST, body)

func new_list_request(key: String, offset: int = 0, limit: int = -1) -> ApiRequest:
	return ApiRequest.new(
		self.base_uri + "/score/list/" + Config.ProjectName.to_lower() + "?key=" + key + "&offset=" + str(offset) + "&limit=" + str(limit), 
		self.headers, HTTPClient.METHOD_GET)
