친구 요청 수락
대기 중인 친구 요청을 수락합니다.
URL 확인
이 API는 service-api.playnanoo.com 도메인을 사용합니다.
API 정보
- URL:
https://service-api.playnanoo.com/friend/v20231201/accept - Method:
PUT - 인증 필요: 예
DeviceInfo 상속
이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.
요청 파라미터
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| table_code | string | 필수 | 친구 테이블 코드 |
| relationship_code | string | 필수 | 수락할 친구 요청의 관계 코드 |
응답 데이터
Res 클래스
| 필드 | 타입 | 설명 |
|---|---|---|
| Status | string | 처리 결과 상태 |
Unity C# 구현
BaseResponse 클래스
모든 API 응답의 기본 클래스입니다.
public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}
필드 설명:
ErrorCode: 에러 코드Message: 에러 메시지WithdrawalKey: 탈퇴 유예 상태인 경우 복구에 필요한 키 (탈퇴 유예 중인 계정만 제공)BlockKey: 차단된 계정인 경우 제공되는 키 (차단된 계정만 제공)
친구 요청 수락 클래스
using System;
using System.Collections;
using UnityEngine.Networking;
public class FriendAccept
{
static string path = $"https://service-api.playnanoo.com/friend/v20231201/accept";
[Serializable]
public class Req : DeviceInfo
{
public string table_code;
public string relationship_code;
public IEnumerator Send(string tableCode, string relationshipCode, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(tableCode)) this.table_code = tableCode;
if (!string.IsNullOrEmpty(relationshipCode)) this.relationship_code = relationshipCode;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public string Status;
}
}
사용 예제
using PlayNANOO;
public class PlayNANOOExample : MonoBehaviour
{
void AcceptFriendRequest(string relationshipCode)
{
FriendAccept.Req req = new FriendAccept.Req();
StartCoroutine(req.Send(
tableCode: "friend_table",
relationshipCode: relationshipCode,
onSuccess: res =>
{
Debug.Log($"친구 요청 수락 성공: {res.Status}");
ShowMessage("친구가 되었습니다!");
},
onError: (error) =>
{
Debug.LogError($"친구 요청 수락 실패: [{error.ErrorCode}] [{error.Message}]");
ShowMessage("친구 요청 수락에 실패했습니다.");
}
));
}
void ShowMessage(string message)
{
// UI 메시지 표시
Debug.Log(message);
}
}
RelationshipCode
RelationshipCode는 대기 중인 친구 요청 조회 API (searchPending)를 통해 얻을 수 있습니다.
친구 목록 갱신
친구 요청을 수락한 후에는 친구 목록을 다시 조회하여 UI를 업데이트하는 것이 좋습니다.