Skip to content

Commit

Permalink
v2.0.0-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
awd-studio committed Jan 19, 2019
1 parent 1588a7d commit e7331d8
Show file tree
Hide file tree
Showing 125 changed files with 3,283 additions and 8,897 deletions.
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Ignore vendors
/vendor

# Ignore composer.lock file
/build/
/vendor/
/composer.lock

# Ignore build
/build
/phpunit.xml
105 changes: 68 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<h1 align="center">Powerful & Simple NovaPoshta API SDK for PHP</h1>
<h1 align="center">NovaPoshta API SDK for PHP</h1>

<p align="center">Fast and easy, integrate your PHP apps with <a href="https://devcenter.novaposhta.ua/docs/services/">official API</a>.</p>
<p align="center">PHP-library to work with the <a href="https://devcenter.novaposhta.ua/docs/services/">NovaPoshta API v2</a>.</p>

<p align="center">
<a href="https://travis-ci.org/awd-studio/NovaPoshta" title="Build Status"><img src="https://travis-ci.org/awd-studio/NovaPoshta.svg?branch=master" alt="Build Status" /></a>
<a href="https://travis-ci.org/awd-studio/NovaPoshta" title="Build Status"><img src="https://travis-ci.org/awd-studio/NovaPoshta.svg?branch=dev" alt="Build Status" /></a>
<a href="https://coveralls.io/github/awd-studio/NovaPoshta" title="Coverage Status"><img src="https://coveralls.io/repos/github/awd-studio/NovaPoshta/badge.svg" alt="Coverage Status" /></a>
<a href="https://packagist.org/packages/awd-studio/NovaPoshta" title="Latest Stable Version"><img src="https://poser.pugx.org/awd-studio/NovaPoshta/v/stable" alt="Latest Stable Version" /></a>
<a href="https://packagist.org/packages/awd-studio/NovaPoshta" title="Total Downloads"><img src="https://poser.pugx.org/awd-studio/NovaPoshta/downloads" alt="Total Downloads" /></a>
<a href="https://github.com/awd-studio/NovaPoshta/blob/master/LICENSE" title="License"><img src="https://poser.pugx.org/awd-studio/NovaPoshta/license" alt="License" /></a>
<a href="https://github.com/awd-studio/NovaPoshta/blob/dev/LICENSE" title="License"><img src="https://poser.pugx.org/awd-studio/NovaPoshta/license" alt="License" /></a>
</p>


### About Nova Poshta company:

Today Nova Poshta is a leader in express delivery owing to its innovation approach and hard work on efficiency improvement. By anticipating Client needs, the company constantly comes up with new products and services.
Expand All @@ -32,53 +31,85 @@ Nova Poshta puts into your service:

*[More information](https://novaposhta.ua/en/o_kompanii/nova_poshta_sogodni).*

### Install:
```bash
composer require 'awd-studio/novaposhta:^2.0@dev'
```

### Very simple usage (see more examples below):
```php
<?php

use NP\NP;

$response = NP::init($key)->sendWith('Address', 'searchSettlements', [
'StreetName' => 'Шев',
'SettlementRef' => 'e715719e-4b33-11e4-ab6d-005056801329',
'Limit' => 10,
]);
### Uninstall:
```bash
composer remove awd-studio/novaposhta
```

## Requirements
- PHP 7+
- PHP 7.2+
- [Composer](https://getcomposer.org) package manager
- [API token](https://devcenter.novaposhta.ua/blog/%D0%BF%D0%BE%D0%BB%D1%83%D1%87%D0%B5%D0%BD%D0%B8%D0%B5-api-%D0%BA%D0%BB%D1%8E%D1%87%D0%B0)
- [Guzzle](https://github.com/guzzle/guzzle) or [PHP_CURL](http://php.net/manual/book.curl.php) libraries for sending HTTP-requests *(optional - you can define custom HTTP-driver)*
- [PHP_CURL](http://php.net/manual/book.curl.php) library for sending HTTP-requests *(you can define your custom HTTP-driver as well)*

### Usage:

## Install
Via [Composer](https://getcomposer.org/)
```bash
composer require awd-studio/novaposhta
```
#### POST request:
```php
<?php

## Uninstall
```bash
composer remove awd-studio/novaposhta
use \AwdStudio\NovaPoshta\Config;
use \AwdStudio\NovaPoshta\Http\CurlRequestFactory;
use \AwdStudio\NovaPoshta\Method\Address\SearchSettlements;
use \AwdStudio\NovaPoshta\Serialization\JsonSerializer;

// Set up
$apiKey = '[MY_API_KEY]';
$config = Config::create($apiKey);

// Create needle method
$cityName = 'київ';
$limit = 5;
$method = new SearchSettlements();
$method->setCityName($cityName);
$method->setLimit($limit);

// Serialization
$serializer = new JsonSerializer();

// Request
$requestFactory = new CurlRequestFactory();
$requestFactory->setConfig($config);
$requestFactory->setMethod($method);
$requestFactory->setSerializer($serializer);
$request = $requestFactory->build();

// Execute request
$responseData = $request->execute();

// Deserialize response
$response = $serializer->deserialize($responseData);
```

## Usage:

#### GET request:
```php
<?php

use NP\NP;
use \AwdStudio\NovaPoshta\Config;
use \AwdStudio\NovaPoshta\Http\CurlRequestFactory;
use \AwdStudio\NovaPoshta\Method\Orders\PrintDocument;

$np = NP::init(['key' => 'yourApiKey', 'driver' => $yourDriver]);
// Set up
$apiKey = '[MY_API_KEY]';
$config = Config::create($apiKey);

// Simple usage methods:
$np->with('modelName', 'methodName', $data);
$response = $np->send();
$docRefs = ['20600000002260'];
$type = 'pdf';
$method = new PrintDocument();
$method->setOrders($docRefs);
$method->setType($type);

// Or more simple:
$response = $np->sendWith('modelName', 'methodName', $data);
```
// Request
$requestFactory = new CurlRequestFactory();
$requestFactory->setConfig($config);
$requestFactory->setMethod($method);
$request = $requestFactory->build();

[See details.](https://devcenter.novaposhta.ua/docs/services/55702570a0fe4f0cf4fc53ed) All methods implements.
// Response
$response = $request->execute();
```
35 changes: 15 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "awd-studio/novaposhta",
"description": "NovaPoshta API SDK for PHP",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Anton Karpov",
"email": "[email protected]",
"role": "Developer"
"email": "[email protected]"
}
],
"description": "Powerful & Simple NovaPoshta API SDK for PHP",
"keywords": [
"branch-offices",
"delivery",
Expand All @@ -25,35 +25,30 @@
"ukraine",
"wrapper-api"
],
"homepage": "https://github.com/awd-studio/NovaPoshta",
"support": {
"issues": "https://github.com/awd-studio/NovaPoshta/issues",
"source": "https://github.com/awd-studio/NovaPoshta"
},
"minimum-stability": "dev",
"type": "library",
"require": {
"php": "^7.0",
"ext-json": "*"
"php": "^7.2",
"ext-json": "*",
"ext-curl": "*"
},
"require-dev": {
"phpunit/phpunit": "^6",
"php-coveralls/php-coveralls": "^2.0@dev"
"phpunit/phpunit": "^7.4.0",
"php-coveralls/php-coveralls": "2.1.x-dev"
},
"autoload": {
"psr-4": {
"NP\\": "src/NP"
"AwdStudio\\NovaPoshta\\": "src/NovaPoshta"
}
},
"autoload-dev": {
"psr-4": {
"NP\\Test\\": "tests/NP",
"NP\\Mock\\": "tests/Mock"
"AwdStudio\\NovaPoshta\\Test\\": "tests/NovaPoshta",
"AwdStudio\\NovaPoshta\\Mock\\": "tests/Mock"
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"coverage": "vendor/bin/phpunit -c ./phpunit.xml.dist",
"test": "vendor/bin/phpunit --bootstrap vendor/autoload.php",
"coverage": "vendor/bin/phpunit --bootstrap vendor/autoload.php -c ./phpunit.xml.dist",
"coveralls": "php vendor/bin/coveralls -v"
}
},
"minimum-stability": "dev"
}
7 changes: 2 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,21 @@
processIsolation="false"
stopOnFailure="false"
forceCoversAnnotation="true">
<title>NovaPoshta</title>

<testsuites>
<testsuite name="NovaPoshta Test Suite">
<directory>./tests/</directory>
<directory>./tests/NovaPoshta/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
<directory suffix=".php">./src/NovaPoshta/</directory>
</whitelist>
</filter>

<logging>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
Loading

0 comments on commit e7331d8

Please sign in to comment.