import { ParameterUtil, APIEncoder, APIDecoder } from '@ucap-webmessenger/api';

import { PIRequest, PIResponse } from './pi';
import { DeviceType } from '@ucap-webmessenger/core';

export interface UserTermsActionRequest extends PIRequest {
  userSeq: number;
  token: string;
  deviceType: DeviceType;
}

// tslint:disable-next-line: no-empty-interface
export interface UserTermsActionResponse extends PIResponse {
  responseCode?: string;
  responseMsg?: string;
}

const userTermsActionEncodeMap = {
  userSeq: 'userSeq',
  token: 'tokenKey',
  deviceType: 'deviceType'
};

export const encodeUserTermsAction: APIEncoder<UserTermsActionRequest> = (
  req: UserTermsActionRequest
) => {
  return ParameterUtil.encode(userTermsActionEncodeMap, req);
};

export const decodeUserTermsAction: APIDecoder<UserTermsActionResponse> = (
  res: any
) => {
  return {
    responseCode: res.responseCode,
    responseMsg: res.responseMsg
  } as UserTermsActionResponse;
};
