Skip to content

Commit

Permalink
Initial commit for API v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lasse Lehtinen committed May 7, 2024
1 parent 2934381 commit f4bbaa3
Show file tree
Hide file tree
Showing 52 changed files with 1,842 additions and 1,588 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Tests

on:
push:
paths:
- '**.php'
- '.github/workflows/run-tests.yml'
- 'phpunit.xml.dist'
- 'composer.json'
- 'composer.lock'

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.3, 8.2]
stability: [prefer-lowest, prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Run syntax checks
run: vendor/bin/grumphp run --tasks=composer,phplint

- name: Run security checks
run: vendor/bin/grumphp run --tasks=securitychecker_roave

- name: Run style checks
run: vendor/bin/grumphp run --tasks=phpcs

- name: Run static analysis
run: vendor/bin/grumphp run --tasks=phpstan
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor
composer.lock
.idea/
.phpunit.result.cache
.phpunit.cache
.phpunit.result.cache
4 changes: 4 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
build:
image: default-bionic
environment:
php: 8.2.1
filter:
excluded_paths: [tests/*]
checks:
Expand Down
1 change: 0 additions & 1 deletion .styleci.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

128 changes: 86 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,105 @@
[![Latest Version](https://img.shields.io/packagist/v/lasselehtinen/issuu.svg)](https://github.com/lasselehtinen/issuu/releases)
[![Build Status](https://img.shields.io/travis/lasselehtinen/issuu/master.svg?style=flat-square)](https://travis-ci.org/lasselehtinen/issuu)
[![Quality Score](https://img.shields.io/scrutinizer/g/lasselehtinen/issuu.svg?style=flat-square)](https://scrutinizer-ci.com/g/lasselehtinen/issuu)
[![StyleCI](https://styleci.io/repos/111231767/shield)](https://styleci.io/repos/111231767)
![Latest build](https://github.com/lasselehtinen/issuu/actions/workflows/run-tests.yml/badge.svg)

# Issuu - API client for PHP

## Notes

The version 3.0 is for the Issuu API v2. Old API was deprecated on May 1st, 2024.

## Installation
You can install this package via composer using this command:
```shell
composer require lasselehtinen/issuu
```
## Supported functionality
# Drafts
| Endpoint | Supported |
|----------------------------------------|-----------|
| List drafts | Yes |
| Create a new Draft | Yes |
| Delete a Draft by slug | Yes |
| Update a Draft by slug | Yes |
| Upload a document for a Draft by slug | Yes |
| Publish a Draft by slug | Yes |

# Publications
| Endpoint | Supported |
|------------------------------------------|-----------|
| List Publications | Yes |
| Get Publication by slug | Yes |
| Delete Publication by slug | Yes |
| Get Publication assets by slug | No |
| Get Publication Fullscreen share by slug | No |
| Get Publication Reader Share URL by slug | No |
| Get Publication QRCode share by slug | No |
| Get Publication Embed code by slug | No |

# Stacks
| Endpoint | Supported |
|---------------------------------------|-----------|
| List Stacks | Yes |
| Create a new Stack | No |
| Get Stack data by ID | No |
| Delete a Stack by ID | No |
| Update Stack data by ID | No |
| Get Stack Items slug | No |
| Add Stack Item by slug to stack | No |
| Delete Stack Item by slug from stack | No |

# Stats
| Endpoint | Supported |
|---------------------------------------|-----------|
| Get Stats | No |

# User
| Endpoint | Supported |
|---------------------------------------|-----------|
| Get User Profile | No |
| Get User Features | No |

## Usage
### Creating a client
First create a new instance with your API key and secret:
```php
use lasselehtinen\Issuu\Issuu;

$issuu = new Issuu('apiSecret', 'apiKey');
```

### Bookmarks
```php
use lasselehtinen\Issuu\Bookmarks;

$bookmarks = new Bookmarks($issuu);

// Available methods - See the methods DocBlock documentation for information about all available parameters
$bookmarksAdd = $bookmarks->add('publination', '081024182109-9280632f2866416d97634cdccc66715d');
$bookmarksList = $bookmarks->list();
$bookmarksDelete = $bookmarks->delete('11b27cd5-ecdc-4c39-b818-8f3c8eca443c');
```

### Documents
```php
use lasselehtinen\Issuu\Documents;

$documents = new Documents($issuu);

// Available methods - See the methods DocBlock documentation for information about all available parameters
$documentsUpload = $documents->upload('/path/to/local/file.pdf');
$documentsUrlUpload = $documents->urlUpload('http://www.example.com/sample.pdf');
$documentsList = $documents->list();
$documentsUpdate = $documents->update('racing', 'Rally cars');
$documentsDelete = $documents->delete('racing');
```

### Folders
```php
use lasselehtinen\Issuu\Folders;

$folders = new Folders($issuu);
$issuu = new Issuu('apiKey');
$drafts = new Drafts($issuu);

$body = [
'confirmCopyright' => true,
'fileUrl' => 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
'info' => [
'file' => 0,
'access' => 'PUBLIC',
'title' => 'Example title',
'description' => 'Description',
'preview' => false,
'type' => 'editorial',
'showDetectedLinks' => false,
'downloadable' => false,
'originalPublishDate' => '1970-01-01T00:00:00.000Z',
],
];

$createDraft = $drafts->create($body);
$drafts->publishDraftBySlug($createDraft->slug);

// Try few times until the file is converted
for ($i=0; $i < 10; $i++) {
$draft = $drafts->getDraftBySlug($createDraft->slug);
$conversionStatus = $draft->fileInfo->conversionStatus;

if ($conversionStatus === 'DONE') {
break;
}

sleep(2);
}

$publishDraftBySlug = $drafts->publishDraftBySlug($createDraft->slug, ['desiredName' => 'foobar']);

// Available methods - See the methods DocBlock documentation for information about all available parameters
$foldersAdd = $folders->add('Cool stuff');
$foldersList = $folders->list();
$foldersUpdate = $folders->update('4c3ba964-60c3-4349-94d0-ff86db2d47c9', 'New folder name');
$foldersDelete = $folders->delete('4c3ba964-60c3-4349-94d0-ff86db2d47c9');
```

## Contributing
Expand Down
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpro/grumphp": "^1.4",
"squizlabs/php_codesniffer": "^3.1"
"squizlabs/php_codesniffer": "^3.7",
"php-parallel-lint/php-parallel-lint": "^1.4",
"roave/security-advisories": "latest-dev",
"phpstan/phpstan": "^1.10"
},
"autoload": {
"psr-4": {
Expand All @@ -27,5 +30,10 @@
"classmap": [
"tests/TestCase.php"
]
},
"config": {
"allow-plugins": {
"phpro/grumphp": false
}
}
}
18 changes: 14 additions & 4 deletions grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,25 @@ grumphp:
paths: []
tasks:
composer:
securitychecker_local:
phpunit:
config_file: ~
phplint:
triggered_by: ['php']
securitychecker_roave:
run_always: true
phpstan:
level: 9
ignore_patterns:
- "vendor*"
triggered_by: ['php']
memory_limit: "-1"
phpcs:
standard: PSR2
tab_width: 4
triggered_by: [php]
warning_severity: 6
ignore_patterns:
- "vendor*"
- "tests*"
phpunit:
config_file: ~

testsuites: []
extensions: []
94 changes: 0 additions & 94 deletions src/Bookmarks.php

This file was deleted.

Loading

0 comments on commit f4bbaa3

Please sign in to comment.