diff --git a/docs/ErrorException.html b/docs/ErrorException.html deleted file mode 100644 index 88600ca..0000000 --- a/docs/ErrorException.html +++ /dev/null @@ -1,249 +0,0 @@ - - - - - - - - Class ErrorException | API - - - - - -
- -
- -
-
- -
- -
-

- Class ErrorException -

- - - - - - - - - - - -
extends -Exception
- -
- -
- -
- -
- - - - - - - - - - - - - - - - - - - - -
Methods
- - - - - - - -
Methods inherited from Exception
-__wakeup(), getMessage(), getCode(), getFile(), getLine(), getTrace(), getPrevious(), getTraceAsString(), __toString()
- - - - - - - - - - - - - - - - - - - - - -
- - -
- -
- -
- - diff --git a/docs/Exception.html b/docs/Exception.html index 7b719e6..339a768 100644 --- a/docs/Exception.html +++ b/docs/Exception.html @@ -113,21 +113,14 @@

@@ -92,7 +92,7 @@

Exceptions

- Class IPay\Exception\SessionExpiredException + Class IPay\Exception\SessionException

@@ -118,7 +118,7 @@

- Located at Exception/SessionExpiredException.php
+ Located at Exception/SessionException.php
diff --git a/docs/RuntimeException.html b/docs/RuntimeException.html index 3b599c9..0a73c6c 100644 --- a/docs/RuntimeException.html +++ b/docs/RuntimeException.html @@ -118,12 +118,12 @@

