package com.ai.da.common.utils.paypalRequest;

import com.alibaba.fastjson.JSONObject;
import com.paypal.http.HttpRequest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.HashMap;

@Component
public class AuthenticationRequest extends HttpRequest<HashMap> {

    public AuthenticationRequest() {
        super("/v1/oauth2/token", "POST", HashMap.class);
        this.header("Content-Type", "application/x-www-form-urlencoded");
        body();
    }

    public AuthenticationRequest authorization(String clientId, String clientSecret) {
        this.header(clientId, clientSecret);
        return this;
    }

    public AuthenticationRequest body() {
        HashMap<String, String> body = new HashMap<>();
        body.put("grant_type", "client_credentials");
        this.requestBody(body);
        return this;
    }
}
