Download the PHP package kly/onesdk without Composer
On this page you can find all versions of the php package kly/onesdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package onesdk
One.co.id PHP SDK
This SDK is created for easier intergration and API usage of ONE APP.
For publisher only
Prerequisite
- PHP Version >=5.3.3
Installation
If you are using composer you could get it with composer require kly/onesdk
and you are all set. Load up the autoloader and Call the classes or factory you need.
Usage
To use this SDK, there are several basic steps that should be done :
- Create and load credentials (client_id and client_secret or separated one use access_token)
- Instance your content into
\One\Model\Article
object - Attach any necessary details (Photos, Videos, Galleries, Or extra Pages)
- Instance
\One\Publisher
Object - Send your Article object through
submitArticle
method onPublisher
These are some examples code to perform those steps :
Load credentials
Refer to loadTestEnv() method.
Instance publisher object
Publish
If you want to publish an article, there are several steps should be done :
-
Instance article object
-
Attach if article contains some attachments
Article supports multiple kind of attachment such as: photo, page.
- Publish the article to ONE App REST API by submitting through instanced publisher object.
$this->publisher->submitArticle($article);
Fetch
You can fetch all the articles by calling listArticle()
on publisher object.
$this->publisher->listArticle();
Steps to contribute :
-
Fork the original repository to your github repository.
-
Clone from your repository
-
To keep up to date with original repository, run this command
-
Create branch. Remember, the name of branch should express what you're doing.
-
Don't forget to install composer dependencies
-
Modify the .env.example file, to reflect correct credentials.
-
Save the .env.example as .env
-
When you are ready to propose changes to the original repository, it's time to create pull request. To create pull request, run the following commands :
-
Go to your github account, on tab pull request, add your comment. Be detailed, use imperative, emoticon to make it clearer.
- Watch for feedbacks.
PHP CS Fixer
PHP CS Fixer is intended to fix coding standard. So, Remember! to always run PHP CS Fixer before you create pull request.
Testing
How to Run Tests
Open a command prompt or terminal, navigate to project directory and run command composer run test
> php ./phpunit --bootstrap ./test/bootstrap.php ./test/
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
..................
Time: 14 seconds, Memory: 10.00MB
OK (18 tests, 98 assertions)
To see what test is running you can use command composer run test:verbose
> php ./phpunit --bootstrap ./test/bootstrap.php ./test/
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Starting test 'One\Test\Unit\PublisherTest::testSubmitArticleWithoutAttachment'.
.
Starting test 'One\Test\Unit\PublisherTest::testSubmitArticleWithPhotos'.
.
Starting test 'One\Test\Unit\PublisherTest::testSubmitArticleWithPage'.
.
Starting test 'One\Test\Unit\PublisherTest::testSubmitArticleWithGallery'.
.
Starting test 'One\Test\Unit\PublisherTest::testSubmitArticleWithVideo'.
Time: 12.34 seconds, Memory: 10.00MB
OK (18 tests, 98 assertions)
What to Remember When Writing a Test
- Make sure to create test case for every core function on the class.
- Always compare data you expected or created before you make a request with the actual data that you get from a response.
- Use the correct assertion.
Avoid using assertEquals to compare arrays because sometimes you will get array (response from server) values sorted in different order from your expected array. In example:
$array = [ '0'=>'500', '1'=>'A' ];
$arrayFromResponse = [ '0'=>'A', '1'=>'500 ];
Rather than sorting `$arrayFromResponse` to make the order equal, we can use `assertTrue` combine with `array_diff`
assertTrue(empty(array_diff($array, $arrayFromResponse)));
All versions of onesdk with dependencies
psr/log Version ^1.0
psr/http-message Version ^1.0
symfony/polyfill-intl-normalizer Version ^1.8
php-ds/php-ds Version ^1.2