package com.yutou.okhttp;


import okhttp3.HttpUrl;
import okhttp3.Request;

import java.util.HashMap;

public class GetRequestParams implements IRequestParam {
    /**
     * 构建Request
     *
     * @param request
     * @return
     */
    @Override
    public Request getRequest(HashMap<String, String> map, Request request) {
        //添加公共参数
        HttpUrl.Builder builder = request.url().newBuilder();
        for (String key : map.keySet()) {
            builder.addQueryParameter(key, String.valueOf(map.get(key)));
        }
        return request.newBuilder().url(builder.build()).build();
    }
}