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 b2c93f4
Show file tree
Hide file tree
Showing 49 changed files with 1,808 additions and 1,559 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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 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
104 changes: 66 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,82 @@ 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 | No |
| Delete Publication by slug | No |
| 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');
$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);
```

### 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);

// 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.1",
"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
}
}
}
20 changes: 13 additions & 7 deletions grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ grumphp:
ascii:
failed: ~
succeeded: ~
parallel:
enabled: true
max_workers: 32
fixer:
enabled: true
fix_by_default: false
Expand All @@ -21,15 +18,24 @@ 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]
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 b2c93f4

Please sign in to comment.