Skip to content

Commit

Permalink
YEL-220 [feat] 명세서 업로드
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonjeongs committed Feb 16, 2024
1 parent 4b2bc7d commit 7a9309f
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 80 deletions.
40 changes: 8 additions & 32 deletions src/docs/asciidoc/check-is-possible-admob.adoc
Original file line number Diff line number Diff line change
@@ -1,52 +1,28 @@
:reproducible:
== 상점에서 보상형 광고 가능한지 여부 (명세)
== 상점에서 보상형 광고 가능한지 여부

=== 요청

[http,json]
----
GET /api/v1/admob/{tag} HTTP/1.1
Authorization: Bearer your-access-token
Content-Type: application/json
----
include::{snippets}/api/v1/admob/possible/http-request.adoc[]

=== 요청 파라미터

include::{snippets}/api/v1/admob/possible/path-parameters.adoc[]

----
tag -> shop
tag -> ADMOB_POINT
----
* 보상형 광고 다른곳에서 사용할 수도 있으므로 tag로 어떤 곳에서 사용하고 있는곳인지 tag로 명시
* 현재는 상점 -> shop에서만 보상형 광고 진행
* 현재는 상점에 있는 보상형 광고 (ADMOB_POINT를 tag에 요청)

=== 응답

[http,json]
----
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json
{
"status" : 200,
"message" : "광고 보고 포인트 얻기 가능 여부 조회에 성공했습니다.",
"data": {
"createdAt": "2024-01-01 12:00:00",
"isPossible" : true,
}
}
----

include::{snippets}/api/v1/admob/possible/http-response.adoc[]

=== NOTE

- Header에 무작위한 UUID4 값을 넣어주세요
* 예시) IdempotencyKey: 0397b5f3-ecdc-47d6-b5d7-2b1afcf00e87
- 주의사항
* 같은 멱등성키를 2번 요청하면, 400번 에러.
- ADMOB
* ADMOB 서버에 SSV(ServerSideVerification) Options의 customData에 입력한 것과 동일한 멱등성 키를 넘겨주세요.

=== CHANGELOG

- 2024.02.17 API 릴리즈
- 2024.02.16 명세서 작성
2 changes: 1 addition & 1 deletion src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@

* 🆕 link:reward-admob.html[광고보고 보상 얻기, 2024-02-11]

* 🆕 link:check-is-possible-admob.adoc[광고보고 보상 얻기 가능 여부 조회, 2024-02-16 (명세)]
* 🆕 link:check-is-possible-admob.adoc[광고보고 보상 얻기 가능 여부 조회, 2024-02-17]
82 changes: 36 additions & 46 deletions src/main/resources/static/docs/check-is-possible-admob.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.18">
<title>상점에서 보상형 광고 가능한지 여부 (명세)</title>
<title>상점에서 보상형 광고 가능한지 여부</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<style>
/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
Expand Down Expand Up @@ -441,23 +441,42 @@
</div>
<div id="content">
<div class="sect1">
<h2 id="_상점에서_보상형_광고_가능한지_여부_명세">상점에서 보상형 광고 가능한지 여부 (명세)</h2>
<h2 id="_상점에서_보상형_광고_가능한지_여부">상점에서 보상형 광고 가능한지 여부</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_요청">요청</h3>
<div class="listingblock">
<div class="content">
<pre>GET /api/v1/admob/{tag} HTTP/1.1
Authorization: Bearer your-access-token
Content-Type: application/json</pre>
<pre class="highlight nowrap"><code class="language-http" data-lang="http">GET /api/v1/admob/possible/ADMOB_POINT HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer your-access-token</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_요청_파라미터">요청 파라미터</h3>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 1. /api/v1/admob/possible/{tag}</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Parameter</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>tag</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">보상형 광고의 종류</p></td>
</tr>
</tbody>
</table>
<div class="listingblock">
<div class="content">
<pre>tag -&gt; shop</pre>
<pre>tag -&gt; ADMOB_POINT</pre>
</div>
</div>
<div class="ulist">
Expand All @@ -466,7 +485,7 @@ <h3 id="_요청_파라미터">요청 파라미터</h3>
<p>보상형 광고 다른곳에서 사용할 수도 있으므로 tag로 어떤 곳에서 사용하고 있는곳인지 tag로 명시</p>
</li>
<li>
<p>현재는 상점 &#8594; shop에서만 보상형 광고 진행</p>
<p>현재는 상점에 있는 보상형 광고 (ADMOB_POINT를 tag에 요청)</p>
</li>
</ul>
</div>
Expand All @@ -475,64 +494,35 @@ <h3 id="_요청_파라미터">요청 파라미터</h3>
<h3 id="_응답">응답</h3>
<div class="listingblock">
<div class="content">
<pre>HTTP/1.1 200 OK
<pre class="highlight nowrap"><code class="language-http" data-lang="http">HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json

