/**
 * Nudr_DataRepository API OpenAPI file
 * Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB,
 * ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
 *
 * The version of the OpenAPI document: 2.1.2
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator
 * (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
 * the class manually.
 */

#include "AMF3GPPAccessRegistrationDocumentApiImpl.h"

#include "logger.hpp"
#include "udr_app.hpp"
#include "udr_config.hpp"
using namespace config;
extern config::udr_config udr_cfg;
namespace oai::udr::api {

using namespace oai::udr::model;

AMF3GPPAccessRegistrationDocumentApiImpl::
    AMF3GPPAccessRegistrationDocumentApiImpl(
        std::shared_ptr<Pistache::Rest::Router> rtr, udr_app *udr_app_inst,
        std::string address)
    : AMF3GPPAccessRegistrationDocumentApi(rtr),
      m_udr_app(udr_app_inst),
      m_address(address) {}

void AMF3GPPAccessRegistrationDocumentApiImpl::amf_context3gpp(
    const std::string &ueId, const std::vector<PatchItem> &patchItem,
    const Pistache::Optional<std::string> &supportedFeatures,
    Pistache::Http::ResponseWriter &response) {
  /************************ test ************************/
  nlohmann::json j, j1;
  for (int i = 0; i < patchItem.size(); i++) {
    to_json(j1, patchItem[i]);
    j += j1;
  }
  response.send(Pistache::Http::Code::Ok, j.dump());
  /******************************************************/
}
void AMF3GPPAccessRegistrationDocumentApiImpl::create_amf_context3gpp(
    const std::string &ueId,
    Amf3GppAccessRegistration &amf3GppAccessRegistration,
    Pistache::Http::ResponseWriter &response) {
  nlohmann::json response_data = {};
  Pistache::Http::Code code = {};
  m_udr_app->handle_create_amf_context_3gpp(ueId, amf3GppAccessRegistration,
                                            response_data, code);

  Logger::udr_server().debug("HTTP reponse code %d.\n", code);
  response.send(code, response_data.dump());
}
void AMF3GPPAccessRegistrationDocumentApiImpl::query_amf_context3gpp(
    const std::string &ueId,
    const Pistache::Optional<std::vector<std::string>> &fields,
    const Pistache::Optional<std::string> &supportedFeatures,
    Pistache::Http::ResponseWriter &response) {
  nlohmann::json response_data = {};
  Pistache::Http::Code code = {};
  m_udr_app->handle_query_amf_context_3gpp(ueId, response_data, code);

  Logger::udr_server().debug("HTTP reponse code %d.\n", code);
  response.send(code, response_data.dump());
}

}  // namespace oai::udr::api