CallFire/CallFire-PHP-SDK

error missing Swagger\Document::setDefaultScheme()

Closed this issue · 10 comments

Running this simple demo script. Cannot make connection to callfire servers

require 'vendor/autoload.php';
$client = \CallFire\Api\DocumentedClient::createClient("***", "***");
$request = $client->findCallBroadcasts();
$response = $client->request($request);
$json = json_decode($response->getBody());

I get this error, tried on PHP5.6 , 7 in localhost and production environment.
Fatal error: Call to undefined method Swagger\Document::setDefaultScheme() in /vendor/thefrozenfire/swagger-client/src/Swagger/Client.php on line 20

Hi, please describe how you installed sdk?
Did you use composer for that?

yes I used composer with following command
composer require callfire/php-sdk:^2.0
I use Mac and MAMP for localhost, tested it on CentOS 7 on linux server same error. I checked the code and couldn't find this method setDefaultScheme

This is the project repo - https://github.com/atanasov/test-firecall
I added all files even vendor folder. It's just simple test. Try it with your credentials and test it.
I still get the same error.
Fatal error: Call to undefined method Swagger\Document::setDefaultScheme() in /Users/user/Documents/www/test-firecall/vendor/thefrozenfire/swagger-client/src/Swagger/Client.php on line 20

Thanks.

Thanks, working on that.

Please use composer.lock file from repository to download correct dependencies versions.
We'll think how to avoid this problem in future and add comment to README at least.

Just put this https://github.com/CallFire/CallFire-PHP-SDK/blob/2.0/composer.lock to your project here:
https://github.com/atanasov/test-firecall/blob/master/composer.lock.

For now when you are loading dependencies using composer.json - it loads the ^2.0 dependecies and one of them already haven't setDefaultScheme method in Document class.

It's not working. When I change my composer.lock file. and do composer install it doesn't load CallFirePHP sdk files. Just sdk dependencies. I added callfire folder manually in vendor folder and added links for it in composer autload_namespaces.php and some other files and again get new error message.

Fatal error: Uncaught exception 'Swagger\Exception\InvalidOperationException' with message 'Operation by the specified ID does not exist' in /Users/user/Documents/www/test-firecall/vendor/thefrozenfire/swagger/src/Swagger/Exception/InvalidOperationException.php:13
Stack trace:
#0 /Users/user/Documents/www/test-firecall/vendor/thefrozenfire/swagger/src/Swagger/Document.php(62): Swagger\Exception\InvalidOperationException::assess(Array, 'findvoicebroadc...')
#1 /Users/user/Documents/www/test-firecall/vendor/thefrozenfire/swagger-client/src/Swagger/Client.php(55): Swagger\Document->getOperationById('findVoiceBroadc...')
#2 /Users/user/Documents/www/test-firecall/vendor/thefrozenfire/swagger-client/src/Swagger/Client.php(107): Swagger\Client->createRequest('findVoiceBroadc...', Object(Swagger\Client\SecurityCredential\Basic))
#3 /Users/user/Documents/www/test-firecall/test.php(6): Swagger\Client->__call('findVoiceBroadc...', Array)
#4 /Users/user/Documents/www/test-firecall/test.php(6): CallFire\Api\Client->findVoiceBroadcast in /Users/user/Documents/www/test-firecall/vendor/thefrozenfire/swagger/src/Swagger/Exception/InvalidOperationException.php on line 13

Please if you can do it and make it working on my test project - give me commit / pull request.

Can't push.
Failed with error: fatal: unable to access 'https://github.com/atanasov/test-firecall.git/': The requested URL returned error: 403

In any case Fatal error: Uncaught exception 'Swagger\Exception\InvalidOperationException' error means that you tried to use operation which doesn't exist anymore in callfire apis.

$request = $client->findCallBroadcasts(); - should be like this, we don't have findVoiceBroadcasts.
We've already updated docs to fix example. Just didn't release them yet.

Please generate code hints to see what operations are supported.
You can do that:

  1. go to test-firecall/vendor/callfire/php-sdk
  2. php src/CallFire/CodeHint/CodeHintsGenerator.php generateCodeHints

File test-firecall\vendor\callfire\php-sdk\src\CallFire\Api\DocumentedClient.php will include generated supported operations with examples how to use.

OK thanks, finally it works.

Really appreciate your help.