|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +</div> |
| 10 | + |
| 11 | +# Connector |
| 12 | +A Laravel package as connector between Affiliate with Products. |
| 13 | + |
| 14 | +## Warning |
| 15 | +This package for internal purposes, any incoming issues won't be responded. |
| 16 | + |
| 17 | +## Installation |
| 18 | +Run these command into your laravel project folder. |
| 19 | +``` |
| 20 | +composer require crenata/affiliate-connector |
| 21 | +``` |
| 22 | + |
| 23 | +### Publish Configuration |
| 24 | +You need to publish the package's config. To publish configuration, run the following command. |
| 25 | +``` |
| 26 | +php artisan vendor:publish --tag=connector-config |
| 27 | +``` |
| 28 | + |
| 29 | +### Generate Authentication Bridge |
| 30 | +To secure the bridge, You must generate `secret key` and `private key` to your `server` and `client` project. To generate the key, run the following command. |
| 31 | +``` |
| 32 | +php artisan connector:generate |
| 33 | +``` |
| 34 | +And you will see. |
| 35 | +``` |
| 36 | +Server : CONNECTOR_SERVER=dc6917876732a081d1d35b225aedab5bae8e5438 |
| 37 | +Client : CONNECTOR_CLIENT=ba770d272202ad9b938638687760e2ec96a7e954b19447fd5f412c615e2c7ef7 |
| 38 | +
|
| 39 | +Copy the key to the .env file each projects. |
| 40 | +``` |
| 41 | +In the server section, add `CONNECTOR_SERVER` to .env file. And also in the client section, add `CONNECTOR_CLIENT` to .env file. |
| 42 | + |
| 43 | +## Usage |
| 44 | +Make sure you're following these steps. |
| 45 | + |
| 46 | +### Create Get All Product |
| 47 | +Create your query to get all products, and change default controller in `config/connector.php` to your created controller. |
| 48 | +``` |
| 49 | +"api" => [ |
| 50 | + [ |
| 51 | + "method" => HttpMethodConstant::GET, |
| 52 | + "url" => "products", |
| 53 | + "controller" => "Crenata\AffiliateConnector\Http\Controllers\ConnectorController@getProducts" // Replace with your controller. |
| 54 | + ], |
| 55 | + ... |
| 56 | +] |
| 57 | +``` |
| 58 | +Expected Return : |
| 59 | +``` |
| 60 | +[ |
| 61 | + [ |
| 62 | + "id" => int, |
| 63 | + "name" => string, |
| 64 | + "description" => string, |
| 65 | + "price" => int |
| 66 | + ], |
| 67 | + ... |
| 68 | +] |
| 69 | +``` |
| 70 | + |
| 71 | +### Create Get Product With Ids |
| 72 | +Create your query to get products using `WHERE id IN()`, and change default controller in `config/connector.php` to your created controller. At this request, you will receive query string with param `ids` as `string` that contains `product ids` separated by `comma`. |
| 73 | +``` |
| 74 | +"api" => [ |
| 75 | + [ |
| 76 | + "method" => HttpMethodConstant::GET, |
| 77 | + "url" => "product-with-ids", |
| 78 | + "controller" => "Crenata\AffiliateConnector\Http\Controllers\ConnectorController@getProductWithIds" // Replace with your controller. |
| 79 | + ], |
| 80 | + ... |
| 81 | +] |
| 82 | +``` |
| 83 | +Expected Return : |
| 84 | +``` |
| 85 | +[ |
| 86 | + [ |
| 87 | + "id" => int, |
| 88 | + "name" => string, |
| 89 | + "description" => string, |
| 90 | + "price" => int |
| 91 | + ], |
| 92 | + ... |
| 93 | +] |
| 94 | +``` |
| 95 | + |
| 96 | +### Create Find Product |
| 97 | +Create your query to get product using `WHERE id`, and change default controller in `config/connector.php` to your created controller. At this request, you will receive query string with param `id` as `int`. |
| 98 | +``` |
| 99 | +"api" => [ |
| 100 | + [ |
| 101 | + "method" => HttpMethodConstant::GET, |
| 102 | + "url" => "find-product", |
| 103 | + "controller" => "Crenata\AffiliateConnector\Http\Controllers\ConnectorController@findProduct" // Replace with your controller. |
| 104 | + ], |
| 105 | + ... |
| 106 | +] |
| 107 | +``` |
| 108 | +Expected Return : |
| 109 | +``` |
| 110 | +[ |
| 111 | + "id" => int, |
| 112 | + "name" => string, |
| 113 | + "description" => string, |
| 114 | + "price" => int |
| 115 | +] |
| 116 | +``` |
| 117 | + |
| 118 | +## Authors |
| 119 | +- [Hafiizh Ghulam](mailto:hafiizh.ghulam@frisidea.com) |
0 commit comments