Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package co.nilin.opex.api.core.inout

data class AddAddressBookItemRequest(
var name: String,
var address: String,
var addressType: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package co.nilin.opex.api.core.inout

data class AddBankAccountRequest(
val name: String? = null,
val cardNumber: String? = null,
val iban: String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package co.nilin.opex.api.core.inout

data class AddressBookResponse(
var id: Long? = null,
var name: String,
var address: String,
var addressType: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package co.nilin.opex.api.core.inout


data class BankAccountResponse(
var id: Long? = null,
var name: String? = null,
var cardNumber: String? = null,
var iban: String? = null,
var accountNumber: String? = null,
var bank: String? = null,
var status: BankAccountStatus,
)

enum class BankAccountStatus {
WAITING, VERIFIED, REJECTED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package co.nilin.opex.api.core.inout

data class CompleteProfileRequest(
var firstName: String,
var lastName: String,
var address: String? = null,
var telephone: String? = null,
var postalCode: String? = null,
var nationality: NationalityType,
var identifier: String,
var gender: Gender,
var birthDate: Long,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package co.nilin.opex.api.core.inout

data class ContactUpdateConfirmRequest(
val email: String? = null,
val mobile: String? = null,
val otpCode: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package co.nilin.opex.api.core.inout

data class ContactUpdateRequest(
val email: String? = null,
val mobile: String? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package co.nilin.opex.api.core.inout

import java.time.LocalDateTime

data class ProfileApprovalRequestUser(
var status: ProfileApprovalRequestStatus,
var createDate: LocalDateTime,
var description: String? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package co.nilin.opex.api.core.inout

data class ProfileApprovalRequestUserResponse(
var status: ProfileApprovalRequestStatus,
var createDate: Long,
var description: String? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package co.nilin.opex.api.core.inout

data class ProfileResponse(
var email: String?,
var userId: String?,
var firstName: String? = null,
var lastName: String? = null,
var address: String? = null,
var mobile: String? = null,
var telephone: String? = null,
var postalCode: String? = null,
var nationality: NationalityType? = null,
var identifier: String? = null,
var gender: Gender? = null,
var birthDate: Long? = null,
var status: ProfileStatus? = null,
var createDate: Long? = null,
var lastUpdateDate: Long? = null,
var creator: String? = null,
var kycLevel: KycLevel? = null,
var mobileIdentityMatch: Boolean? = null,
var personalIdentityMatch: Boolean? = null

)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package co.nilin.opex.api.core.inout

import java.math.BigDecimal
import java.time.LocalDateTime

data class ReservedTransferResponse(
var reserveNumber: String,
var sourceSymbol: String,
var destSymbol: String,
var receiverUuid: String,
var sourceAmount: BigDecimal,
var guaranteedDestAmount: BigDecimal,
var reserveDate: LocalDateTime? = LocalDateTime.now(),
var expDate: LocalDateTime? = null,
var status: ReservedStatus? = null
)




Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package co.nilin.opex.api.core.inout

data class TerminalCommand(
var uuid: String?,
var owner: String,
var identifier: String,
var active: Boolean? = true,
var type: TransferMethod,
var metaData: String,
var description : String?,
var displayOrder: Int? = null,

)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package co.nilin.opex.api.core.inout

import java.math.BigDecimal

data class TransferReserveRequest(
val sourceAmount: BigDecimal,
val sourceSymbol: String,
val destSymbol: String,
var senderUuid: String?,
val receiverUuid: String,
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package co.nilin.opex.api.core.spi

import co.nilin.opex.api.core.inout.CompleteProfileRequest
import co.nilin.opex.api.core.inout.ContactUpdateConfirmRequest
import co.nilin.opex.api.core.inout.ContactUpdateRequest
import co.nilin.opex.api.core.inout.ProfileApprovalRequestUser
import co.nilin.opex.api.core.inout.*

interface ProfileProxy {
suspend fun getProfile(token: String): Profile
suspend fun completeProfile(token: String, request: CompleteProfileRequest): Profile?
suspend fun requestContactUpdate(token: String, request: ContactUpdateRequest): TempOtpResponse
suspend fun confirmContactUpdate(token: String, request: ContactUpdateConfirmRequest)
suspend fun getUserProfileApprovalRequest(token: String): ProfileApprovalRequestUser

// Admin
suspend fun getProfiles(token: String, profileRequest: ProfileRequest): List<Profile>
suspend fun getProfile(token: String, uuid: String): Profile
suspend fun getProfileAdmin(token: String, uuid: String): Profile
suspend fun getProfileHistory(token: String, uuid: String, limit: Int, offset: Int): List<ProfileHistory>
suspend fun getProfileApprovalRequests(
token: String,
Expand All @@ -17,4 +27,16 @@ interface ProfileProxy {
token: String,
request: UpdateApprovalRequestBody
): ProfileApprovalAdminResponse


// Address Book
suspend fun addAddressBook(token: String, request: AddAddressBookItemRequest): AddressBookResponse
suspend fun getAllAddressBooks(token: String): List<AddressBookResponse>
suspend fun deleteAddressBook(token: String, id: Long)
suspend fun updateAddressBook(token: String, id: Long, request: AddAddressBookItemRequest): AddressBookResponse

//Bank Account
suspend fun addBankAccount(token: String, request: AddBankAccountRequest): BankAccountResponse
suspend fun getBankAccounts(token: String): List<BankAccountResponse>
suspend fun deleteBankAccount(token: String, id: Long)
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,8 @@ interface WalletProxy {
amount: BigDecimal,
request: ManualTransferRequest
): TransferResult

suspend fun reserveSwap(token: String, request: TransferReserveRequest) :ReservedTransferResponse
suspend fun finalizeSwap(token: String,reserveUuid: String,description: String?,transferRef: String?) : TransferResult
suspend fun getGatewayTerminal(gatewayUuid: String):List<TerminalCommand>
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class SecurityConfig(
.pathMatchers(HttpMethod.PUT, "/opex/v1/otc/rate").hasAnyAuthority("ROLE_admin", "ROLE_rate_bot")
.pathMatchers(HttpMethod.GET, "/opex/v1/otc/**").permitAll()
.pathMatchers("/opex/v1/otc/**").hasAuthority("ROLE_admin")
.pathMatchers("/opex/v1/bank-account/**").hasAuthority("PERM_bank_account:write")
.anyExchange().authenticated()
}
.addFilterBefore(apiKeyFilter as WebFilter, SecurityWebFiltersOrder.AUTHENTICATION)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package co.nilin.opex.api.ports.opex.controller

import co.nilin.opex.api.core.inout.AddAddressBookItemRequest
import co.nilin.opex.api.core.inout.AddressBookResponse
import co.nilin.opex.api.core.spi.ProfileProxy
import co.nilin.opex.api.ports.opex.util.jwtAuthentication
import co.nilin.opex.api.ports.opex.util.tokenValue
import org.springframework.security.core.annotation.CurrentSecurityContext
import org.springframework.security.core.context.SecurityContext
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/opex/v1/address-book")
class AddressBookController(
val profileProxy: ProfileProxy,
) {

@PostMapping
suspend fun addAddressBook(
@RequestBody request: AddAddressBookItemRequest,
@CurrentSecurityContext securityContext: SecurityContext
): AddressBookResponse {
return profileProxy.addAddressBook(securityContext.jwtAuthentication().tokenValue(), request)
}

@GetMapping
suspend fun getAddressBook(@CurrentSecurityContext securityContext: SecurityContext): List<AddressBookResponse> {
return profileProxy.getAllAddressBooks(securityContext.jwtAuthentication().tokenValue())
}

@DeleteMapping("/{id}")
suspend fun deleteAddressBook(
@PathVariable("id") id: Long,
@CurrentSecurityContext securityContext: SecurityContext
) {
profileProxy.deleteAddressBook(securityContext.jwtAuthentication().tokenValue(), id)
}

@PutMapping("/{id}")
suspend fun updateAddressBook(
@PathVariable("id") id: Long,
@RequestBody request: AddAddressBookItemRequest,
@CurrentSecurityContext securityContext: SecurityContext
): AddressBookResponse {
return profileProxy.updateAddressBook(securityContext.jwtAuthentication().tokenValue(), id, request)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package co.nilin.opex.api.ports.opex.controller

import co.nilin.opex.api.core.inout.AddBankAccountRequest
import co.nilin.opex.api.core.inout.BankAccountResponse
import co.nilin.opex.api.core.spi.ProfileProxy
import co.nilin.opex.api.ports.opex.util.jwtAuthentication
import co.nilin.opex.api.ports.opex.util.tokenValue
import org.springframework.security.core.annotation.CurrentSecurityContext
import org.springframework.security.core.context.SecurityContext
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/opex/v1/bank-account")
class BankAccountController(
val profileProxy: ProfileProxy,
) {

@PostMapping
suspend fun addBankAccount(
@RequestBody request: AddBankAccountRequest,
@CurrentSecurityContext securityContext: SecurityContext
): BankAccountResponse {
return profileProxy.addBankAccount(securityContext.jwtAuthentication().tokenValue(), request)
}

@GetMapping
suspend fun getBankAccounts(@CurrentSecurityContext securityContext: SecurityContext): List<BankAccountResponse> {
return profileProxy.getBankAccounts(securityContext.jwtAuthentication().tokenValue())
}

@DeleteMapping("/{id}")
suspend fun deleteBankAccount(
@PathVariable("id") id: Long,
@CurrentSecurityContext securityContext: SecurityContext
) {
profileProxy.deleteBankAccount(securityContext.jwtAuthentication().tokenValue(), id)
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ class MarketController(
return accountantProxy.getWithdrawLimitConfigs()
}

@GetMapping("/gateway/{gatewayUuid}/terminal")
suspend fun getGatewayTerminal(
@PathVariable("gatewayUuid") gatewayUuid: String,
): List<TerminalCommand>? {
return walletProxy.getGatewayTerminal(gatewayUuid)
}

private fun getValidLimit(limit: Int?): Int = when {
limit == null -> 100
limit > 1000 -> 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ProfileAdminController(private val profileProxy: ProfileProxy) {
@PathVariable uuid: String,
@CurrentSecurityContext securityContext: SecurityContext,
): Profile {
return profileProxy.getProfile(securityContext.jwtAuthentication().tokenValue(), uuid)
return profileProxy.getProfileAdmin(securityContext.jwtAuthentication().tokenValue(), uuid)
}

@GetMapping("/history/{uuid}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package co.nilin.opex.api.ports.opex.controller

import co.nilin.opex.api.core.inout.*
import co.nilin.opex.api.core.spi.ProfileProxy
import co.nilin.opex.api.ports.opex.util.jwtAuthentication
import co.nilin.opex.api.ports.opex.util.toProfileApprovalRequestUserResponse
import co.nilin.opex.api.ports.opex.util.toProfileResponse
import co.nilin.opex.api.ports.opex.util.tokenValue
import org.springframework.security.core.annotation.CurrentSecurityContext
import org.springframework.security.core.context.SecurityContext
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/opex/v1/profile")

class ProfileController(
val profileProxy: ProfileProxy,
) {

@GetMapping("/personal-data")
suspend fun getProfile(@CurrentSecurityContext securityContext: SecurityContext): ProfileResponse {
return profileProxy.getProfile(securityContext.jwtAuthentication().tokenValue()).toProfileResponse()
}

@PutMapping("/completion")
suspend fun completeProfile(
@RequestBody completeProfileRequest: CompleteProfileRequest,
@CurrentSecurityContext securityContext: SecurityContext
): ProfileResponse? {
return profileProxy.completeProfile(securityContext.jwtAuthentication().tokenValue(), completeProfileRequest)
?.toProfileResponse()
}

@PostMapping("/contact/update/otp-request")
suspend fun requestContactUpdate(
@RequestBody request: ContactUpdateRequest,
@CurrentSecurityContext securityContext: SecurityContext
): TempOtpResponse {
return profileProxy.requestContactUpdate(securityContext.jwtAuthentication().tokenValue(), request)
}

@PatchMapping("/contact/update/otp-verification")
suspend fun confirmContactUpdate(
@RequestBody request: ContactUpdateConfirmRequest,
@CurrentSecurityContext securityContext: SecurityContext
) {
profileProxy.confirmContactUpdate(securityContext.jwtAuthentication().tokenValue(), request)

}

@GetMapping("/approval-request")
suspend fun getApprovalRequest(@CurrentSecurityContext securityContext: SecurityContext): ProfileApprovalRequestUserResponse {
return profileProxy.getUserProfileApprovalRequest(securityContext.jwtAuthentication().tokenValue())
.toProfileApprovalRequestUserResponse()
}
}
Loading
Loading