diff --git a/README.md b/README.md index d3b62ce..38c10e3 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ sbt clean compile ``` #### Usage in java code ``` -P24API p24Api = P24API.getInstance(new P24Model.P24Credential(1, "merch_id")); +P24API p24Api = P24API.getInstance(1, "merchPass")); QiwiAPI qiwiApi = QiwiAPI.getInstance("token"); // Requires KWM backup key(!) WebMoneyAPI webMoneyApi = WebMoneyAPI.getInstance("wimd", "password", "/kwmPath/test.kwm"); diff --git a/privat24/src/main/scala/com/github/unknownnpc/psw/p24/P24API.scala b/privat24/src/main/scala/com/github/unknownnpc/psw/p24/P24API.scala index 9cf7f37..7752fc4 100644 --- a/privat24/src/main/scala/com/github/unknownnpc/psw/p24/P24API.scala +++ b/privat24/src/main/scala/com/github/unknownnpc/psw/p24/P24API.scala @@ -5,12 +5,12 @@ import java.util.Date import com.github.unknownnpc.psw.api.APIException import com.github.unknownnpc.psw.p24.action.RetrieveTransferHistoryAction +import com.github.unknownnpc.psw.p24.model.P24Model.Merchant import com.github.unknownnpc.psw.p24.model.P24Model.WalletHistory._ -import com.github.unknownnpc.psw.p24.model.P24Model.{Merchant, P24Credential} import com.github.unknownnpc.psw.p24.serializer.P24Serializer.walletHistoryReqResSerializer import org.apache.http.impl.client.{CloseableHttpClient, HttpClients} -private[p24] class P24API(credentials: P24Credential, httpClient: CloseableHttpClient) { +private[p24] class P24API(merchId: Long, merchPass: String, httpClient: CloseableHttpClient) { private val p24ReqDateFormatter = new SimpleDateFormat(WalletRequestHistoryDateFormat) @@ -26,8 +26,8 @@ private[p24] class P24API(credentials: P24Credential, httpClient: CloseableHttpC def retrieveTransferHistory(cardNum: String, from: Date, to: Date, waitVal: Long = 15): Either[APIException, WalletHistoryResponse] = { val request = WalletHistoryRequest( - credentials.pass, - Merchant(credentials.id, None), + merchPass, + Merchant(merchId, None), WalletHistoryRequestData( waitField = waitVal, payment = @@ -48,9 +48,9 @@ private[p24] class P24API(credentials: P24Credential, httpClient: CloseableHttpC object P24API { - def apply(credentials: P24Credential, - httpClient: CloseableHttpClient = HttpClients.createDefault()): P24API = new P24API(credentials, httpClient) + def apply(merchId: Long, merchPass: String, + httpClient: CloseableHttpClient = HttpClients.createDefault()): P24API = new P24API(merchId, merchPass, httpClient) - def getInstance(credentials: P24Credential) = apply(credentials) + def getInstance(merchId: Long, merchPass: String) = apply(merchId, merchPass) } diff --git a/privat24/src/main/scala/com/github/unknownnpc/psw/p24/model/P24Model.scala b/privat24/src/main/scala/com/github/unknownnpc/psw/p24/model/P24Model.scala index bddc256..2f3a6c1 100644 --- a/privat24/src/main/scala/com/github/unknownnpc/psw/p24/model/P24Model.scala +++ b/privat24/src/main/scala/com/github/unknownnpc/psw/p24/model/P24Model.scala @@ -4,7 +4,6 @@ import java.util.Date private[p24] object P24Model { - case class P24Credential(id: Long, pass: String) case class Merchant(id: Long, signature: Option[String]) object WalletHistory { diff --git a/privat24/src/test/scala/com/github/unknownnpc/psw/p24/P24APITest.scala b/privat24/src/test/scala/com/github/unknownnpc/psw/p24/P24APITest.scala index 8162ecc..6cf8ee5 100644 --- a/privat24/src/test/scala/com/github/unknownnpc/psw/p24/P24APITest.scala +++ b/privat24/src/test/scala/com/github/unknownnpc/psw/p24/P24APITest.scala @@ -2,7 +2,6 @@ package com.github.unknownnpc.psw.p24 import java.util.Date -import com.github.unknownnpc.psw.p24.model.P24Model.P24Credential import org.apache.http.client.methods.{CloseableHttpResponse, HttpPost} import org.apache.http.entity.StringEntity import org.apache.http.impl.client.CloseableHttpClient @@ -17,8 +16,7 @@ import org.scalatestplus.mockito.MockitoSugar class P24APITest extends FunSpec with Matchers with MockitoSugar { private val client: CloseableHttpClient = mock[CloseableHttpClient] - private val credential = P24Credential(1, "pass") - private val p24API = P24API(credential, client) + private val p24API = P24API(1, "pass", client) describe("retrieveTransferHistory") {