Skip to content

Commit

Permalink
Document simple usage example.
Browse files Browse the repository at this point in the history
  • Loading branch information
garthbrantley committed Sep 11, 2022
1 parent ab9db4b commit bd76329
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,33 @@ vendor/bin/phpunit

## Getting Started

Simple usage looks like:
Simple usage looks like (example fetching a list of products):

```php
<?php

use SubscribePro\Sdk;

// Set credentials
$clientId = 'XXXX';
$clientSecret = 'XXXX';

// Set log message format
$messageFormat = "SUBSCRIBE PRO REST API Call: {method} - {uri}\nRequest body: {req_body}\n{code} {phrase}\nResponse body: {res_body}\n{error}\n";

// Create SDK object
// Setup with Platform API base url and credentials from Magento config
$sdk = new Sdk([
'client_id' => $clientId,
'client_secret' => $clientSecret,
'logging_enable' => true,
'logging_file_name' => 'var/log/subscribe_pro_api.log',
'logging_message_format' => $messageFormat,
'api_request_timeout' => 60,
]);

$products = $sdk
->getProductService()
->loadProducts(['sku' => 'SOME-EXAMPLE-SKU']);

```

0 comments on commit bd76329

Please sign in to comment.