File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# openiai
2+
3+ * Version:* ` 0.1.3 `
4+
5+ This library is yet unfinished. Use it only at your own risk.
6+ Feel free to contribute.
7+
8+
9+ ## Summary
10+
211Open IAI API PHP wrapper library.
12+
13+ This is a Laravel library that lets you easily connect to IdoSell Shop API
14+ and make requests. It aims to cover the whole API (all gates and methods,
15+ which are automatically looked for).
16+
17+
18+ ## Requirements
19+ * PHP 7.2
20+ * Laravel 5.8
21+ * ext-json
22+ * ext-soap
23+
24+ ## Installation
25+
26+ Simply use Composer to install this package, either by executing CLI command
27+ in your project directory:
28+
29+ ``` bash
30+ composer require tombabolewski/openiai
31+ ```
32+
33+ or by adding the following line to your ` composer.json ` file in ` require `
34+ section:
35+
36+ ``` json
37+ "require" : {
38+ "tombabolewski/openiai" : " ^0.1.3"
39+ }
40+ ```
41+
42+ Next, you should add the Service Provider to your ` config/app.php ` file.
43+ Just add the following line to the ` providers ` array, preferably at the end:
44+
45+ ``` php
46+ 'providers' => [
47+ // (...)
48+ Tombabolewski/Openiai/OpeniaiServiceProvider::class,
49+ ],
50+ ```
51+
52+ If you would like, you can also add an alias to the ` aliases ` array like that:
53+ ``` php
54+ 'aliases' => [
55+ // (...)
56+ 'Openiai' => Tombabolewski/Openiai/Client::class
57+ ],
58+ ```
59+
60+
61+ ## Usage
62+
63+ Section under construction ;]
64+
65+ Example:
66+ ``` php
67+ //Create openiai client instance
68+ $client = app()->make('Openiai');
69+
70+ //Get all products
71+ $products = $client->Products->get();
72+ ```
Original file line number Diff line number Diff line change 11{
2- "name" : " tombabolewski/openiai" ,
3- "description" : " Open IAI API PHP wrapper library" ,
4- "type" : " library" ,
5- "support" : {
6- "source" : " https://github.com/tombabolewski/openiai" ,
7- "issues" : " https://github.com/ltombabolewski/openiai/issues"
8- },
9- "require" : {
10- "php" : " >=7.1" ,
11- "ext-json" : " *" ,
12- "laravel/laravel" : " 5.8" ,
13- "league/csv" : " ^9.3" ,
14- "guzzle/http" : " ^3.9"
15- },
16- "license" : " MIT" ,
17- "authors" : [
18- {
19- "name" : " Thomas Lucifer Babolewski" ,
20- "email" : " spootek@gmail.com"
21- }
22- ],
23- "autoload" : {
24- "psr-4" : {
25- "Tombabolewski\\ Openiai\\ " : " src/"
26- }
27- },
28- "extra" : {
29- "laravel" : {
30- "providers" : [
31- " Tomabolewski\\ Openiai\\ Providers\\ openiaiServiceProvider"
32- ]
33- }
2+ "name" : " tombabolewski/openiai" ,
3+ "description" : " Open IAI API PHP wrapper library" ,
4+ "type" : " library" ,
5+ "support" : {
6+ "source" : " https://github.com/tombabolewski/openiai" ,
7+ "issues" : " https://github.com/tombabolewski/openiai/issues"
8+ },
9+ "require" : {
10+ "php" : " >=7.2" ,
11+ "ext-json" : " *" ,
12+ "laravel/laravel" : " 5.8" ,
13+ "league/csv" : " ^9.3" ,
14+ "guzzle/http" : " ^3.9"
15+ },
16+ "license" : " MIT" ,
17+ "authors" : [
18+ {
19+ "name" : " Tomasz Babolewski" ,
20+ "email" : " spootek@gmail.com"
3421 }
22+ ],
23+ "autoload" : {
24+ "psr-4" : {
25+ "Tombabolewski\\ Openiai\\ " : " src/"
26+ }
27+ },
28+ "extra" : {
29+ "laravel" : {
30+ "providers" : [
31+ " Tombabolewski\\ Openiai\\ OpeniaiServiceProvider"
32+ ],
33+ "aliases" : {
34+ "OpenIAI" : " Tombabolewski\\ Openiai\\ Facade"
35+ }
36+ }
37+ }
3538}
Load diff This file was deleted.
Load diff This file was deleted.
Load diff This file was deleted.
Original file line number Diff line number Diff line change 33
44namespace Tombabolewski \Openiai ;
55
6- use Guzzle \ Http \ Client as HttpClient ;
6+ use Tombabolewski \ Openiai \ Structure \ ApiVersion ;
77
88class Client
99{
10- public function __construct ()
10+ protected $ version ;
11+
12+ public function __construct ($ version = 0 )
1113 {
14+ if (!$ version ) {
15+ $ version = config ('API_DEFAULT_VERSION ' );
16+ }
17+ $ this ->setVersion ($ version );
18+ }
1219
20+ public function setVersion ($ versionSignature )
21+ {
22+ $ this ->version = new ApiVersion ($ versionSignature );
1323 }
1424}
Original file line number Diff line number Diff line change 11<?php
22
33
4- namespace Tombabolewski \Openiai ;
4+ namespace Tombabolewski \Openiai \ Exception ;
55use Exception ;
66
77class ApiException extends Exception
Original file line number Diff line number Diff line change @@ -10,6 +10,6 @@ class Facade extends BaseFacade
1010{
1111 public static function getFacadeAccessor ()
1212 {
13- return 'IAI ' ;
13+ return 'openiai ' ;
1414 }
1515}
Original file line number Diff line number Diff line change 33namespace App \Providers ;
44
55use Illuminate \Support \ServiceProvider ;
6+ use Tombabolewski \Openiai \Client ;
67
7- class openiaiServiceProvider extends ServiceProvider
8+ class OpeniaiServiceProvider extends ServiceProvider
89{
910 /**
1011 * Register services.
@@ -13,7 +14,7 @@ class openiaiServiceProvider extends ServiceProvider
1314 */
1415 public function register ()
1516 {
16- //
17+ $ this -> mergeConfigFrom ( __DIR__ . ' /config/openiai.php ' , ' openiai ' );
1718 }
1819
1920 /**
@@ -23,6 +24,11 @@ public function register()
2324 */
2425 public function boot ()
2526 {
26- //
27+ $ this ->publishes ([
28+ __DIR__ . '/config/openiai.php ' => config_path ('openiai.php ' ),
29+ ]);
30+ $ this ->app ->bind ('openiai ' , function ($ app ) {
31+ return new Client ();
32+ });
2733 }
2834}
Original file line number Diff line number Diff line change 11<?php
22
33
4- namespace Tombabolewski \Openiai ;
4+ namespace Tombabolewski \Openiai \ Response ;
55
66
77use Exception ;
@@ -53,7 +53,7 @@ public function offsetGet($offset)
5353 if (!$ this ->offsetExists ($ offset )) {
5454 throw new Exception ('Offset does not exist ' );
5555 }
56- if ($ this ->current ()->getPage () = == $ offset ) {
56+ if ($ this ->current ()->getPage () ! == $ offset ) {
5757 $ this ->currentPage = $ this ->getParentMethod ()->exec ($ offset , $ this ->requestParams );
5858 }
5959 return $ this ->current ();
@@ -114,8 +114,9 @@ public function current()
114114 public function next ()
115115 {
116116 $ nextPage = $ this ->getParentMethod ()->getPage () + 1 ;
117- if (!$ this ->offsetExists ($ nextPage ))
118- $ this ->currentPage = $ this ->getParentMethod ()->exec ($ nextPage , $ this ->requestParams );
117+ if (!$ this ->offsetExists ($ nextPage )){
118+ $ this ->currentPage = $ this ->getParentMethod ()->exec ($ nextPage , $ this ->requestParams );
119+ }
119120 }
120121
121122 /**
@@ -138,7 +139,8 @@ public function key()
138139 */
139140 public function valid ()
140141 {
141- return isset ($ this ->currentPage ) && !is_null ($ this ->currentPage );
142+ return isset ($ this ->currentPage )
143+ && !is_null ($ this ->currentPage );
142144 }
143145
144146 /**
You can’t perform that action at this time.
0 commit comments