Giter Site home page Giter Site logo

karix-php's People

Contributors

tsudot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

karix-php's Issues

Method sendMessage() throws a 500 error

Hi, I'm using karix-php with cakephp framework 3.4.10 version and when try to send an sms the method throws an error, even though sms is arrived.

Error: [Exception] DateTime::__construct(): Failed to parse time string (2018-09-03T09:28:07.140475154Z) at position 0 (2): The timezone could not be found in the database

Here is a logs:

2018-09-03 09:27:54 Error: [Exception] DateTime::__construct(): Failed to parse time string (2018-09-03T09:28:07.140475154Z) at position 0 (2): The timezone could not be found in the database
Request URL: /users/invite
Stack Trace:
#0 API_V2/vendor/karixtech/karix-php/lib/ObjectSerializer.php(261): DateTime->__construct('2018-09-03T09:2...')
#1 API_V2/vendor/karixtech/karix-php/lib/ObjectSerializer.php(311): Swagger\Client\ObjectSerializer::deserialize('2018-09-03T09:2...', '\DateTime', NULL)
#2 API_V2/vendor/karixtech/karix-php/lib/ObjectSerializer.php(247): Swagger\Client\ObjectSerializer::deserialize(Object(stdClass), '\Swagger\Client...', NULL)
#3 API_V2/vendor/karixtech/karix-php/lib/ObjectSerializer.php(311): Swagger\Client\ObjectSerializer::deserialize(Array, '\Swagger\Client...', NULL)
#4 API_V2/vendor/karixtech/karix-php/lib/Api/MessageApi.php(775): Swagger\Client\ObjectSerializer::deserialize(Object(stdClass), '\Swagger\Client...', Array)
#5 API_V2/vendor/karixtech/karix-php/lib/Api/MessageApi.php(715): Swagger\Client\Api\MessageApi->sendMessageWithHttpInfo('1.0', Object(Swagger\Client\Model\CreateMessage))
#6 API_V2/src/Controller/Component/SmsProviders/KarixProvider.php(83): Swagger\Client\Api\MessageApi->sendMessage('1.0', Object(Swagger\Client\Model\CreateMessage))
#7 API_V2/src/Controller/Component/SmsComponent.php(52): App\Controller\Component\SmsProviders\KarixProvider->sendMessage('+380675872686', 'New user i...')
#8 API_V2/plugins/Invitations/src/Controller/AppController.php(56): App\Controller\Component\SmsComponent->sendMessage('+380675872686', 'New user i...')
#9 API_V2/vendor/cakephp/cakephp/src/Controller/Controller.php(440): Invitations\Controller\AppController->inviteBulk()
#10 API_V2/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(119): Cake\Controller\Controller->invokeAction()
#11 API_V2/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(93): Cake\Http\ActionDispatcher->_invoke(Object(Invitations\Controller\AppController))
#12 API_V2/vendor/cakephp/cakephp/src/Http/BaseApplication.php(78): Cake\Http\ActionDispatcher->dispatch(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#13 API_V2/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Http\BaseApplication->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#14 API_V2/src/Routing/Middleware/CorsMiddleware.php(32): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#15 API_V2/vendor/cakephp/cakephp/src/Http/Runner.php(65): App\Routing\Middleware\CorsMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#16 API_V2/vendor/cakephp/cakephp/src/Routing/Middleware/RoutingMiddleware.php(59): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#17 API_V2/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Routing\Middleware\RoutingMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#18 API_V2/vendor/cakephp/cakephp/src/Routing/Middleware/AssetMiddleware.php(88): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#19 API_V2/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Routing\Middleware\AssetMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#20 API_V2/vendor/cakephp/cakephp/src/Error/Middleware/ErrorHandlerMiddleware.php(92): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#21 API_V2/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#22 API_V2/vendor/cakephp/debug_kit/src/Middleware/DebugKitMiddleware.php(52): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#23 API_V2/vendor/cakephp/cakephp/src/Http/Runner.php(65): DebugKit\Middleware\DebugKitMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#24 API_V2/vendor/cakephp/cakephp/src/Http/Runner.php(51): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#25 API_V2/vendor/cakephp/cakephp/src/Http/Server.php(80): Cake\Http\Runner->run(Object(Cake\Http\MiddlewareQueue), Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#26 API_V2/webroot/index.php(37): Cake\Http\Server->run()
#27 {main}

Here is my class for sending messages (according to article https://blog.karix.io/how-to-send-an-sms-using-php-helper-library):

use Cake\Core\Configure;
use Cake\Core\Exception\Exception;
use Cake\Http\Client;
use Swagger\Client\Api\MessageApi;
use Swagger\Client\Configuration;
use Swagger\Client\Model\CreateMessage;

/**
 * Class KarixProvider
 * @package App\Controller\Component\SmsProviders
 */
class KarixProvider implements SmsProviderInterface
{
    /**
     * Host url
     *
     * @var string
     */
    private $host = 'https://api.karix.io';

    /**
     * Version of a Karix API
     *
     * @var string
     */
    private $apiVersion = '1.0';

    /**
     * configuration for the Karix platform
     *
     * @var
     */
    private $config;

    /**
     * KarixProvider constructor.
     * @param $params
     */
    public function __construct($params)
    {
        $config = new Configuration();
        $config->setUsername(Configure::read('SmsProviders.Karix.AUTH_ID'));
        $config->setPassword(Configure::read('SmsProviders.Karix.AUTH_TOKEN'));
        return $this->config = $config;
    }

    /**
     * Create instance of Message object
     *
     * @return MessageApi
     */
    public function apiInstance()
    {
        return new MessageApi(
        // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
        // This is optional, `GuzzleHttp\Client` will be used as default.
            new \GuzzleHttp\Client(),
            $this->config);
    }

    /**
     * Send message to recipient
     *
     * @param $recipient
     * @param $text
     * @return \Cake\Network\Response
     */
    public function sendMessage($recipient, $text)
    {
        $message = new CreateMessage();

        date_default_timezone_set('UTC');

        $message->setDestination([$recipient]);
        $message->setSource(Configure::read('SmsProviders.Karix.SOURCE_NUMBER'));
        $message->setText($text);

        try {
            $result = $this->apiInstance()->sendMessage($this->apiVersion, $message);
            return response(__("success"));
        } catch (Exception $e) {
            return response('Exception when calling MessageApi->createMessage: ' .
                $e->getMessage() . PHP_EOL, 400);
        }
    }

Class 'Brick\Math\BigDecimal' not found

I am using laravel and when I send sms I got this error
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'Brick\Math\BigDecimal' not found

The SMS message sent but with internal server error 500 so this make problems with my API client

I tried to fix it by myself but I did not find the class Brick\Math\BigDecimal in this class ObjectSerializer here is the link to the line which I mean https://github.com/karixtech/karix-php/blob/v2/lib/ObjectSerializer.php#L32

and the problem occurs at this line of code https://github.com/karixtech/karix-php/blob/v2/lib/ObjectSerializer.php#L268

I hope I get solution of my problem!

Class 'Karix\Configuration' not found

Got Class 'Karix\Configuration' not found error in laravel and when I try to install using
composer require "karixtech/karix-php" package folder is empty under vendor folder.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.