Skip to content

Commit

Permalink
fix: java method
Browse files Browse the repository at this point in the history
  • Loading branch information
finalchild committed Sep 5, 2024
1 parent 31884dc commit fb13a51
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,9 @@ class SchemaGenerator(private val document: JsonObject, private val includePrefi

val futureFunBuilder = FunSpec.builder("${operation.name}Future")
.addAnnotation(AnnotationSpec.builder(JvmName::class).addMember("%S", operation.name).build())
// .returns(returnType = CompletableFuture::class.asTypeName().parameterizedBy(operation.success))
.returns(returnType = CompletableFuture::class.asTypeName().parameterizedBy(operation.success))
.addParameters(funBuilder.parameters)
.addCode("return future(::operation.name)")
.addCode("return GlobalScope.future { ${operation.name}(${funBuilder.parameters.joinToString(", ") { it.name } }) }")

classBuilder.addFunction(futureFunBuilder.build())
}
Expand All @@ -754,6 +754,8 @@ class SchemaGenerator(private val document: JsonObject, private val includePrefi
.addImport("io.ktor.http", "appendPathSegments", "HttpHeaders", "ContentType", "contentType")
.addImport("kotlinx.serialization", "encodeToString")
.addImport("kotlinx.serialization.json", "Json")
.addImport("kotlinx.coroutines", "GlobalScope")
.addImport("kotlinx.coroutines.future", "future")
.addType(classBuilder.build())
.build()
.writeTo(targetDirectory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,16 @@ import io.portone.sdk.server.schemas.WebhookNotFoundError
import io.portone.sdk.server.schemas.WebhookNotFoundException
import java.io.Closeable
import java.time.Instant
import java.util.concurrent.CompletableFuture
import kotlin.Boolean
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.future.future
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
Expand Down Expand Up @@ -268,8 +271,9 @@ public class PortOneApi(
* @param identityVerificationId 조회할 본인인증 아이디
*/
@JvmName("getIdentityVerification")
public fun getIdentityVerificationFuture(identityVerificationId: String): Unit =
future(::operation.name)
public fun getIdentityVerificationFuture(identityVerificationId: String):
CompletableFuture<IdentityVerification> = GlobalScope.future {
getIdentityVerification(identityVerificationId) }

/**
* 본인인증 요청 전송
Expand Down Expand Up @@ -360,7 +364,8 @@ public class PortOneApi(
bypass: JsonObject? = null,
`operator`: IdentityVerificationOperator,
method: IdentityVerificationMethod,
): Unit = future(::operation.name)
): CompletableFuture<Unit> = GlobalScope.future { sendIdentityVerification(identityVerificationId,
channelKey, customer, customData, bypass, operator, method) }

/**
* 본인인증 확인
Expand Down Expand Up @@ -432,7 +437,8 @@ public class PortOneApi(
*/
@JvmName("confirmIdentityVerification")
public fun confirmIdentityVerificationFuture(identityVerificationId: String, otp: String? = null):
Unit = future(::operation.name)
CompletableFuture<ConfirmIdentityVerificationResponse> = GlobalScope.future {
confirmIdentityVerification(identityVerificationId, otp) }

/**
* SMS 본인인증 요청 재전송
Expand Down Expand Up @@ -492,8 +498,9 @@ public class PortOneApi(
* @param identityVerificationId 본인인증 아이디
*/
@JvmName("resendIdentityVerification")
public fun resendIdentityVerificationFuture(identityVerificationId: String): Unit =
future(::operation.name)
public fun resendIdentityVerificationFuture(identityVerificationId: String):
CompletableFuture<Unit> = GlobalScope.future {
resendIdentityVerification(identityVerificationId) }

/**
* 결제 정보 사전 등록
Expand Down Expand Up @@ -559,7 +566,8 @@ public class PortOneApi(
totalAmount: Long? = null,
taxFreeAmount: Long? = null,
currency: Currency? = null,
): Unit = future(::operation.name)
): CompletableFuture<Unit> = GlobalScope.future { preRegisterPayment(paymentId, totalAmount,
taxFreeAmount, currency) }

/**
* 빌링키 단건 조회
Expand Down Expand Up @@ -617,7 +625,8 @@ public class PortOneApi(
* @param billingKey 조회할 빌링키
*/
@JvmName("getBillingKeyInfo")
public fun getBillingKeyInfoFuture(billingKey: String): Unit = future(::operation.name)
public fun getBillingKeyInfoFuture(billingKey: String): CompletableFuture<BillingKeyInfo> =
GlobalScope.future { getBillingKeyInfo(billingKey) }

/**
* 빌링키 삭제
Expand Down Expand Up @@ -691,7 +700,8 @@ public class PortOneApi(
* @param billingKey 삭제할 빌링키
*/
@JvmName("deleteBillingKey")
public fun deleteBillingKeyFuture(billingKey: String): Unit = future(::operation.name)
public fun deleteBillingKeyFuture(billingKey: String): CompletableFuture<DeleteBillingKeyResponse>
= GlobalScope.future { deleteBillingKey(billingKey) }

/**
* 빌링키 다건 조회
Expand Down Expand Up @@ -759,7 +769,8 @@ public class PortOneApi(
page: PageInput? = null,
sort: BillingKeySortInput? = null,
filter: BillingKeyFilterInput? = null,
): Unit = future(::operation.name)
): CompletableFuture<GetBillingKeyInfosResponse> = GlobalScope.future { getBillingKeyInfos(page,
sort, filter) }

/**
* 빌링키 발급
Expand Down Expand Up @@ -854,7 +865,8 @@ public class PortOneApi(
customData: String? = null,
bypass: JsonObject? = null,
noticeUrls: List<String>? = null,
): Unit = future(::operation.name)
): CompletableFuture<IssueBillingKeyResponse> = GlobalScope.future { issueBillingKey(method,
channelKey, channelGroupId, customer, customData, bypass, noticeUrls) }

/**
* 현금 영수증 단건 조회
Expand Down Expand Up @@ -912,7 +924,8 @@ public class PortOneApi(
* @param paymentId 결제 건 아이디
*/
@JvmName("getCashReceiptByPaymentId")
public fun getCashReceiptByPaymentIdFuture(paymentId: String): Unit = future(::operation.name)
public fun getCashReceiptByPaymentIdFuture(paymentId: String): CompletableFuture<CashReceipt> =
GlobalScope.future { getCashReceiptByPaymentId(paymentId) }

/**
* 결제 단건 조회
Expand Down Expand Up @@ -969,7 +982,8 @@ public class PortOneApi(
* @param paymentId 조회할 결제 아이디
*/
@JvmName("getPayment")
public fun getPaymentFuture(paymentId: String): Unit = future(::operation.name)
public fun getPaymentFuture(paymentId: String): CompletableFuture<Payment> = GlobalScope.future {
getPayment(paymentId) }

/**
* 결제 다건 조회(페이지 기반)
Expand Down Expand Up @@ -1027,8 +1041,8 @@ public class PortOneApi(
* @param filter 조회할 결제 건 조건 필터 - V1 결제 건의 경우 일부 필드에 대해 필터가 적용되지 않을 수 있습니다.
*/
@JvmName("getPayments")
public fun getPaymentsFuture(page: PageInput? = null, filter: PaymentFilterInput? = null): Unit =
future(::operation.name)
public fun getPaymentsFuture(page: PageInput? = null, filter: PaymentFilterInput? = null):
CompletableFuture<GetPaymentsResponse> = GlobalScope.future { getPayments(page, filter) }

/**
* 결제 대용량 다건 조회(커서 기반)
Expand Down Expand Up @@ -1102,7 +1116,8 @@ public class PortOneApi(
until: Instant? = null,
cursor: String? = null,
size: Int? = null,
): Unit = future(::operation.name)
): CompletableFuture<GetAllPaymentsByCursorResponse> = GlobalScope.future {
getAllPaymentsByCursor(from, until, cursor, size) }

/**
* 결제 예약 단건 조회
Expand Down Expand Up @@ -1160,7 +1175,8 @@ public class PortOneApi(
* @param paymentScheduleId 조회할 결제 예약 건 아이디
*/
@JvmName("getPaymentSchedule")
public fun getPaymentScheduleFuture(paymentScheduleId: String): Unit = future(::operation.name)
public fun getPaymentScheduleFuture(paymentScheduleId: String): CompletableFuture<PaymentSchedule>
= GlobalScope.future { getPaymentSchedule(paymentScheduleId) }

/**
* 결제 예약 다건 조회
Expand Down Expand Up @@ -1230,7 +1246,8 @@ public class PortOneApi(
page: PageInput? = null,
sort: PaymentScheduleSortInput? = null,
filter: PaymentScheduleFilterInput? = null,
): Unit = future(::operation.name)
): CompletableFuture<GetPaymentSchedulesResponse> = GlobalScope.future { getPaymentSchedules(page,
sort, filter) }

/**
* 결제 예약 취소
Expand Down Expand Up @@ -1305,7 +1322,8 @@ public class PortOneApi(
*/
@JvmName("revokePaymentSchedules")
public fun revokePaymentSchedulesFuture(billingKey: String? = null, scheduleIds: List<String>? =
null): Unit = future(::operation.name)
null): CompletableFuture<RevokePaymentSchedulesResponse> = GlobalScope.future {
revokePaymentSchedules(billingKey, scheduleIds) }

/**
* 결제 예약
Expand Down Expand Up @@ -1388,7 +1406,8 @@ public class PortOneApi(
paymentId: String,
payment: BillingKeyPaymentInput,
timeToPay: Instant,
): Unit = future(::operation.name)
): CompletableFuture<CreatePaymentScheduleResponse> = GlobalScope.future {
createPaymentSchedule(paymentId, payment, timeToPay) }

/**
* 결제 취소
Expand Down Expand Up @@ -1511,7 +1530,9 @@ public class PortOneApi(
requester: CancelRequester? = null,
currentCancellableAmount: Long? = null,
refundAccount: CancelPaymentBodyRefundAccount? = null,
): Unit = future(::operation.name)
): CompletableFuture<CancelPaymentResponse> = GlobalScope.future { cancelPayment(paymentId,
amount, taxFreeAmount, vatAmount, reason, requester, currentCancellableAmount, refundAccount)
}

/**
* 빌링키 결제
Expand Down Expand Up @@ -1678,7 +1699,10 @@ public class PortOneApi(
shippingAddress: SeparatedAddressInput? = null,
promotionId: String? = null,
bypass: JsonObject? = null,
): Unit = future(::operation.name)
): CompletableFuture<PayWithBillingKeyResponse> = GlobalScope.future {
payWithBillingKey(paymentId, billingKey, channelKey, orderName, customer, customData, amount,
currency, installmentMonth, useFreeInterestFromMerchant, useCardPoint, cashReceipt, country,
noticeUrls, products, productCount, productType, shippingAddress, promotionId, bypass) }

/**
* 수기 결제
Expand Down Expand Up @@ -1830,7 +1854,10 @@ public class PortOneApi(
productType: PaymentProductType? = null,
shippingAddress: SeparatedAddressInput? = null,
promotionId: String? = null,
): Unit = future(::operation.name)
): CompletableFuture<PayInstantlyResponse> = GlobalScope.future { payInstantly(paymentId,
channelKey, channelGroupId, method, orderName, isCulturalExpense, isEscrow, customer,
customData, amount, currency, country, noticeUrls, products, productCount, productType,
shippingAddress, promotionId) }

/**
* 현금 영수증 수동 발급
Expand Down Expand Up @@ -1929,7 +1956,8 @@ public class PortOneApi(
productType: PaymentProductType? = null,
customer: IssueCashReceiptCustomerInput,
paidAt: Instant? = null,
): Unit = future(::operation.name)
): CompletableFuture<IssueCashReceiptResponse> = GlobalScope.future { issueCashReceipt(paymentId,
channelKey, type, orderName, currency, amount, productType, customer, paidAt) }

/**
* 현금 영수증 취소
Expand Down Expand Up @@ -1994,7 +2022,9 @@ public class PortOneApi(
* @param paymentId 결제 건 아이디
*/
@JvmName("cancelCashReceiptByPaymentId")
public fun cancelCashReceiptByPaymentIdFuture(paymentId: String): Unit = future(::operation.name)
public fun cancelCashReceiptByPaymentIdFuture(paymentId: String):
CompletableFuture<CancelCashReceiptResponse> = GlobalScope.future {
cancelCashReceiptByPaymentId(paymentId) }

/**
* 가상계좌 말소
Expand Down Expand Up @@ -2058,7 +2088,9 @@ public class PortOneApi(
* @param paymentId 결제 건 아이디
*/
@JvmName("closeVirtualAccount")
public fun closeVirtualAccountFuture(paymentId: String): Unit = future(::operation.name)
public fun closeVirtualAccountFuture(paymentId: String):
CompletableFuture<CloseVirtualAccountResponse> = GlobalScope.future {
closeVirtualAccount(paymentId) }

/**
* 에스크로 배송 정보 등록
Expand Down Expand Up @@ -2146,7 +2178,8 @@ public class PortOneApi(
logistics: PaymentLogistics,
sendEmail: Boolean? = null,
products: List<PaymentProduct>? = null,
): Unit = future(::operation.name)
): CompletableFuture<ApplyEscrowLogisticsResponse> = GlobalScope.future {
applyEscrowLogistics(paymentId, sender, receiver, logistics, sendEmail, products) }

/**
* 에스크로 배송 정보 수정
Expand Down Expand Up @@ -2234,7 +2267,8 @@ public class PortOneApi(
logistics: PaymentLogistics,
sendEmail: Boolean? = null,
products: List<PaymentProduct>? = null,
): Unit = future(::operation.name)
): CompletableFuture<ModifyEscrowLogisticsResponse> = GlobalScope.future {
modifyEscrowLogistics(paymentId, sender, receiver, logistics, sendEmail, products) }

/**
* 에스크로 구매 확정
Expand Down Expand Up @@ -2302,8 +2336,9 @@ public class PortOneApi(
* 네이버페이 전용 파라미터이며, 구분이 모호한 경우 고객사 관리자(true)로 입력합니다.
*/
@JvmName("confirmEscrow")
public fun confirmEscrowFuture(paymentId: String, fromStore: Boolean? = null): Unit =
future(::operation.name)
public fun confirmEscrowFuture(paymentId: String, fromStore: Boolean? = null):
CompletableFuture<ConfirmEscrowResponse> = GlobalScope.future { confirmEscrow(paymentId,
fromStore) }

/**
* 웹훅 재발송
Expand Down Expand Up @@ -2366,8 +2401,9 @@ public class PortOneApi(
* @param webhookId 웹훅 아이디 - 입력하지 않으면 결제 건의 가장 최근 웹훅 아이디가 기본 적용됩니다
*/
@JvmName("resendWebhook")
public fun resendWebhookFuture(paymentId: String, webhookId: String? = null): Unit =
future(::operation.name)
public fun resendWebhookFuture(paymentId: String, webhookId: String? = null):
CompletableFuture<ResendWebhookResponse> = GlobalScope.future { resendWebhook(paymentId,
webhookId) }

/**
* 카카오페이 주문 조회 API
Expand Down Expand Up @@ -2424,8 +2460,9 @@ public class PortOneApi(
* @param channelKey 채널 키
*/
@JvmName("getKakaopayPaymentOrder")
public fun getKakaopayPaymentOrderFuture(pgTxId: String, channelKey: String): Unit =
future(::operation.name)
public fun getKakaopayPaymentOrderFuture(pgTxId: String, channelKey: String):
CompletableFuture<GetKakaopayPaymentOrderResponse> = GlobalScope.future {
getKakaopayPaymentOrder(pgTxId, channelKey) }

/**
* 영수증 내 하위 상점 거래 등록
Expand Down Expand Up @@ -2494,5 +2531,6 @@ public class PortOneApi(
*/
@JvmName("registerStoreReceipt")
public fun registerStoreReceiptFuture(paymentId: String,
items: List<RegisterStoreReceiptBodyItem>): Unit = future(::operation.name)
items: List<RegisterStoreReceiptBodyItem>): CompletableFuture<RegisterStoreReceiptResponse> =
GlobalScope.future { registerStoreReceipt(paymentId, items) }
}
1 change: 1 addition & 0 deletions common/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module io.portone.sdk.server {
requires kotlinx.serialization.json;
requires kotlinx.coroutines.core;

exports io.portone.sdk.server;
exports io.portone.sdk.server.schemas;
Expand Down

0 comments on commit fb13a51

Please sign in to comment.