diff --git a/docs/Symfony.Component.OptionsResolver.Exception.ExceptionInterface.html b/docs/Symfony.Component.OptionsResolver.Exception.ExceptionInterface.html index a8851a5..9cf9faa 100644 --- a/docs/Symfony.Component.OptionsResolver.Exception.ExceptionInterface.html +++ b/docs/Symfony.Component.OptionsResolver.Exception.ExceptionInterface.html @@ -179,45 +179,45 @@

  • -Symfony\Component\OptionsResolver\Exception\InvalidArgumentException +Symfony\Component\OptionsResolver\Exception\NoSuchOptionException implements ExceptionInterface -
  • + + diff --git a/docs/Throwable.html b/docs/Throwable.html index 79c1b2f..841c70c 100644 --- a/docs/Throwable.html +++ b/docs/Throwable.html @@ -117,21 +117,14 @@

    + diff --git a/docs/assets/elements.js b/docs/assets/elements.js index 7b145f9..4f4e679 100644 --- a/docs/assets/elements.js +++ b/docs/assets/elements.js @@ -1 +1 @@ -window.ApiGen?.resolveElements({"namespace":[["EventSauce","namespace-EventSauce.html"],["EventSauce\\ObjectHydrator","namespace-EventSauce.ObjectHydrator.html"],["Http","namespace-Http.html"],["Http\\Client","namespace-Http.Client.html"],["Http\\Client\\Common","namespace-Http.Client.Common.html"],["Http\\Promise","namespace-Http.Promise.html"],["IPay","namespace-IPay.html"],["IPay\\Api","namespace-IPay.Api.html"],["IPay\\Captcha","namespace-IPay.Captcha.html"],["IPay\\Encryption","namespace-IPay.Encryption.html"],["IPay\\Entity","namespace-IPay.Entity.html"],["IPay\\Exception","namespace-IPay.Exception.html"],["IPay\\Http","namespace-IPay.Http.html"],["IPay\\Http\\Plugin","namespace-IPay.Http.Plugin.html"],["Psr","namespace-Psr.html"],["Psr\\Http","namespace-Psr.Http.html"],["Psr\\Http\\Client","namespace-Psr.Http.Client.html"],["Psr\\Http\\Message","namespace-Psr.Http.Message.html"],["Symfony","namespace-Symfony.html"],["Symfony\\Component","namespace-Symfony.Component.html"],["Symfony\\Component\\OptionsResolver","namespace-Symfony.Component.OptionsResolver.html"],["Symfony\\Component\\OptionsResolver\\Exception","namespace-Symfony.Component.OptionsResolver.Exception.html"],["","namespace-none.html"]],"classLike":[["ArrayAccess","ArrayAccess.html",{"method":[["offsetExists","_offsetExists"],["offsetGet","_offsetGet"],["offsetSet","_offsetSet"],["offsetUnset","_offsetUnset"]]}],["ArrayIterator","ArrayIterator.html",{"method":[["__construct","___construct"],["offsetExists","_offsetExists"],["offsetGet","_offsetGet"],["offsetSet","_offsetSet"],["offsetUnset","_offsetUnset"],["append","_append"],["getArrayCopy","_getArrayCopy"],["count","_count"],["getFlags","_getFlags"],["setFlags","_setFlags"],["asort","_asort"],["ksort","_ksort"],["uasort","_uasort"],["uksort","_uksort"],["natsort","_natsort"],["natcasesort","_natcasesort"],["unserialize","_unserialize"],["serialize","_serialize"],["__serialize","___serialize"],["__unserialize","___unserialize"],["rewind","_rewind"],["current","_current"],["key","_key"],["next","_next"],["valid","_valid"],["seek","_seek"],["__debugInfo","___debugInfo"]]}],["ArrayObject","ArrayObject.html",{"method":[["__construct","___construct"],["offsetExists","_offsetExists"],["offsetGet","_offsetGet"],["offsetSet","_offsetSet"],["offsetUnset","_offsetUnset"],["append","_append"],["getArrayCopy","_getArrayCopy"],["count","_count"],["getFlags","_getFlags"],["setFlags","_setFlags"],["asort","_asort"],["ksort","_ksort"],["uasort","_uasort"],["uksort","_uksort"],["natsort","_natsort"],["natcasesort","_natcasesort"],["unserialize","_unserialize"],["serialize","_serialize"],["__serialize","___serialize"],["__unserialize","___unserialize"],["getIterator","_getIterator"],["exchangeArray","_exchangeArray"],["setIteratorClass","_setIteratorClass"],["getIteratorClass","_getIteratorClass"],["__debugInfo","___debugInfo"]]}],["Closure","Closure.html",{"method":[["bind","_bind"],["bindTo","_bindTo"],["call","_call"],["fromCallable","_fromCallable"]]}],["Countable","Countable.html",{"method":[["count","_count"]]}],["DateInterval","DateInterval.html",{"method":[["__construct","___construct"],["createFromDateString","_createFromDateString"],["format","_format"],["__serialize","___serialize"],["__unserialize","___unserialize"],["__wakeup","___wakeup"],["__set_state","___set_state"]]}],["DateTime","DateTime.html",{"method":[["__construct","___construct"],["__serialize","___serialize"],["__unserialize","___unserialize"],["__wakeup","___wakeup"],["__set_state","___set_state"],["createFromImmutable","_createFromImmutable"],["createFromInterface","_createFromInterface"],["createFromFormat","_createFromFormat"],["getLastErrors","_getLastErrors"],["format","_format"],["modify","_modify"],["add","_add"],["sub","_sub"],["getTimezone","_getTimezone"],["setTimezone","_setTimezone"],["getOffset","_getOffset"],["setTime","_setTime"],["setDate","_setDate"],["setISODate","_setISODate"],["setTimestamp","_setTimestamp"],["getTimestamp","_getTimestamp"],["diff","_diff"]]}],["DateTimeImmutable","DateTimeImmutable.html",{"method":[["__construct","___construct"],["__serialize","___serialize"],["__unserialize","___unserialize"],["__wakeup","___wakeup"],["__set_state","___set_state"],["createFromFormat","_createFromFormat"],["getLastErrors","_getLastErrors"],["format","_format"],["getTimezone","_getTimezone"],["getOffset","_getOffset"],["getTimestamp","_getTimestamp"],["diff","_diff"],["modify","_modify"],["add","_add"],["sub","_sub"],["setTimezone","_setTimezone"],["setTime","_setTime"],["setDate","_setDate"],["setISODate","_setISODate"],["setTimestamp","_setTimestamp"],["createFromMutable","_createFromMutable"],["createFromInterface","_createFromInterface"]]}],["DateTimeInterface","DateTimeInterface.html",{"method":[["format","_format"],["getTimezone","_getTimezone"],["getOffset","_getOffset"],["getTimestamp","_getTimestamp"],["diff","_diff"],["__wakeup","___wakeup"],["__serialize","___serialize"],["__unserialize","___unserialize"]]}],["DateTimeZone","DateTimeZone.html",{"method":[["__construct","___construct"],["getName","_getName"],["getOffset","_getOffset"],["getTransitions","_getTransitions"],["getLocation","_getLocation"],["listAbbreviations","_listAbbreviations"],["listIdentifiers","_listIdentifiers"],["__serialize","___serialize"],["__unserialize","___unserialize"],["__wakeup","___wakeup"],["__set_state","___set_state"]]}],["ErrorException","ErrorException.html",{"method":[["__construct","___construct"],["getSeverity","_getSeverity"]]}],["EventSauce\\ObjectHydrator\\IterableList","EventSauce.ObjectHydrator.IterableList.html",{"method":[["__construct","___construct"],["getIterator","_getIterator"],["toArray","_toArray"]]}],["EventSauce\\ObjectHydrator\\ObjectMapper","EventSauce.ObjectHydrator.ObjectMapper.html",{"method":[["hydrateObject","_hydrateObject"],["hydrateObjects","_hydrateObjects"],["serializeObject","_serializeObject"],["serializeObjectOfType","_serializeObjectOfType"],["serializeObjects","_serializeObjects"]]}],["EventSauce\\ObjectHydrator\\UnableToHydrateObject","EventSauce.ObjectHydrator.UnableToHydrateObject.html",{"method":[["missingFields","_missingFields"],["stack","_stack"],["dueToError","_dueToError"],["dueToMissingFields","_dueToMissingFields"],["noHydrationDefined","_noHydrationDefined"],["classIsNotInstantiable","_classIsNotInstantiable"]]}],["EventSauce\\ObjectHydrator\\UnableToSerializeObject","EventSauce.ObjectHydrator.UnableToSerializeObject.html",{"method":[["dueToError","_dueToError"]]}],["Exception","Exception.html",{"method":[["__construct","___construct"],["__wakeup","___wakeup"],["getMessage","_getMessage"],["getCode","_getCode"],["getFile","_getFile"],["getLine","_getLine"],["getTrace","_getTrace"],["getPrevious","_getPrevious"],["getTraceAsString","_getTraceAsString"],["__toString","___toString"]]}],["Http\\Client\\Common\\HttpMethodsClientInterface","Http.Client.Common.HttpMethodsClientInterface.html",{"method":[["get","_get"],["head","_head"],["trace","_trace"],["post","_post"],["put","_put"],["patch","_patch"],["delete","_delete"],["options","_options"],["send","_send"]]}],["Http\\Client\\Common\\Plugin","Http.Client.Common.Plugin.html",{"method":[["handleRequest","_handleRequest"]]}],["Http\\Client\\Exception","Http.Client.Exception.html",[]],["Http\\Client\\HttpClient","Http.Client.HttpClient.html",[]],["Http\\Promise\\Promise","Http.Promise.Promise.html",{"constant":[["PENDING","PENDING"],["FULFILLED","FULFILLED"],["REJECTED","REJECTED"]],"method":[["then","_then"],["getState","_getState"],["wait","_wait"]]}],["InvalidArgumentException","InvalidArgumentException.html",[]],["IPay\\Api\\AbstractApi","IPay.Api.AbstractApi.html",{"property":[["objectMapper","$objectMapper"],["iPayClient","$iPayClient"]],"method":[["__construct","___construct"],["post","_post"],["createOptionsResolver","_createOptionsResolver"],["getSession","_getSession"]]}],["IPay\\Api\\AuthenticatedApi","IPay.Api.AuthenticatedApi.html",{"method":[["customer","_customer"],["accounts","_accounts"],["historyTransactions","_historyTransactions"]]}],["IPay\\Api\\AuthenticatedSession","IPay.Api.AuthenticatedSession.html",{"method":[["__construct","___construct"],["getRequestParameters","_getRequestParameters"],["getSessionId","_getSessionId"]]}],["IPay\\Api\\BodyBuilder","IPay.Api.BodyBuilder.html",{"method":[["from","_from"],["enhance","_enhance"],["build","_build"],["encrypt","_encrypt"],["__toString","___toString"],["jsonSerialize","_jsonSerialize"]]}],["IPay\\Api\\SessionInterface","IPay.Api.SessionInterface.html",{"method":[["getRequestParameters","_getRequestParameters"]]}],["IPay\\Api\\UnauthenticatedApi","IPay.Api.UnauthenticatedApi.html",{"method":[["login","_login"]]}],["IPay\\Api\\UnauthenticatedSession","IPay.Api.UnauthenticatedSession.html",{"method":[["getRequestParameters","_getRequestParameters"]]}],["IPay\\Captcha\\CaptchaSolver","IPay.Captcha.CaptchaSolver.html",{"method":[["solve","_solve"]]}],["IPay\\Encryption\\Encrypter","IPay.Encryption.Encrypter.html",{"method":[["encrypt","_encrypt"]]}],["IPay\\Entity\\Account","IPay.Entity.Account.html",{"property":[["title","$title"],["number","$number"],["currencyCode","$currencyCode"],["accountState","$accountState"]],"method":[["__construct","___construct"]]}],["IPay\\Entity\\AccountState","IPay.Entity.AccountState.html",{"property":[["availableBalance","$availableBalance"],["balance","$balance"]],"method":[["__construct","___construct"]]}],["IPay\\Entity\\Customer","IPay.Entity.Customer.html",{"property":[["name","$name"],["phone","$phone"],["job","$job"],["accountNumber","$accountNumber"]],"method":[["__construct","___construct"]]}],["IPay\\Entity\\Transaction","IPay.Entity.Transaction.html",{"property":[["currency","$currency"],["amount","$amount"],["remark","$remark"],["corresponsiveAccount","$corresponsiveAccount"],["corresponsiveName","$corresponsiveName"],["processDate","$processDate"]],"method":[["__construct","___construct"]]}],["IPay\\Exception\\LoginFailedException","IPay.Exception.LoginFailedException.html",[]],["IPay\\Exception\\SessionExpiredException","IPay.Exception.SessionExpiredException.html",[]],["IPay\\Http\\Plugin\\ExceptionThrower","IPay.Http.Plugin.ExceptionThrower.html",{"method":[["handleRequest","_handleRequest"]]}],["IPay\\IPayClient","IPay.IPayClient.html",{"method":[["create","_create"],["getClient","_getClient"],["guest","_guest"],["session","_session"]]}],["Iterator","Iterator.html",{"method":[["current","_current"],["next","_next"],["key","_key"],["valid","_valid"],["rewind","_rewind"]]}],["IteratorAggregate","IteratorAggregate.html",{"method":[["getIterator","_getIterator"]]}],["JsonSerializable","JsonSerializable.html",{"method":[["jsonSerialize","_jsonSerialize"]]}],["LogicException","LogicException.html",[]],["OutOfBoundsException","OutOfBoundsException.html",[]],["Psr\\Http\\Client\\ClientExceptionInterface","Psr.Http.Client.ClientExceptionInterface.html",[]],["Psr\\Http\\Client\\ClientInterface","Psr.Http.Client.ClientInterface.html",{"method":[["sendRequest","_sendRequest"]]}],["Psr\\Http\\Message\\MessageInterface","Psr.Http.Message.MessageInterface.html",{"method":[["getProtocolVersion","_getProtocolVersion"],["withProtocolVersion","_withProtocolVersion"],["getHeaders","_getHeaders"],["hasHeader","_hasHeader"],["getHeader","_getHeader"],["getHeaderLine","_getHeaderLine"],["withHeader","_withHeader"],["withAddedHeader","_withAddedHeader"],["withoutHeader","_withoutHeader"],["getBody","_getBody"],["withBody","_withBody"]]}],["Psr\\Http\\Message\\RequestInterface","Psr.Http.Message.RequestInterface.html",{"method":[["getRequestTarget","_getRequestTarget"],["withRequestTarget","_withRequestTarget"],["getMethod","_getMethod"],["withMethod","_withMethod"],["getUri","_getUri"],["withUri","_withUri"]]}],["Psr\\Http\\Message\\ResponseInterface","Psr.Http.Message.ResponseInterface.html",{"method":[["getStatusCode","_getStatusCode"],["withStatus","_withStatus"],["getReasonPhrase","_getReasonPhrase"]]}],["Psr\\Http\\Message\\StreamInterface","Psr.Http.Message.StreamInterface.html",{"method":[["__toString","___toString"],["close","_close"],["detach","_detach"],["getSize","_getSize"],["tell","_tell"],["eof","_eof"],["isSeekable","_isSeekable"],["seek","_seek"],["rewind","_rewind"],["isWritable","_isWritable"],["write","_write"],["isReadable","_isReadable"],["read","_read"],["getContents","_getContents"],["getMetadata","_getMetadata"]]}],["Psr\\Http\\Message\\UriInterface","Psr.Http.Message.UriInterface.html",{"method":[["getScheme","_getScheme"],["getAuthority","_getAuthority"],["getUserInfo","_getUserInfo"],["getHost","_getHost"],["getPort","_getPort"],["getPath","_getPath"],["getQuery","_getQuery"],["getFragment","_getFragment"],["withScheme","_withScheme"],["withUserInfo","_withUserInfo"],["withHost","_withHost"],["withPort","_withPort"],["withPath","_withPath"],["withQuery","_withQuery"],["withFragment","_withFragment"],["__toString","___toString"]]}],["RuntimeException","RuntimeException.html",[]],["SeekableIterator","SeekableIterator.html",{"method":[["seek","_seek"]]}],["Serializable","Serializable.html",{"method":[["serialize","_serialize"],["unserialize","_unserialize"]]}],["Stringable","Stringable.html",{"method":[["__toString","___toString"]]}],["Symfony\\Component\\OptionsResolver\\Exception\\AccessException","Symfony.Component.OptionsResolver.Exception.AccessException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\ExceptionInterface","Symfony.Component.OptionsResolver.Exception.ExceptionInterface.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\InvalidArgumentException","Symfony.Component.OptionsResolver.Exception.InvalidArgumentException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\InvalidOptionsException","Symfony.Component.OptionsResolver.Exception.InvalidOptionsException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\MissingOptionsException","Symfony.Component.OptionsResolver.Exception.MissingOptionsException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\NoSuchOptionException","Symfony.Component.OptionsResolver.Exception.NoSuchOptionException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\OptionDefinitionException","Symfony.Component.OptionsResolver.Exception.OptionDefinitionException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\UndefinedOptionsException","Symfony.Component.OptionsResolver.Exception.UndefinedOptionsException.html",[]],["Symfony\\Component\\OptionsResolver\\OptionConfigurator","Symfony.Component.OptionsResolver.OptionConfigurator.html",{"method":[["__construct","___construct"],["allowedTypes","_allowedTypes"],["allowedValues","_allowedValues"],["default","_default"],["define","_define"],["deprecated","_deprecated"],["normalize","_normalize"],["required","_required"],["info","_info"],["ignoreUndefined","_ignoreUndefined"]]}],["Symfony\\Component\\OptionsResolver\\Options","Symfony.Component.OptionsResolver.Options.html",[]],["Symfony\\Component\\OptionsResolver\\OptionsResolver","Symfony.Component.OptionsResolver.OptionsResolver.html",{"method":[["setDefault","_setDefault"],["setDefaults","_setDefaults"],["hasDefault","_hasDefault"],["setRequired","_setRequired"],["isRequired","_isRequired"],["getRequiredOptions","_getRequiredOptions"],["isMissing","_isMissing"],["getMissingOptions","_getMissingOptions"],["setDefined","_setDefined"],["isDefined","_isDefined"],["getDefinedOptions","_getDefinedOptions"],["isNested","_isNested"],["setDeprecated","_setDeprecated"],["isDeprecated","_isDeprecated"],["setNormalizer","_setNormalizer"],["addNormalizer","_addNormalizer"],["setAllowedValues","_setAllowedValues"],["addAllowedValues","_addAllowedValues"],["setAllowedTypes","_setAllowedTypes"],["addAllowedTypes","_addAllowedTypes"],["define","_define"],["setInfo","_setInfo"],["getInfo","_getInfo"],["setPrototype","_setPrototype"],["isPrototype","_isPrototype"],["remove","_remove"],["clear","_clear"],["resolve","_resolve"],["offsetGet","_offsetGet"],["offsetExists","_offsetExists"],["offsetSet","_offsetSet"],["offsetUnset","_offsetUnset"],["count","_count"],["setIgnoreUndefined","_setIgnoreUndefined"]]}],["Throwable","Throwable.html",{"method":[["getMessage","_getMessage"],["getCode","_getCode"],["getFile","_getFile"],["getLine","_getLine"],["getTrace","_getTrace"],["getPrevious","_getPrevious"],["getTraceAsString","_getTraceAsString"]]}],["Traversable","Traversable.html",[]]],"function":[["ipay","function-ipay.html"]]}) \ No newline at end of file +window.ApiGen?.resolveElements({"namespace":[["EventSauce","namespace-EventSauce.html"],["EventSauce\\ObjectHydrator","namespace-EventSauce.ObjectHydrator.html"],["Http","namespace-Http.html"],["Http\\Client","namespace-Http.Client.html"],["Http\\Client\\Common","namespace-Http.Client.Common.html"],["Http\\Promise","namespace-Http.Promise.html"],["IPay","namespace-IPay.html"],["IPay\\Api","namespace-IPay.Api.html"],["IPay\\Captcha","namespace-IPay.Captcha.html"],["IPay\\Encryption","namespace-IPay.Encryption.html"],["IPay\\Entity","namespace-IPay.Entity.html"],["IPay\\Exception","namespace-IPay.Exception.html"],["IPay\\Http","namespace-IPay.Http.html"],["IPay\\Http\\Plugin","namespace-IPay.Http.Plugin.html"],["Psr","namespace-Psr.html"],["Psr\\Http","namespace-Psr.Http.html"],["Psr\\Http\\Client","namespace-Psr.Http.Client.html"],["Psr\\Http\\Message","namespace-Psr.Http.Message.html"],["Symfony","namespace-Symfony.html"],["Symfony\\Component","namespace-Symfony.Component.html"],["Symfony\\Component\\OptionsResolver","namespace-Symfony.Component.OptionsResolver.html"],["Symfony\\Component\\OptionsResolver\\Exception","namespace-Symfony.Component.OptionsResolver.Exception.html"],["","namespace-none.html"]],"classLike":[["ArrayAccess","ArrayAccess.html",{"method":[["offsetExists","_offsetExists"],["offsetGet","_offsetGet"],["offsetSet","_offsetSet"],["offsetUnset","_offsetUnset"]]}],["ArrayIterator","ArrayIterator.html",{"method":[["__construct","___construct"],["offsetExists","_offsetExists"],["offsetGet","_offsetGet"],["offsetSet","_offsetSet"],["offsetUnset","_offsetUnset"],["append","_append"],["getArrayCopy","_getArrayCopy"],["count","_count"],["getFlags","_getFlags"],["setFlags","_setFlags"],["asort","_asort"],["ksort","_ksort"],["uasort","_uasort"],["uksort","_uksort"],["natsort","_natsort"],["natcasesort","_natcasesort"],["unserialize","_unserialize"],["serialize","_serialize"],["__serialize","___serialize"],["__unserialize","___unserialize"],["rewind","_rewind"],["current","_current"],["key","_key"],["next","_next"],["valid","_valid"],["seek","_seek"],["__debugInfo","___debugInfo"]]}],["ArrayObject","ArrayObject.html",{"method":[["__construct","___construct"],["offsetExists","_offsetExists"],["offsetGet","_offsetGet"],["offsetSet","_offsetSet"],["offsetUnset","_offsetUnset"],["append","_append"],["getArrayCopy","_getArrayCopy"],["count","_count"],["getFlags","_getFlags"],["setFlags","_setFlags"],["asort","_asort"],["ksort","_ksort"],["uasort","_uasort"],["uksort","_uksort"],["natsort","_natsort"],["natcasesort","_natcasesort"],["unserialize","_unserialize"],["serialize","_serialize"],["__serialize","___serialize"],["__unserialize","___unserialize"],["getIterator","_getIterator"],["exchangeArray","_exchangeArray"],["setIteratorClass","_setIteratorClass"],["getIteratorClass","_getIteratorClass"],["__debugInfo","___debugInfo"]]}],["Closure","Closure.html",{"method":[["bind","_bind"],["bindTo","_bindTo"],["call","_call"],["fromCallable","_fromCallable"]]}],["Countable","Countable.html",{"method":[["count","_count"]]}],["DateInterval","DateInterval.html",{"method":[["__construct","___construct"],["createFromDateString","_createFromDateString"],["format","_format"],["__serialize","___serialize"],["__unserialize","___unserialize"],["__wakeup","___wakeup"],["__set_state","___set_state"]]}],["DateTime","DateTime.html",{"method":[["__construct","___construct"],["__serialize","___serialize"],["__unserialize","___unserialize"],["__wakeup","___wakeup"],["__set_state","___set_state"],["createFromImmutable","_createFromImmutable"],["createFromInterface","_createFromInterface"],["createFromFormat","_createFromFormat"],["getLastErrors","_getLastErrors"],["format","_format"],["modify","_modify"],["add","_add"],["sub","_sub"],["getTimezone","_getTimezone"],["setTimezone","_setTimezone"],["getOffset","_getOffset"],["setTime","_setTime"],["setDate","_setDate"],["setISODate","_setISODate"],["setTimestamp","_setTimestamp"],["getTimestamp","_getTimestamp"],["diff","_diff"]]}],["DateTimeImmutable","DateTimeImmutable.html",{"method":[["__construct","___construct"],["__serialize","___serialize"],["__unserialize","___unserialize"],["__wakeup","___wakeup"],["__set_state","___set_state"],["createFromFormat","_createFromFormat"],["getLastErrors","_getLastErrors"],["format","_format"],["getTimezone","_getTimezone"],["getOffset","_getOffset"],["getTimestamp","_getTimestamp"],["diff","_diff"],["modify","_modify"],["add","_add"],["sub","_sub"],["setTimezone","_setTimezone"],["setTime","_setTime"],["setDate","_setDate"],["setISODate","_setISODate"],["setTimestamp","_setTimestamp"],["createFromMutable","_createFromMutable"],["createFromInterface","_createFromInterface"]]}],["DateTimeInterface","DateTimeInterface.html",{"method":[["format","_format"],["getTimezone","_getTimezone"],["getOffset","_getOffset"],["getTimestamp","_getTimestamp"],["diff","_diff"],["__wakeup","___wakeup"],["__serialize","___serialize"],["__unserialize","___unserialize"]]}],["DateTimeZone","DateTimeZone.html",{"method":[["__construct","___construct"],["getName","_getName"],["getOffset","_getOffset"],["getTransitions","_getTransitions"],["getLocation","_getLocation"],["listAbbreviations","_listAbbreviations"],["listIdentifiers","_listIdentifiers"],["__serialize","___serialize"],["__unserialize","___unserialize"],["__wakeup","___wakeup"],["__set_state","___set_state"]]}],["EventSauce\\ObjectHydrator\\IterableList","EventSauce.ObjectHydrator.IterableList.html",{"method":[["__construct","___construct"],["getIterator","_getIterator"],["toArray","_toArray"]]}],["EventSauce\\ObjectHydrator\\ObjectMapper","EventSauce.ObjectHydrator.ObjectMapper.html",{"method":[["hydrateObject","_hydrateObject"],["hydrateObjects","_hydrateObjects"],["serializeObject","_serializeObject"],["serializeObjectOfType","_serializeObjectOfType"],["serializeObjects","_serializeObjects"]]}],["EventSauce\\ObjectHydrator\\UnableToHydrateObject","EventSauce.ObjectHydrator.UnableToHydrateObject.html",{"method":[["missingFields","_missingFields"],["stack","_stack"],["dueToError","_dueToError"],["dueToMissingFields","_dueToMissingFields"],["noHydrationDefined","_noHydrationDefined"],["classIsNotInstantiable","_classIsNotInstantiable"]]}],["EventSauce\\ObjectHydrator\\UnableToSerializeObject","EventSauce.ObjectHydrator.UnableToSerializeObject.html",{"method":[["dueToError","_dueToError"]]}],["Exception","Exception.html",{"method":[["__construct","___construct"],["__wakeup","___wakeup"],["getMessage","_getMessage"],["getCode","_getCode"],["getFile","_getFile"],["getLine","_getLine"],["getTrace","_getTrace"],["getPrevious","_getPrevious"],["getTraceAsString","_getTraceAsString"],["__toString","___toString"]]}],["Http\\Client\\Common\\HttpMethodsClientInterface","Http.Client.Common.HttpMethodsClientInterface.html",{"method":[["get","_get"],["head","_head"],["trace","_trace"],["post","_post"],["put","_put"],["patch","_patch"],["delete","_delete"],["options","_options"],["send","_send"]]}],["Http\\Client\\Common\\Plugin","Http.Client.Common.Plugin.html",{"method":[["handleRequest","_handleRequest"]]}],["Http\\Client\\Exception","Http.Client.Exception.html",[]],["Http\\Client\\HttpClient","Http.Client.HttpClient.html",[]],["Http\\Promise\\Promise","Http.Promise.Promise.html",{"constant":[["PENDING","PENDING"],["FULFILLED","FULFILLED"],["REJECTED","REJECTED"]],"method":[["then","_then"],["getState","_getState"],["wait","_wait"]]}],["InvalidArgumentException","InvalidArgumentException.html",[]],["IPay\\Api\\AbstractApi","IPay.Api.AbstractApi.html",{"property":[["objectMapper","$objectMapper"],["iPayClient","$iPayClient"]],"method":[["__construct","___construct"],["post","_post"],["createOptionsResolver","_createOptionsResolver"],["getSession","_getSession"]]}],["IPay\\Api\\AuthenticatedApi","IPay.Api.AuthenticatedApi.html",{"method":[["customer","_customer"],["accounts","_accounts"],["historyTransactions","_historyTransactions"]]}],["IPay\\Api\\AuthenticatedSession","IPay.Api.AuthenticatedSession.html",{"method":[["__construct","___construct"],["getRequestParameters","_getRequestParameters"],["getSessionId","_getSessionId"]]}],["IPay\\Api\\BodyBuilder","IPay.Api.BodyBuilder.html",{"method":[["from","_from"],["enhance","_enhance"],["build","_build"],["encrypt","_encrypt"],["__toString","___toString"],["jsonSerialize","_jsonSerialize"]]}],["IPay\\Api\\SessionInterface","IPay.Api.SessionInterface.html",{"method":[["getRequestParameters","_getRequestParameters"]]}],["IPay\\Api\\UnauthenticatedApi","IPay.Api.UnauthenticatedApi.html",{"method":[["login","_login"]]}],["IPay\\Api\\UnauthenticatedSession","IPay.Api.UnauthenticatedSession.html",{"method":[["getRequestParameters","_getRequestParameters"]]}],["IPay\\Captcha\\CaptchaSolver","IPay.Captcha.CaptchaSolver.html",{"method":[["solve","_solve"]]}],["IPay\\Encryption\\Encrypter","IPay.Encryption.Encrypter.html",{"method":[["encrypt","_encrypt"]]}],["IPay\\Entity\\Account","IPay.Entity.Account.html",{"property":[["title","$title"],["number","$number"],["currencyCode","$currencyCode"],["accountState","$accountState"]],"method":[["__construct","___construct"]]}],["IPay\\Entity\\AccountState","IPay.Entity.AccountState.html",{"property":[["availableBalance","$availableBalance"],["balance","$balance"]],"method":[["__construct","___construct"]]}],["IPay\\Entity\\Customer","IPay.Entity.Customer.html",{"property":[["name","$name"],["phone","$phone"],["job","$job"],["accountNumber","$accountNumber"]],"method":[["__construct","___construct"]]}],["IPay\\Entity\\Transaction","IPay.Entity.Transaction.html",{"property":[["currency","$currency"],["amount","$amount"],["remark","$remark"],["corresponsiveAccount","$corresponsiveAccount"],["corresponsiveName","$corresponsiveName"],["processDate","$processDate"]],"method":[["__construct","___construct"]]}],["IPay\\Exception\\LoginException","IPay.Exception.LoginException.html",[]],["IPay\\Exception\\SessionException","IPay.Exception.SessionException.html",[]],["IPay\\Http\\Plugin\\ExceptionThrower","IPay.Http.Plugin.ExceptionThrower.html",{"method":[["handleRequest","_handleRequest"]]}],["IPay\\IPayClient","IPay.IPayClient.html",{"method":[["create","_create"],["getClient","_getClient"],["guest","_guest"],["session","_session"]]}],["Iterator","Iterator.html",{"method":[["current","_current"],["next","_next"],["key","_key"],["valid","_valid"],["rewind","_rewind"]]}],["IteratorAggregate","IteratorAggregate.html",{"method":[["getIterator","_getIterator"]]}],["JsonSerializable","JsonSerializable.html",{"method":[["jsonSerialize","_jsonSerialize"]]}],["LogicException","LogicException.html",[]],["OutOfBoundsException","OutOfBoundsException.html",[]],["Psr\\Http\\Client\\ClientExceptionInterface","Psr.Http.Client.ClientExceptionInterface.html",[]],["Psr\\Http\\Client\\ClientInterface","Psr.Http.Client.ClientInterface.html",{"method":[["sendRequest","_sendRequest"]]}],["Psr\\Http\\Message\\MessageInterface","Psr.Http.Message.MessageInterface.html",{"method":[["getProtocolVersion","_getProtocolVersion"],["withProtocolVersion","_withProtocolVersion"],["getHeaders","_getHeaders"],["hasHeader","_hasHeader"],["getHeader","_getHeader"],["getHeaderLine","_getHeaderLine"],["withHeader","_withHeader"],["withAddedHeader","_withAddedHeader"],["withoutHeader","_withoutHeader"],["getBody","_getBody"],["withBody","_withBody"]]}],["Psr\\Http\\Message\\RequestInterface","Psr.Http.Message.RequestInterface.html",{"method":[["getRequestTarget","_getRequestTarget"],["withRequestTarget","_withRequestTarget"],["getMethod","_getMethod"],["withMethod","_withMethod"],["getUri","_getUri"],["withUri","_withUri"]]}],["Psr\\Http\\Message\\ResponseInterface","Psr.Http.Message.ResponseInterface.html",{"method":[["getStatusCode","_getStatusCode"],["withStatus","_withStatus"],["getReasonPhrase","_getReasonPhrase"]]}],["Psr\\Http\\Message\\StreamInterface","Psr.Http.Message.StreamInterface.html",{"method":[["__toString","___toString"],["close","_close"],["detach","_detach"],["getSize","_getSize"],["tell","_tell"],["eof","_eof"],["isSeekable","_isSeekable"],["seek","_seek"],["rewind","_rewind"],["isWritable","_isWritable"],["write","_write"],["isReadable","_isReadable"],["read","_read"],["getContents","_getContents"],["getMetadata","_getMetadata"]]}],["Psr\\Http\\Message\\UriInterface","Psr.Http.Message.UriInterface.html",{"method":[["getScheme","_getScheme"],["getAuthority","_getAuthority"],["getUserInfo","_getUserInfo"],["getHost","_getHost"],["getPort","_getPort"],["getPath","_getPath"],["getQuery","_getQuery"],["getFragment","_getFragment"],["withScheme","_withScheme"],["withUserInfo","_withUserInfo"],["withHost","_withHost"],["withPort","_withPort"],["withPath","_withPath"],["withQuery","_withQuery"],["withFragment","_withFragment"],["__toString","___toString"]]}],["RuntimeException","RuntimeException.html",[]],["SeekableIterator","SeekableIterator.html",{"method":[["seek","_seek"]]}],["Serializable","Serializable.html",{"method":[["serialize","_serialize"],["unserialize","_unserialize"]]}],["Stringable","Stringable.html",{"method":[["__toString","___toString"]]}],["Symfony\\Component\\OptionsResolver\\Exception\\AccessException","Symfony.Component.OptionsResolver.Exception.AccessException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\ExceptionInterface","Symfony.Component.OptionsResolver.Exception.ExceptionInterface.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\InvalidArgumentException","Symfony.Component.OptionsResolver.Exception.InvalidArgumentException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\InvalidOptionsException","Symfony.Component.OptionsResolver.Exception.InvalidOptionsException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\MissingOptionsException","Symfony.Component.OptionsResolver.Exception.MissingOptionsException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\NoSuchOptionException","Symfony.Component.OptionsResolver.Exception.NoSuchOptionException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\OptionDefinitionException","Symfony.Component.OptionsResolver.Exception.OptionDefinitionException.html",[]],["Symfony\\Component\\OptionsResolver\\Exception\\UndefinedOptionsException","Symfony.Component.OptionsResolver.Exception.UndefinedOptionsException.html",[]],["Symfony\\Component\\OptionsResolver\\OptionConfigurator","Symfony.Component.OptionsResolver.OptionConfigurator.html",{"method":[["__construct","___construct"],["allowedTypes","_allowedTypes"],["allowedValues","_allowedValues"],["default","_default"],["define","_define"],["deprecated","_deprecated"],["normalize","_normalize"],["required","_required"],["info","_info"],["ignoreUndefined","_ignoreUndefined"]]}],["Symfony\\Component\\OptionsResolver\\Options","Symfony.Component.OptionsResolver.Options.html",[]],["Symfony\\Component\\OptionsResolver\\OptionsResolver","Symfony.Component.OptionsResolver.OptionsResolver.html",{"method":[["setDefault","_setDefault"],["setDefaults","_setDefaults"],["hasDefault","_hasDefault"],["setRequired","_setRequired"],["isRequired","_isRequired"],["getRequiredOptions","_getRequiredOptions"],["isMissing","_isMissing"],["getMissingOptions","_getMissingOptions"],["setDefined","_setDefined"],["isDefined","_isDefined"],["getDefinedOptions","_getDefinedOptions"],["isNested","_isNested"],["setDeprecated","_setDeprecated"],["isDeprecated","_isDeprecated"],["setNormalizer","_setNormalizer"],["addNormalizer","_addNormalizer"],["setAllowedValues","_setAllowedValues"],["addAllowedValues","_addAllowedValues"],["setAllowedTypes","_setAllowedTypes"],["addAllowedTypes","_addAllowedTypes"],["define","_define"],["setInfo","_setInfo"],["getInfo","_getInfo"],["setPrototype","_setPrototype"],["isPrototype","_isPrototype"],["remove","_remove"],["clear","_clear"],["resolve","_resolve"],["offsetGet","_offsetGet"],["offsetExists","_offsetExists"],["offsetSet","_offsetSet"],["offsetUnset","_offsetUnset"],["count","_count"],["setIgnoreUndefined","_setIgnoreUndefined"]]}],["Throwable","Throwable.html",{"method":[["getMessage","_getMessage"],["getCode","_getCode"],["getFile","_getFile"],["getLine","_getLine"],["getTrace","_getTrace"],["getPrevious","_getPrevious"],["getTraceAsString","_getTraceAsString"]]}],["Traversable","Traversable.html",[]]],"function":[["ipay","function-ipay.html"]]}) \ No newline at end of file diff --git a/docs/namespace-IPay.Exception.html b/docs/namespace-IPay.Exception.html index 192a02f..af86221 100644 --- a/docs/namespace-IPay.Exception.html +++ b/docs/namespace-IPay.Exception.html @@ -49,13 +49,13 @@

    Namespaces

    Exceptions

    @@ -99,11 +99,11 @@

    Namespace IPay\LoginFailedException + LoginException - SessionExpiredException + SessionException diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 3750f50..a0ee970 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -27,8 +27,8 @@ IPay.Entity.AccountState.html IPay.Entity.Customer.html IPay.Entity.Transaction.html - IPay.Exception.LoginFailedException.html - IPay.Exception.SessionExpiredException.html + IPay.Exception.LoginException.html + IPay.Exception.SessionException.html IPay.Http.Plugin.ExceptionThrower.html IPay.IPayClient.html @@ -46,8 +46,8 @@ source-Entity.Account.html source-Entity.Customer.html source-Entity.Transaction.html - source-Exception.LoginFailedException.html - source-Exception.SessionExpiredException.html + source-Exception.LoginException.html + source-Exception.SessionException.html source-Http.Plugin.ExceptionThrower.html source-IPayClient.html source-functions.html diff --git a/docs/source-Api.AuthenticatedApi.html b/docs/source-Api.AuthenticatedApi.html index 29067ab..9254db3 100644 --- a/docs/source-Api.AuthenticatedApi.html +++ b/docs/source-Api.AuthenticatedApi.html @@ -121,7 +121,7 @@

    Interfaces

    -
    1: <?php
    2:
    3: namespace IPay\Api;
    4:
    5: use IPay\Entity\Account;
    6: use IPay\Entity\Customer;
    7: use IPay\Entity\Transaction;
    8: use Symfony\Component\OptionsResolver\Options;
    9:
    10: /**
    11: * @extends AbstractApi<AuthenticatedSession>
    12: */
    13: class AuthenticatedApi extends AbstractApi
    14: {
    15: /**
    16: * @throws \IPay\Exception\SessionExpiredException
    17: */
    18: public function customer(): Customer
    19: {
    20: return $this->objectMapper->hydrateObject(
    21: Customer::class,
    22: $this->post('getCustomerDetails')['customerInfo'],
    23: );
    24: }
    25:
    26: /**
    27: * @return list<Account>
    28: *
    29: * @throws \IPay\Exception\SessionExpiredException
    30: */
    31: public function accounts(): array
    32: {
    33: return $this->objectMapper->hydrateObjects(
    34: Account::class,
    35: $this->post('getEntitiesAndAccounts')['accounts'],
    36: )->toArray();
    37: }
    38:
    39: /**
    40: * @param array{
    41: * accountNumber: string,
    42: * tranType?: 'Credit'|'Debit'|'',
    43: * startDate?: \DateTimeInterface,
    44: * endDate?: \DateTimeInterface,
    45: * } $parameters
    46: *
    47: * @return \Iterator<int, Transaction>
    48: *
    49: * @throws \IPay\Exception\SessionExpiredException
    50: */
    51: public function historyTransactions(array $parameters): \Iterator
    52: {
    53: $datetimeNormalizer = static function (
    54: Options $resolver,
    55: \DateTimeInterface $value
    56: ): string {
    57: return $value->format('Y-m-d');
    58: };
    59:
    60: $resolver = self::createOptionsResolver()
    61: ->setRequired([
    62: 'accountNumber',
    63: 'tranType',
    64: 'startDate',
    65: 'endDate',
    66: ])
    67: ->setAllowedTypes('accountNumber', 'string')
    68: ->setAllowedValues('tranType', ['Credit', 'Debit', ''])
    69: ->setAllowedTypes('startDate', \DateTimeInterface::class)
    70: ->setAllowedTypes('endDate', \DateTimeInterface::class)
    71: ->setNormalizer('startDate', $datetimeNormalizer)
    72: ->setNormalizer('endDate', $datetimeNormalizer)
    73: ->setDefaults([
    74: 'tranType' => 'Credit',
    75: 'startDate' => new \DateTimeImmutable(),
    76: 'endDate' => new \DateTimeImmutable(),
    77: ])
    78: ;
    79:
    80: $parameters = $resolver->resolve($parameters);
    81:
    82: $parameters['pageNumber'] = 0;
    83: do {
    84: $transactions = $this->post(
    85: 'getHistTransactions',
    86: $parameters
    87: )['transactions'];
    88: foreach ($this->objectMapper->hydrateObjects(
    89: Transaction::class,
    90: $transactions
    91: )->getIterator() as $transaction) {
    92: yield $transaction;
    93: }
    94: ++$parameters['pageNumber'];
    95: } while (count($transactions) > 0);
    96: }
    97: }
    98:
    +
    1: <?php
    2:
    3: namespace IPay\Api;
    4:
    5: use IPay\Entity\Account;
    6: use IPay\Entity\Customer;
    7: use IPay\Entity\Transaction;
    8: use Symfony\Component\OptionsResolver\Options;
    9:
    10: /**
    11: * @extends AbstractApi<AuthenticatedSession>
    12: */
    13: class AuthenticatedApi extends AbstractApi
    14: {
    15: /**
    16: * @throws \IPay\Exception\SessionException
    17: */
    18: public function customer(): Customer
    19: {
    20: return $this->objectMapper->hydrateObject(
    21: Customer::class,
    22: $this->post('getCustomerDetails')['customerInfo'],
    23: );
    24: }
    25:
    26: /**
    27: * @return list<Account>
    28: *
    29: * @throws \IPay\Exception\SessionException
    30: */
    31: public function accounts(): array
    32: {
    33: return $this->objectMapper->hydrateObjects(
    34: Account::class,
    35: $this->post('getEntitiesAndAccounts')['accounts'],
    36: )->toArray();
    37: }
    38:
    39: /**
    40: * @param array{
    41: * accountNumber: string,
    42: * tranType?: 'Credit'|'Debit'|'',
    43: * startDate?: \DateTimeInterface,
    44: * endDate?: \DateTimeInterface,
    45: * } $parameters
    46: *
    47: * @return \Iterator<int, Transaction>
    48: *
    49: * @throws \IPay\Exception\SessionException
    50: */
    51: public function historyTransactions(array $parameters): \Iterator
    52: {
    53: $datetimeNormalizer = static function (
    54: Options $resolver,
    55: \DateTimeInterface $value
    56: ): string {
    57: return $value->format('Y-m-d');
    58: };
    59:
    60: $resolver = self::createOptionsResolver()
    61: ->setRequired([
    62: 'accountNumber',
    63: 'tranType',
    64: 'startDate',
    65: 'endDate',
    66: ])
    67: ->setAllowedTypes('accountNumber', 'string')
    68: ->setAllowedValues('tranType', ['Credit', 'Debit', ''])
    69: ->setAllowedTypes('startDate', \DateTimeInterface::class)
    70: ->setAllowedTypes('endDate', \DateTimeInterface::class)
    71: ->setNormalizer('startDate', $datetimeNormalizer)
    72: ->setNormalizer('endDate', $datetimeNormalizer)
    73: ->setDefaults([
    74: 'tranType' => 'Credit',
    75: 'startDate' => new \DateTimeImmutable(),
    76: 'endDate' => new \DateTimeImmutable(),
    77: ])
    78: ;
    79:
    80: $parameters = $resolver->resolve($parameters);
    81:
    82: $parameters['pageNumber'] = 0;
    83: do {
    84: $transactions = $this->post(
    85: 'getHistTransactions',
    86: $parameters
    87: )['transactions'];
    88: foreach ($this->objectMapper->hydrateObjects(
    89: Transaction::class,
    90: $transactions
    91: )->getIterator() as $transaction) {
    92: yield $transaction;
    93: }
    94: ++$parameters['pageNumber'];
    95: } while (count($transactions) > 0);
    96: }
    97: }
    98:
    -
    1: <?php
    2:
    3: namespace IPay\Api;
    4:
    5: use IPay\Captcha\CaptchaSolver;
    6: use Nette\Utils\Random;
    7:
    8: /**
    9: * @extends AbstractApi<UnauthenticatedSession>
    10: */
    11: class UnauthenticatedApi extends AbstractApi
    12: {
    13: /**
    14: * @param array{
    15: * userName: string,
    16: * accessCode: string,
    17: * } $credentials
    18: *
    19: * @throws \IPay\Exception\LoginFailedException
    20: */
    21: public function login(array $credentials): AuthenticatedApi
    22: {
    23: $resolver = self::createOptionsResolver()
    24: ->setRequired([
    25: 'userName',
    26: 'accessCode',
    27: ])
    28: ->setAllowedTypes('userName', 'string')
    29: ->setAllowedTypes('accessCode', 'string')
    30: ;
    31:
    32: $parameters = $resolver->resolve($credentials) + $this->bypassCaptcha();
    33:
    34: /** @var array{sessionId: string, ...} */
    35: $result = $this->post('signIn', $parameters);
    36:
    37: return new AuthenticatedApi(
    38: $this->iPayClient,
    39: new AuthenticatedSession($result['sessionId'])
    40: );
    41: }
    42:
    43: /**
    44: * @return array{captchaId:string,captchaCode:string}
    45: */
    46: private function bypassCaptcha(): array
    47: {
    48: $captchaId = Random::generate(9, '0-9a-zA-Z');
    49: $svg = (string) $this->iPayClient->getClient()
    50: ->get(sprintf('api/get-captcha/%s', $captchaId))
    51: ->getBody();
    52: $captchaCode = CaptchaSolver::solve($svg);
    53:
    54: return compact('captchaId', 'captchaCode');
    55: }
    56: }
    57:
    +
    1: <?php
    2:
    3: namespace IPay\Api;
    4:
    5: use IPay\Captcha\CaptchaSolver;
    6: use Nette\Utils\Random;
    7:
    8: /**
    9: * @extends AbstractApi<UnauthenticatedSession>
    10: */
    11: class UnauthenticatedApi extends AbstractApi
    12: {
    13: /**
    14: * @param array{
    15: * userName: string,
    16: * accessCode: string,
    17: * } $credentials
    18: *
    19: * @throws \IPay\Exception\LoginException
    20: */
    21: public function login(array $credentials): AuthenticatedApi
    22: {
    23: $resolver = self::createOptionsResolver()
    24: ->setRequired([
    25: 'userName',
    26: 'accessCode',
    27: ])
    28: ->setAllowedTypes('userName', 'string')
    29: ->setAllowedTypes('accessCode', 'string')
    30: ;
    31:
    32: $parameters = $resolver->resolve($credentials) + $this->bypassCaptcha();
    33:
    34: /** @var array{sessionId: string, ...} */
    35: $result = $this->post('signIn', $parameters);
    36:
    37: return new AuthenticatedApi(
    38: $this->iPayClient,
    39: new AuthenticatedSession($result['sessionId'])
    40: );
    41: }
    42:
    43: /**
    44: * @return array{captchaId:string,captchaCode:string}
    45: */
    46: private function bypassCaptcha(): array
    47: {
    48: $captchaId = Random::generate(9, '0-9a-zA-Z');
    49: $svg = (string) $this->iPayClient->getClient()
    50: ->get(sprintf('api/get-captcha/%s', $captchaId))
    51: ->getBody();
    52: $captchaCode = CaptchaSolver::solve($svg);
    53:
    54: return compact('captchaId', 'captchaCode');
    55: }
    56: }
    57:
    -
    1: <?php
    2:
    3: namespace IPay\Exception;
    4:
    5: class LoginFailedException extends \ErrorException
    6: {
    7: }
    8:
    +
    1: <?php
    2:
    3: namespace IPay\Exception;
    4:
    5: class LoginException extends \Exception
    6: {
    7: }
    8:
    -
    1: <?php
    2:
    3: namespace IPay\Exception;
    4:
    5: class SessionExpiredException extends \Exception
    6: {
    7: }
    8:
    +
    1: <?php
    2:
    3: namespace IPay\Exception;
    4:
    5: class SessionException extends \Exception
    6: {
    7: }
    8:
    -
    1: <?php
    2:
    3: namespace IPay\Http\Plugin;
    4:
    5: use Http\Client\Common\Plugin;
    6: use Http\Promise\Promise;
    7: use IPay\Exception\LoginFailedException;
    8: use IPay\Exception\SessionExpiredException;
    9: use Nette\Utils\Json;
    10: use Psr\Http\Message\RequestInterface;
    11: use Psr\Http\Message\ResponseInterface;
    12:
    13: final class ExceptionThrower implements Plugin
    14: {
    15: public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
    16: {
    17: return $next($request)->then(function (ResponseInterface $response): ResponseInterface {
    18: if (200 !== $response->getStatusCode()) {
    19: $error = Json::decode((string) $response->getBody());
    20:
    21: throw self::createException($error);
    22: }
    23:
    24: return $response;
    25: });
    26: }
    27:
    28: /**
    29: * @param \stdClass&object{errorCode: string, errorMessage: string} $error
    30: */
    31: private static function createException(\stdClass $error): \Throwable
    32: {
    33: return match ($error->errorCode) {
    34: 'LOGON_CREDENTIALS_REJECTED' => new LoginFailedException($error->errorMessage),
    35: '96', '99' => new SessionExpiredException('The session has expired.'),
    36: default => new \RuntimeException('Unknown error.'),
    37: };
    38: }
    39: }
    40:
    +
    1: <?php
    2:
    3: namespace IPay\Http\Plugin;
    4:
    5: use Http\Client\Common\Plugin;
    6: use Http\Promise\Promise;
    7: use IPay\Exception\LoginException;
    8: use IPay\Exception\SessionException;
    9: use Nette\Utils\Json;
    10: use Psr\Http\Message\RequestInterface;
    11: use Psr\Http\Message\ResponseInterface;
    12:
    13: final class ExceptionThrower implements Plugin
    14: {
    15: public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
    16: {
    17: return $next($request)->then(function (ResponseInterface $response): ResponseInterface {
    18: if (200 !== $response->getStatusCode()) {
    19: $error = Json::decode((string) $response->getBody());
    20:
    21: throw self::createException($error);
    22: }
    23:
    24: return $response;
    25: });
    26: }
    27:
    28: /**
    29: * @param \stdClass&object{errorCode: string, errorMessage?: string} $error
    30: */
    31: private static function createException(\stdClass $error): \Throwable
    32: {
    33: /** @var class-string<\Exception> */
    34: $class = match ($error->errorCode) {
    35: 'LOGON_CREDENTIALS_REJECTED' => LoginException::class,
    36: '96', '99' => SessionException::class,
    37: default => \RuntimeException::class,
    38: };
    39:
    40: return new $class($error->errorMessage ?? 'Unknown error.');
    41: }
    42: }
    43: