Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
vody105 committed Feb 25, 2019
1 parent d6cd0c2 commit dd10e27
Show file tree
Hide file tree
Showing 27 changed files with 1,022 additions and 0 deletions.
112 changes: 112 additions & 0 deletions .docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# GoSMS.cz Api Integration

## Content

- [Requirements - what do you need](#requirements)
- [Installation - how to register an extension](#installation)
- [Usage - how to use it](#usage)


## Requirements

Create account on GoSMS.cz and copy clientId and clientSecret from administration.

If you use default HTTP client, you need to install and register [guzzlette](https://github.com/contributte/guzzlette/) extension.

Default AccessTokenSessionProvider uses [nette/http](https://github.com/nette/http) as its session handler;

* **clientId**
* **clientSecret**
* **httpClient**
* **accessTokenProvider**


## Installation

```yaml
extensions:
guzzlette: Contributte\Guzzlette\DI\GuzzleExtension # optional for default HTTP client
gosms: App\Model\GoSMS\DI\GoSmsExtension

gosms:
# Required
clientId: 10185_2jz2pog5jtgkocs0oc0008kow8kkwsccsk8c8ogogggs44cskg
clientSecret: caajrzi80zs4cwgg8400swwo8wgc4kook0s8s48kw8s00sgws

# Optional
httpClient:
accessTokenProvider:
```
## Usage
We prepared 2 clients: `AccountClient` and `MessageClient`. They mirror methods from [GoSMS.cz Api documentation](https://doc.gosms.cz/) so read documentation first. All methods except `send` return raw data as received from GoSMS.cz api.

All methods throw ClientException with error message and code as response status when response status is not 200/201;

### AccountClient

* `detail()` - [Organization detail](https://doc.gosms.cz/#detail-organizace)

### MessageClient

* `send(Contributte\Gosms\Entity\Message)` - [Sends message](https://doc.gosms.cz/#jak-poslat-zpravu)
* Unfortunately GoSMS.cz does not include newly created message ID. We parse their response for you and include it in result object as `parsedId`. This id is needed by other methods.
* `test(Contributte\Gosms\Entity\Message)` - [Test creating message withou sending](https://doc.gosms.cz/#testovaci-vytvoreni-zpravy-bez-odeslani)
* `detail(string $id)` - [Sent message detail](https://doc.gosms.cz/#detail-zpravy)
* `replies(string $id)` - [List sent message replies](https://doc.gosms.cz/#seznam-odpovedi-u-zpravy)
* `delete(string $id)` - [Delete sent message](https://doc.gosms.cz/#smazani-zpravy)


```php
<?php
namespace App;
use Contributte\Gosms\Client\MessageClient;
use Contributte\Gosms\Entity\Message;
use Contributte\Gosms\Exception\ClientException;
final class SendPaymentsControl extends BaseControl
{
/** @var MessageClient */
private $messageClient;
public function __construct(MessageClient $messageClient)
{
parent::__construct();
$this->messageClient = $messageClient;
}
public function handleSend(): void
{
$result = NULL;
$msg = new Message('Message body', ['+420711555444'], 1);
try {
$result = $this->messageClient->send($msg);
} catch (ClientException $e) {
// Response status
$e->getCode();
// Response body
$e->getMessage();
exit;
}
// Process successful result as you like
$this->saveSentMessage($result->parsedId, $msg);
}
}
```


### AccessTokenProvider

We have two build in AccessToken providers;

* `AccessTokenClient` - fetches and stores accessToken for 1 request
* `AccessTokenSessionProvider` - fetches and stores accessToken in session until access token expires
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = tab
tab_width = 4

[{*.json,*.yml,*.md}]
indent_style = space
indent_size = 2
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Not archived
.docs export-ignore
tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
phpstan.neon export-ignore
README.md export-ignore
ruleset.xml export-ignore
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# IDE
/.idea

# Composer
/vendor
/composer.lock
63 changes: 63 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
language: php
php:
- 7.2
- 7.3

before_install:
# Turn off XDebug
- phpenv config-rm xdebug.ini || return 0

install:
# Composer
- travis_retry composer install --no-progress --prefer-dist

script:
# Tests
- composer run-script tests

after_failure:
# Print *.actual content
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done

jobs:
include:
- env: title="Lowest Dependencies 7.1"
php: 7.2
install:
- travis_retry composer update --no-progress --prefer-dist --prefer-lowest
script:
- composer run-script tests

- stage: Quality Assurance
php: 7.2
script:
- composer run-script qa

- stage: Phpstan
php: 7.2
script:
- composer run-script phpstan

- stage: Test Coverage
if: branch = master AND type = push
php: 7.2
script:
- composer run-script coverage
after_script:
- wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar
- php php-coveralls.phar --verbose --config tests/.coveralls.yml

- stage: Outdated Dependencies
if: branch = master AND type = cron
php: 7.2
script:
- composer outdated --direct --strict

allow_failures:
- stage: Test Coverage

sudo: false

cache:
directories:
- $HOME/.composer/cache
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# GoSMS.cz Api Integration

Easy-to-use [GoSMS.cz](https://gosms.cz) API integration for [`Nette Framework`](https://github.com/nette/).

-----

[![Build Status](https://img.shields.io/travis/contributte/gosms.svg?style=flat-square)](https://travis-ci.org/contributte/gosms)
[![Code coverage](https://img.shields.io/coveralls/contributte/gosms.svg?style=flat-square)](https://coveralls.io/r/contributte/gosms)
[![Licence](https://img.shields.io/packagist/l/contributte/gosms.svg?style=flat-square)](https://packagist.org/packages/contributte/gosms)
[![Downloads this Month](https://img.shields.io/packagist/dm/contributte/gosms.svg?style=flat-square)](https://packagist.org/packages/contributte/gosms)
[![Downloads total](https://img.shields.io/packagist/dt/contributte/gosms.svg?style=flat-square)](https://packagist.org/packages/contributte/gosms)
[![Latest stable](https://img.shields.io/packagist/v/contributte/gosms.svg?style=flat-square)](https://packagist.org/packages/contributte/gosms)
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan)

## Discussion / Help

[![Join the chat](https://img.shields.io/gitter/room/contributte/contributte.svg?style=flat-square)](http://bit.ly/ctteg)

## Install

```
composer require contributte/gosms
```

## Versions

| State | Version | Branch | PHP |
|-------------|---------|----------|----------|
| stable | `^0.1` | `master` | `>= 7.1` |

## Overview

- [Requirements - what do do you need](https://github.com/contributte/gosms/blob/master/.docs/README.md#requirements)
- [Installation - how to register an extension](https://github.com/contributte/gosms/blob/master/.docs/README.md#Installation)
- [Usage - how to use it](https://github.com/contributte/gosms/blob/master/.docs/README.md#usage)

## Maintainers

<table>
<tbody>
<tr>
<td align="center">
<a href="https://github.com/f3l1x">
<img width="150" height="150" src="https://avatars2.githubusercontent.com/u/538058?v=3&s=150">
</a>
</br>
<a href="https://github.com/f3l1x">Milan Felix Šulc</a>
</td>
<td align="center">
<a href="https://github.com/Vody105">
<img width="150" height="150" src="https://avatars2.githubusercontent.com/u/22433893?v=3&s=150">
</a>
</br>
<a href="https://github.com/Vody105">Filip Šuška</a>
</td>
</tr>
</tbody>
</table>

-----

Thank you for testing, reporting and contributing.
57 changes: 57 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "contributte/gosms",
"description": "Full featured GoSMS.cz HTTP client for nette",
"keywords": ["contributte", "gosms", "nette", "sms"],
"type": "library",
"license": "MIT",
"homepage": "https://github.com/contributte/gosms",
"authors": [
{
"name": "Filip Šuška"
}
],
"require": {
"php": ">= 7.2",
"ext-json": "*",
"guzzlehttp/psr7": "^1.4",
"nette/utils": "~2.4 || ~3.0"
},
"require-dev": {
"nette/di": "~2.4",
"contributte/guzzlette": "~2.1",
"nette/http": "~2.4.10",
"ninjify/qa": "^0.8.0",
"ninjify/nunjuck": "^0.2.0",
"mockery/mockery": "^1.1.0",
"phpstan/phpstan-shim": "^0.11",
"phpstan/phpstan-deprecation-rules": "^0.11",
"phpstan/phpstan-nette": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11"
},
"autoload": {
"psr-4": {
"Contributte\\Gosms\\": "src"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"qa": [
"linter src tests",
"codesniffer src tests"
],
"tests": [
"tester -s -p php --colors 1 -C tests/cases"
],
"coverage": [
"tester -s -p phpdbg --colors 1 -C --coverage ./coverage.xml --coverage-src ./src tests/cases"
],
"phpstan": [
"vendor/bin/phpstan analyse -l max -c phpstan.neon src"
]
},
"suggest": {
"contributte/guzzlette": "As default HttpClient",
"nette/http": "As session handler in AccessTokenSessionProvider"
}
}
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
32 changes: 32 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<ruleset name="Contributte">
<!-- Contributte Coding Standard -->
<rule ref="./vendor/ninjify/coding-standard/contributte.xml">
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
</rule>

<!-- Specific rules -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array" value="
src=>Contributte\Gosms,
tests/fixtures=>Tests\Fixtures
"/>
</properties>
</rule>

<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>*tests/cases/*</exclude-pattern>
</rule>

<rule ref="Squiz.Classes.ClassFileName.NoMatch">
<exclude-pattern>*tests/cases/*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.UselessDocComment">
<exclude-pattern>*tests/fixtures/*</exclude-pattern>
</rule>

<!-- Exclude folders -->
<exclude-pattern>/tests/tmp</exclude-pattern>
</ruleset>
Loading

0 comments on commit dd10e27

Please sign in to comment.