-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK examples #1
Merged
Merged
SDK examples #1
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
88fe5e9
add partner and customer sdk examples.
OvidijusSobut aaa528f
add transaction sdk examples.
OvidijusSobut fc62b99
adjustments to sdk examples
OvidijusSobut d5b589d
adjustments to sdk examples
OvidijusSobut f8a88d2
Remove surname from examples
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,27 @@ Partnero PHP SDK | |
|
||
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE) | ||
|
||
# Table of Contents | ||
|
||
* [Installation](#installation) | ||
* [Usage](#usage) | ||
* [Partners API](#partners-for-affiliate-program) | ||
* [Get a list of partners](#get-a-list-of-partners) | ||
* [Get partner](#get-partner) | ||
* [Create partner](#create-partner) | ||
* [Update partner](#update-partner) | ||
* [Delete partner](#delete-partner) | ||
* [Customers API](#customers) | ||
* [Get a list of customers](#get-a-list-of-customers) | ||
* [Get customer](#get-customer) | ||
* [Create customer](#create-customer) | ||
* [Update customer](#update-customer) | ||
* [Delete customer](#delete-customer) | ||
* [Transactions API](#transactions) | ||
* [Create transaction](#create-transaction) | ||
* [Delete transaction](#delete-transaction) | ||
* [Support and Feedback](#support-and-feedback) | ||
|
||
# Installation | ||
|
||
## Requirements | ||
|
@@ -19,10 +40,200 @@ This library is built atop of [PSR-7](https://www.php-fig.org/psr/psr-7/) and | |
composer require partnero/partnero-php | ||
``` | ||
|
||
<a name="usage"></a> | ||
# Usage | ||
|
||
<a name="partners-api"></a> | ||
## Partners for Affiliate program | ||
|
||
<a name="get-a-list-of-partners"></a> | ||
### Get a list of partners | ||
|
||
```php | ||
use Partnero\Partnero; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$partnero->partners()->list(10); | ||
``` | ||
|
||
<a name="get-partner"></a> | ||
### Get partner | ||
|
||
```php | ||
use Partnero\Partnero; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$partnero->partners()->find('partner-key'); | ||
``` | ||
|
||
<a name="create-partner"></a> | ||
### Create partner | ||
|
||
```php | ||
use Partnero\Partnero; | ||
use Partnero\Models\Partner; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$partner = (new Partner()) | ||
->setEmail('[email protected]') | ||
->setName('Name') | ||
->setKey('partner-key'); | ||
|
||
$partnero->partners()->create($partner); | ||
``` | ||
|
||
Key is optional. | ||
If key is not set, a random key will be generated for the partner. | ||
|
||
<a name="update-partner"></a> | ||
### Update partner | ||
|
||
```php | ||
use Partnero\Partnero; | ||
use Partnero\Models\Partner; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$partner = (new Partner()) | ||
->setEmail('[email protected]') | ||
->setName('John') | ||
->setKey('john-doe'); | ||
|
||
$partnero->partners()->update('partner-key', $partner); | ||
``` | ||
|
||
<a name="delete-partner"></a> | ||
### Delete partner | ||
|
||
```php | ||
use Partnero\Partnero; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$partnero->partners()->delete('john-doe'); | ||
``` | ||
|
||
<a name="customer-api"></a> | ||
## Customers | ||
|
||
<a name="get-a-list-of-customers"></a> | ||
### Get a list of customers | ||
|
||
```php | ||
use Partnero\Partnero; | ||
use Partnero\Models\Partner; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$partner = (new Partner()) | ||
->setKey('partner-key'); | ||
|
||
$partnero->customers()->list(10, $partner); | ||
``` | ||
|
||
<a name="get-customer"></a> | ||
### Get customer | ||
|
||
```php | ||
use Partnero\Partnero; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$partnero->customers()->find('customer-key'); | ||
``` | ||
|
||
<a name="create-customer"></a> | ||
### Create customer | ||
|
||
```php | ||
use Partnero\Partnero; | ||
use Partnero\Models\Partner; | ||
use Partnero\Models\Customer; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$partner = new Partner(); | ||
$partner->setKey('partner-key'); | ||
|
||
$customer = (new Customer()) | ||
->setKey('customer-key') | ||
->setName('Name') | ||
->setEmail('[email protected]'); | ||
|
||
$partnero->customers()->create($customer, $partner); | ||
``` | ||
|
||
<a name="update-customer"></a> | ||
### Update customer | ||
|
||
```php | ||
use Partnero\Partnero; | ||
use Partnero\Models\Customer; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$customer = (new Customer()) | ||
->setKey('new-customer-key') | ||
->setName('John') | ||
->setEmail('[email protected]'); | ||
|
||
$partnero->customers()->update('customer-key', $customer); | ||
``` | ||
|
||
<a name="delete-customer"></a> | ||
### Delete customer | ||
|
||
```php | ||
use Partnero\Partnero; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$partnero->customers()->delete('new-customer-key'); | ||
``` | ||
|
||
<a name="transactions-api"></a> | ||
## Transactions | ||
|
||
<a name="create-transcation"></a> | ||
### Create transaction | ||
|
||
```php | ||
use Partnero\Partnero; | ||
use Partnero\Models\Customer; | ||
use Partnero\Models\Transaction; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$customer = (new Customer()) | ||
->setKey('customer-key'); | ||
|
||
$transaction = (new Transaction()) | ||
->setKey('transaction_123') | ||
->setAmount(99.99) | ||
->setAction('sale'); | ||
|
||
$partnero->transactions()->create($transaction, $customer); | ||
``` | ||
|
||
<a name="delete-transcation"></a> | ||
### Delete transaction | ||
|
||
```php | ||
use Partnero\Partnero; | ||
|
||
$partnero = new Partnero('api_key'); | ||
|
||
$partnero->transactions()->delete('transaction_123'); | ||
``` | ||
|
||
<a name="support-and-feedback"></a> | ||
# Support and Feedback | ||
|
||
In case you find any bugs, submit an issue directly here in GitHub. | ||
|
||
If you have any troubles using our API or SDK free to contact our support by email [[email protected]](mailto:[email protected]) | ||
If you have any troubles using our API or SDK feel free to contact our support by email [[email protected]](mailto:[email protected]) | ||
|
||
The official documentation is at [https://developers.partnero.com](https://developers.partnero.com) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need to be consistent with double or single quotes. I'm voting for single.