Git Product home page Git Product logo

api-client's People

Contributors

bakkerpeter avatar grendel7 avatar terraskye avatar tomassie91 avatar

Stargazers

 avatar

Watchers

 avatar

api-client's Issues

Undefined constant PAGE_SIZE in Api/Pagination.php line 60

When trying to do $model->findPage(), the notice Use of undefined constant PAGE_SIZE - assumed 'PAGE_SIZE' in vendor/afosto/api-client/src/Api/Pagination.php on line 60 is generated.

This issue is caused by:

  • findPage() not passing the provided $pageSize parameter to the Paginator constructor because PaginationTrait->getPagination() doesn't support the attribute.
  • The Pagination constructor defaulting to the PAGE_SIZE constant despite not being certain whether it has been defined.

Recommendation:

  • Define a default page size constant somewhere in the client which is always set to a valid value the paginator can default to.

Fatal error: Class 'Afosto\ApiClient\Components\Storage\FileStorage' not found

I'm unable to use any storage adapter in my project. My code looks as follows:

require_once __DIR__.'/vendor/autoload.php';

$storage = new Afosto\ApiClient\Components\Storage\FileStorage([
    'directory' => $app['base_path'] . '/tmp/'
]);

\Afosto\ApiClient\App::run($storage, $app['config']['api_token'], $app['config']['api_secret']);

In response, I get the following exception:

Fatal error: Class 'Afosto\ApiClient\Components\Storage\FileStorage' not found

I suspect this may have something to do with using PSR-4 autoloading on multiple directories at the same time, confusing the autoloader. Many libraries simply use one base directory and make the namespace tree match the directory tree, rather than using a Yii-like "we have specific directories for everything and load the contents of all of them manually".

Possible endless loop in pagination

For example, I want to paginate over a list of models and compare the results of the current page to the results from the first page. To do this, I write the following snippet:

$model = \Afosto\ApiClient\Models\Products\Product::model();

foreach($model->paginate() as $products){
    $model->findPage(1);
}

Because paginate() and findPage() use the same paginator instance, this will result in an endless loop because findPage(1) will always reset the paginator to page 1.

Another potential issue with sharing the paginator is that if paginate receives a certain page size and findPage defines a different page size, then paginate will also use the first page size, which could cause unpredictable behavior.

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.