{
"status" : 200,
"message" : "광고 보고 포인트 얻기 가능 여부 조회에 성공했습니다.",
"data": {
"createdAt": "2024-01-01 12:00:00",
"isPossible" : true,
"data" : {
"createdAt" : "2024-01-10 01:12:00",
"isPossible" : true
}
}</pre>
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_note">NOTE</h3>
<div class="ulist">
<ul>
<li>
<p>Header에 무작위한 UUID4 값을 넣어주세요</p>
<div class="ulist">
<ul>
<li>
<p>예시) IdempotencyKey: 0397b5f3-ecdc-47d6-b5d7-2b1afcf00e87</p>
</li>
</ul>
</div>
</li>
<li>
<p>주의사항</p>
<div class="ulist">
<ul>
<li>
<p>같은 멱등성키를 2번 요청하면, 400번 에러.</p>
</li>
</ul>
</div>
</li>
<li>
<p>ADMOB</p>
<div class="ulist">
<ul>
<li>
<p>ADMOB 서버에 SSV(ServerSideVerification) Options의 customData에 입력한 것과 동일한 멱등성 키를 넘겨주세요.</p>
</li>
</ul>
</div>
</li>
</ul>
</div>

</div>
<div class="sect2">
<h3 id="_changelog">CHANGELOG</h3>
<div class="ulist">
<ul>
<li>
<p>2024.02.17 API 릴리즈</p>
</li>
<li>
<p>2024.02.16 명세서 작성</p>
</li>
</ul>
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/static/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,9 @@ <h3 id="_event_api"><a class="link" href="#_event_api">Event API</a></h3>
<li>
<p>🆕 <a href="reward-admob.html">광고보고 보상 얻기, 2024-02-11</a></p>
</li>
<li>
<p>🆕 <a href="check-is-possible-admob.adoc">광고보고 보상 얻기 가능 여부 조회, 2024-02-16 (명세)</a></p>
</li>
</ul>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;

Expand All @@ -22,20 +24,28 @@
import com.yello.server.domain.event.dto.request.EventJoinRequest;
import com.yello.server.domain.event.dto.response.EventResponse;
import com.yello.server.domain.event.dto.response.EventRewardResponse;
import com.yello.server.domain.event.dto.response.GetIsPossibleAdmob;
import com.yello.server.domain.event.entity.Event;
import com.yello.server.domain.event.entity.EventRandom;
import com.yello.server.domain.event.entity.EventReward;
import com.yello.server.domain.event.entity.EventRewardMapping;
import com.yello.server.domain.event.entity.EventTime;
import com.yello.server.domain.event.service.EventService;
import com.yello.server.domain.group.entity.UserGroup;
import com.yello.server.domain.group.entity.UserGroupType;
import com.yello.server.domain.user.entity.User;
import com.yello.server.domain.user.entity.UserData;
import com.yello.server.domain.user.entity.UserDataType;
import com.yello.server.global.common.util.ConstantUtil;
import com.yello.server.global.exception.ControllerExceptionAdvice;
import com.yello.server.util.TestDataEntityUtil;
import com.yello.server.util.TestDataUtil;
import com.yello.server.util.WithAccessTokenUser;
import java.time.LocalDateTime;
import java.time.OffsetTime;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.UUID;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -100,12 +110,15 @@ class EventControllerTest {

private TestDataUtil testDataUtil = new TestDataEntityUtil();

private User user;

/**
* TODO Event* TestUtil 작성 및 연결 필요
*/
@BeforeEach
void init() {

final UserGroup userGroup = testDataUtil.generateGroup(1L, UserGroupType.UNIVERSITY);
user = testDataUtil.generateUser(1L, userGroup);
}

@Test
Expand Down Expand Up @@ -566,4 +579,33 @@ void init() {
))
.andExpect(MockMvcResultMatchers.status().isOk());
}

@Test
void 광고_보고_보상_얻기_가_여부_조회에_성공합니다() throws Exception {
// when
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime localDateTime = LocalDateTime.of(2024, 1, 10, 1, 12);
final UserDataType tag = UserDataType.ADMOB_POINT;
final UserData userData = UserData.builder().user(user).tag(tag)
.value(localDateTime.format(formatter)).build();
final GetIsPossibleAdmob response = GetIsPossibleAdmob.of(userData);

given(eventService.getIsPossibleAdmob(anyLong(), eq(tag.getInitial())))
.willReturn(response);

// then
mockMvc.perform(
RestDocumentationRequestBuilders.get("/api/v1/admob/possible/{tag}", tag.getInitial())
.with(csrf().asHeader())
.header(HttpHeaders.AUTHORIZATION, "Bearer your-access-token")
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andDo(document("api/v1/admob/possible",
Preprocessors.preprocessRequest(excludeRequestHeaders),
Preprocessors.preprocessResponse(excludeResponseHeaders),
pathParameters(parameterWithName("tag").description("보상형 광고의 종류"))
))
.andExpect(MockMvcResultMatchers.status().isOk());

}
}

0 comments on commit 7a9309f

Please sign in to comment.