Skip to content

Commit ee50b7c

Browse files
authored
Merge pull request #1 from ingrammicro/marcserrat-patch-1
Modified Readme File
2 parents 7e325d8 + 6ec1cd4 commit ee50b7c

File tree

2 files changed

+106
-58
lines changed

2 files changed

+106
-58
lines changed

README.md

Lines changed: 105 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,121 @@
11
![Connect PHP SDK](./assets/connect-logo.png)
22

3-
# Connect PHP SDK ·
3+
# CloudBlue Connect PHP fulfillment SDK
44

5-
## ChangeLog
5+
## Getting Started
6+
CloudBlue PHP SDK allows an easy and fast integration with [CloudBlue Connect](http://connect.cloud.im/) fulfillment API. Thanks to it you can automate the fulfillment of orders generated by your products.
67

7-
* vNext
8-
* Initial version of APS Connect SDK with basic features:
9-
* query requests list
10-
* invoke user-defined processing procedure
11-
* handle processing results
12-
* update request parameters if required
13-
* logging functionality
14-
* collect debug logs in case of failure
8+
In order to use this library, please ensure that you have read first the documentation available on CloudBlue Connect knowladge base article located [here](http://help.vendor.connect.cloud.im/support/solutions/articles/43000030735-fulfillment-management-module), this one will provide you a great information on the rest api that this library implements.
159

16-
## Installing / Getting started
10+
## Class Features
1711

18-
## Developing
12+
This library may be consumed in your project in order to automate the fulfillment of requests, this class once imported into your project will allow you to:
1913

20-
### Built With
21-
List main libraries, frameworks used including versions
14+
- Connect to CloudBlue Connect using your api credentials
15+
- List all requests, and even filter them:
16+
- for a Concrete product
17+
- for a concrete status
18+
- Process each request and obtain full details of the request
19+
- Modify for each request the activation parameters in order to:
20+
- Inquiry for changes
21+
- Store information into the fulfillment request
22+
- Change the status of the requests from it's initial pending state to either inquiring, failed or approved.
23+
- Generate logs
24+
- Collect debug logs in case of failure
2225

23-
### Prerequisites
24-
What is needed to set up the dev environment. For instance, global dependencies or any other tools. include download links.
26+
Your code may use any scheduler to execute, from a simple cron to a cloud scheduler like the ones available in Azure, Google, Amazon or other cloud platforms.
2527

26-
### Setting up Dev
28+
## Installation & loading
29+
CloudBlue PHP SDK is available on [Packagist](https://packagist.org/packages/cloudblue/connect-sdk) (using semantic versioning), and installation via [Composer](https://getcomposer.org) is the recommended way to install CloudBlue PHP SDK. Just add this line to your `composer.json` file:
2730

28-
Here's a brief intro about what a developer must do in order to start developing
29-
the project further:
30-
31-
```shell
32-
git clone https://github.com/your/your-project.git
33-
cd your-project/
34-
packagemanager install
31+
```json
32+
"cloudblue/connect-sdk": "~1.0"
3533
```
3634

37-
And state what happens step-by-step. If there is any virtual environment, local server or database feeder needed, explain here.
38-
39-
### Building
40-
41-
If your project needs some additional steps for the developer to build the
42-
project after some code changes, state them here. for example:
35+
or run
4336

44-
```shell
45-
./configure
46-
make
47-
make install
37+
```sh
38+
composer require cloudblue/connect-sdk
4839
```
4940

50-
Here again you should state what actually happens when the code above gets
51-
executed.
52-
53-
## Versioning
54-
55-
We can maybe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [link to tags on this repository](/tags).
56-
57-
## Configuration
58-
59-
Here you should write what are all of the configurations a user can enter when
60-
using the project.
61-
62-
## Tests
63-
64-
Describe and show how to run the tests with code examples.
65-
Explain what these tests test and why.
66-
67-
```shell
68-
Give an example
41+
Note that the `vendor` folder and the `vendor/autoload.php` script are generated by Composer
42+
43+
## A Simple Example
44+
45+
```php
46+
<?php
47+
48+
require_once "vendor/autoload.php";
49+
50+
/**
51+
* Class ProductRequests
52+
*/
53+
class ProductRequests extends \Connect\RequestsProcessor
54+
{
55+
/**
56+
* ProductRequests constructor.
57+
* @param $config
58+
* @throws ReflectionException
59+
* @throws \Connect\ConfigException
60+
* @throws \Connect\ConfigPropertyInvalid
61+
* @throws \Connect\ConfigPropertyMissed
62+
*/
63+
function __construct($config)
64+
{
65+
parent::__construct($config);
66+
}
67+
68+
/**
69+
* @param \Connect\Request $request
70+
* @return string|void
71+
* @throws Exception
72+
* @throws \Connect\Exception
73+
* @throws \Connect\Fail
74+
* @throws \Connect\Skip
75+
*/
76+
function processRequest($request)
77+
{
78+
Connect\Logger::get()->info("Processing Request: " . $request->id . " for asset: " . $request->asset->id);
79+
switch ($request->type) {
80+
case "purchase":
81+
if($request->asset->params['email']->value == ""){
82+
throw new \Connect\Inquire(array(
83+
$request->asset->params['email']->error("Email address has not been provided, please provide one")
84+
));
85+
}
86+
foreach ($request->asset->items as $item) {
87+
if ($item->quantity > 1000000) {
88+
Connect\Logger::get()->info("Is Not possible to purchase product " . $item->id . " more than 1000000 time, requested: " . $item->quantity);
89+
throw new \Connect\Fail("Is Not possible to purchase product " . $item->id . " more than 1000000 time, requested: " . $item->quantity);
90+
}
91+
else {
92+
//Do some provisoning operation
93+
//Update the parameters to store data
94+
$paramsUpdate[] = new \Connect\Param('ActivationKey', 'somevalue');
95+
return;
96+
}
97+
}
98+
case "cancel":
99+
//Handle cancellation request
100+
case "change":
101+
//Handle change request
102+
default:
103+
throw new \Connect\Fail("Operation not supported:".$request->type);
104+
}
105+
}
106+
}
107+
108+
//Main Code Block
109+
try {
110+
$apiConfig = array(
111+
'apiKey' => 'Key_Available_in_ui',
112+
'apiEndpoint' => 'https://api.connect.cloud.im/public/v1',
113+
'products' => 'CN-631-322-641' #Optional value
114+
);
115+
$requests = new ProductRequests($apiConfig);
116+
$requests->process();
117+
118+
} catch (Exception $e) {
119+
print "Error processing requests:" . $e->getMessage();
120+
}
69121
```
70-
71-
## Style guide
72-
73-
Explain your code style and show how to check it.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Ingram Micro CloudBlue APS Connect QuickStart SDK",
55
"license": "proprietary",
66
"require": {
7-
"php": ">=5.6.0",
7+
"php": ">=5.4.0",
88
"ext-curl": "*",
99
"ext-json": "*",
1010
"ext-Reflection": "*"

0 commit comments

Comments
 (0)