Skip to content

Commit

Permalink
Updated files for release 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Faber committed Dec 18, 2019
1 parent 254a7af commit 511a237
Show file tree
Hide file tree
Showing 46 changed files with 1,948 additions and 1,170 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog
All notable changes to the wrapper will be documented in this file.

## [2.0.0]
### Updated
- Support for PHP upgraded to >= 7.2
- Support for PHP 5.6 is now on deprecated. Latest version supporting this is 1.8.4
- Refactored UnitTests for compatibility with PHPUnit 8
- Removed method sendComodoSAEmail on Request Endpoint
- Lowered Endpoint class creation count ($client->certificate()->... is now $client->certificates->...)

### Added
- Created seperate namespace for Helpers that return API Strings

## [1.8.3]
### Added
- Added support for SSLCheck
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xolphin/xolphin-api-php",
"version": "1.8.3",
"version": "2.0.0",
"description": "Xolphin API module for PHP",
"license": "MIT",
"keywords": [
Expand All @@ -26,12 +26,12 @@
"email": "api@xolphin.com"
},
"require": {
"php": ">=5.6.0",
"php": ">=7.2.0",
"guzzlehttp/guzzle": "~6",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^5.3"
"phpunit/phpunit": "~8"
},
"autoload": {
"psr-4": {
Expand Down
103 changes: 71 additions & 32 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
**IMPORTANT: This will be one of the last releases for the v1 major (except for security updates). We're working on a new major version (v2.x) with PHP7 support. From v2 onward, it will no longer be backward compatible with the v1.x releases of the wrapper. Also, we will no longer name the releases after our API version (which will remain at v1).**

# Xolphin API wrapper for PHP
xolphin-php-api is a library which allows quick integration of the [Xolphin REST API](https://api.xolphin.com) in PHP to automated ordering, issuance and installation of SSL Certificates.

## About Xolphin
[Xolphin](https://www.xolphin.nl/) is the largest supplier of [SSL Certificates](https://www.sslcertificaten.nl) and [Digital Signatures](https://www.digitalehandtekeningen.nl) in the Netherlands. Xolphin has a professional team providing reliable support and rapid issuance of SSL Certificates at an affordable price from industry leading brands such as Comodo, GeoTrust, GlobalSign, Thawte and Symantec.
[Xolphin](https://www.xolphin.nl/) is the largest supplier of [SSL Certificates](https://www.sslcertificaten.nl) and [Digital Signatures](https://www.digitalehandtekeningen.nl) in the Netherlands. Xolphin has a professional team providing reliable support and rapid issuance of SSL Certificates at an affordable price from industry leading brands such as Sectigo, GeoTrust, GlobalSign, Thawte and Symantec.

## Library installation

Expand All @@ -20,6 +18,28 @@ And updated via
composer update xolphin/xolphin-api-php
```

### Upgrade guide from v1.8.3 to v2.x
Update your `xolphin/xolphin-api-php` dependency to `^2.0` in your `composer.json` file.

#### Renamed classes
All endpoint classes have been renamed to a more generic name `<resource>Endpoint`. You should update your usages.

#### Calling Endpoint classes
All endpoint classes are started during startup
They can be called using `$client->certificates->all()` instead of `$client->certificate()->all()`.

#### Using Helpers instead of strings
In version 2.0.0 we introduced Helper classes. These classes contain constants of all static string variables (enums).
Use these constants instead of a string, because we will alter these constants whenever we change the corresponding value in the API.

For instance, when creating a DCV for a domain:
```php
$dcvDomain = new Xolphin\Requests\DCVDomain('someDomain', Xolphin\Helpers\DCVTypes::EMAIL_VALIDATION, 'someemail@address.com');
```

#### Certificate download() method returns string
The method `download()` on the class `CertificatesEndpoint` now returns the certificate string instead of the `GuzzlestreamInterface`.

## Usage

### Client initialization
Expand Down Expand Up @@ -51,7 +71,7 @@ echo $requestsRemaining . "\n";
#### Get list of requests

```php
$requests = $client->request()->all();
$requests = $client->requests->all();
foreach($requests as $request) {
echo $request->id . "\n";
}
Expand All @@ -60,17 +80,17 @@ foreach($requests as $request) {
#### Get request by ID

```php
$request = $client->request()->get(1234);
$request = $client->requests->get(1234);
echo $request->id;
```

#### Request certificate

```php
$products = $client->support()->products();
$products = $client->support->products();

// request Comodo EssentialSSL certificate for 1 year
$request = $client->request()->create($products[1]->id, 1, '<csr_string>', 'EMAIL')
// request Sectigo EssentialSSL certificate for 1 year
$request = $client->requests->create($products[1]->id, 1, '<csr_string>', DCVTypes::EMAIL_VALIDATION)
->setAddress("Address")
->setApproverFirstName("FirstName")
->setApproverLastName("LastName")
Expand All @@ -79,82 +99,82 @@ $request = $client->request()->create($products[1]->id, 1, '<csr_string>', 'EMAI
->setCity("City")
->setCompany("Company")
->setApproverEmail('email@domain.com')
//currently available languages: en, de, fr, nl
->setLanguage('en')
//currently available languages defined in RequestLanguages
->setLanguage(RequestLanguage::ENGLISH)
->addSubjectAlternativeNames('test1.domain.com')
->addSubjectAlternativeNames('test2.domain.com')
->addSubjectAlternativeNames('test3.domain.com')
->addDcv(new \Xolphin\Requests\RequestDCV('test1.domain.com', 'EMAIL', 'email1@domain.com'))
->addDcv(new \Xolphin\Requests\RequestDCV('test2.domain.com', 'EMAIL', 'email2@domain.com'));
->addDcv(new \Xolphin\Requests\DCVDomain('test1.domain.com', DCVTypes::EMAIL_VALIDATION, 'email1@domain.com'))
->addDcv(new \Xolphin\Requests\DCVDomain('test2.domain.com', DCVTypes::EMAIL_VALIDATION, 'email2@domain.com'));

$client->request()->send($request);
$client->requests->send($request);
```

#### Reissue certificate

```php
// Reissue a current certificate
$reissue = new \Xolphin\Requests\Reissue('<csr_string>', 'EMAIL');
$reissue = new \Xolphin\Requests\Reissue('<csr_string>', DCVTypes::EMAIL_VALIDATION);
$reissue->setApproverEmail('email@domain.com');

$client->certificate()->reissue(<certificate_id>, $reissue);
$client->certificates->reissue(<certificate_id>, $reissue);
```

#### Renew certificate

```php
// Renew a current certificate
$currentCertificate = $client->certificate()->get(<certificate_id>);
$currentCertificate = $client->certificates->get(<certificate_id>);

$renew = new \Xolphin\Requests\Renew($currentCertificate->product, <years>, '<csr_string>', 'FILE');
$renew = new \Xolphin\Requests\Renew($currentCertificate->product, <years>, '<csr_string>', DCVTypes::FILE_VALIDATION);
$renew->setApproverEmail('email@domain.com');

$client->certificate()->renew(<certificate_id>, $renew)
$client->certificates->renew(<certificate_id>, $renew);
```

#### Create a note

```php
$result = $client->request()->sendNote(1234,'My message');
$result = $client->requests->sendNote(1234,'My message');
```

#### Get list of notes

```php
$notes = $client->request()->getNotes(1234);
$notes = $client->requests->getNotes(1234);
foreach($notes as $note){
echo $note->messageBody . "\n";
echo $note->messageBody . PHP_EOL;
}
```

#### Send a "Comodo Subscriber Agreement" email
#### Send a "Sectigo Subscriber Agreement" email

```php
//currently available languages: en, de, fr, nl
$client->request()->sendComodoSAEmail(1234, 'mail@example.com', 'en');
//currently available languages defined in RequestLanguages
$client->requests->sendSectigoSAEmail(1234, 'mail@example.com', RequestLanguage::ENGLISH);
```

#### Request an "Encryption Everywhere" certificate
```php
$request = $this->_client->request()->createEE();
$request = $this->_client->requests->createEE();
$request->setCsr(<csr_string>);
$request->setApproverEmail('email@example.com');
$request->setApproverFirstName('FirstName');
$request->setApproverLastName('SecondName');
$request->setApproverPhone(+12345678901);
$request->setDcvType('FILE');
$request->setDcvType(DCVTypes::FILE_VALIDATION);
// if you just want to validate
$request->setValidate(true);

$response = $this->_client->request()->sendEE($request);
$response = $client->requests->sendEE($request);
```

### Certificate

#### Certificates list and expirations

```php
$certificates = $client->certificate()->all();
$certificates = $client->certificates->all();
foreach($certificates as $certificate) {
echo $certificate->id . ' - ' . $certificate->isExpired() . "\n";
}
Expand All @@ -163,8 +183,8 @@ foreach($certificates as $certificate) {
#### Download certificate

```php
$certificates = $client->certificate()->all();
$cert = $client->certificate()->download($certificates[0]->id);
$certificates = $client->certificates->all();
$cert = $client->certificates->download($certificates[0]->id, CertificateDownloadTypes::CRT);
file_put_contents('cert.crt', $cert);
```

Expand All @@ -173,7 +193,7 @@ file_put_contents('cert.crt', $cert);
#### List of products

```php
$products = $client->support()->products();
$products = $client->support->products();
foreach($products as $product) {
echo $product->id . "\n";
}
Expand All @@ -182,6 +202,25 @@ foreach($products as $product) {
#### Decode CSR

```php
$csr = $client->support()->decodeCSR('<your csr string>');
$csr = $client->support->decodeCSR('<your csr string>');
echo $csr->type;
```

### Invoices

#### List of invoices

```php
$invoices = $client->invoices->all();
foreach($invoices as $invoice) {
echo $invoice->id . ' ' . $invoice->invoiceNr . ' ' . $invoice->amount . "\n";
}
```

#### Download Invoice in PDF format

```php
$invoices = $client->invoices->all();
$invoicePdf = $client->invoices->download($invoices[0]->id, InvoiceDownloadTypes::PDF);
file_put_contents('invoice.pdf' , $invoicePdf);
```
Loading

0 comments on commit 511a237

Please sign in to comment.