This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree 4 files changed +124
-0
lines changed
4 files changed +124
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Grayloon \Magento \Api ;
4
+
5
+ class Sources extends AbstractApi
6
+ {
7
+ /**
8
+ * inventoryApiSourcesRepositoryV1
9
+ * All of paginated sources.
10
+ *
11
+ * @param int $pageSize
12
+ * @param int $currentPage
13
+ * @param array $filters
14
+ *
15
+ * @return array
16
+ */
17
+ public function all ($ pageSize = 50 , $ currentPage = 1 , $ filters = [])
18
+ {
19
+ return $ this ->get ('/inventory/sources ' , array_merge ($ filters , [
20
+ 'searchCriteria[pageSize] ' => $ pageSize ,
21
+ 'searchCriteria[currentPage] ' => $ currentPage ,
22
+ ]));
23
+ }
24
+
25
+ /**
26
+ * inventoryApiSourcesRepositoryV1
27
+ * Return Specific Source by name.
28
+ *
29
+ * @param string $name
30
+ *
31
+ * @return array
32
+ */
33
+ public function bySourceName ($ name = 'default ' )
34
+ {
35
+ return $ this ->get ('/inventory/sources/ ' .$ name );
36
+ }
37
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Grayloon \Magento \Api ;
4
+
5
+ class Stocks extends AbstractApi
6
+ {
7
+ /**
8
+ * inventoryApiStocksRepositoryV1
9
+ * All of paginated stock items.
10
+ *
11
+ * @param int $pageSize
12
+ * @param int $currentPage
13
+ * @param array $filters
14
+ *
15
+ * @return array
16
+ */
17
+ public function all ($ pageSize = 50 , $ currentPage = 1 , $ filters = [])
18
+ {
19
+ return $ this ->get ('/inventory/stocks ' , array_merge ($ filters , [
20
+ 'searchCriteria[pageSize] ' => $ pageSize ,
21
+ 'searchCriteria[currentPage] ' => $ currentPage ,
22
+ ]));
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Grayloon \Magento \Tests ;
4
+
5
+ use Grayloon \Magento \Api \Sources ;
6
+ use Grayloon \Magento \MagentoFacade ;
7
+ use Illuminate \Support \Facades \Http ;
8
+
9
+ class SourcesTest extends TestCase
10
+ {
11
+ public function test_can_instantiate_sources ()
12
+ {
13
+ $ this ->assertInstanceOf (Sources::class, MagentoFacade::api ('sources ' ));
14
+ }
15
+
16
+ public function test_can_call_sources_all ()
17
+ {
18
+ Http::fake ([
19
+ '*rest/all/V1/inventory/sources* ' => Http::response ([], 200 ),
20
+ ]);
21
+
22
+ $ api = MagentoFacade::api ('sources ' )->all ();
23
+
24
+ $ this ->assertTrue ($ api ->ok ());
25
+ }
26
+
27
+ public function test_can_call_sources_by_source_name ()
28
+ {
29
+ Http::fake ([
30
+ '*rest/all/V1/inventory/sources/default* ' => Http::response ([], 200 ),
31
+ ]);
32
+
33
+ $ api = MagentoFacade::api ('sources ' )->bySourceName ();
34
+
35
+ $ this ->assertTrue ($ api ->ok ());
36
+ }
37
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Grayloon \Magento \Tests ;
4
+
5
+ use Grayloon \Magento \Api \Stocks ;
6
+ use Grayloon \Magento \MagentoFacade ;
7
+ use Illuminate \Support \Facades \Http ;
8
+
9
+ class StocksTest extends TestCase
10
+ {
11
+ public function test_can_instantiate_stocks ()
12
+ {
13
+ $ this ->assertInstanceOf (Stocks::class, MagentoFacade::api ('stocks ' ));
14
+ }
15
+
16
+ public function test_can_call_stocks_all ()
17
+ {
18
+ Http::fake ([
19
+ '*rest/all/V1/inventory/stocks* ' => Http::response ([], 200 ),
20
+ ]);
21
+
22
+ $ api = MagentoFacade::api ('stocks ' )->all ();
23
+
24
+ $ this ->assertTrue ($ api ->ok ());
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments