Skip to content

Commit

Permalink
Remove useless credentials case class for P24 API
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownNPC committed Aug 3, 2019
1 parent 0ed7ac2 commit 4c9699b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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");
Expand Down
Expand Up @@ -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)

Expand All @@ -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 =
Expand All @@ -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)

}
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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
Expand All @@ -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") {

Expand Down

0 comments on commit 4c9699b

Please sign in to comment.