Download the PHP package picamator/neo-ws-client without Composer
On this page you can find all versions of the php package picamator/neo-ws-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package neo-ws-client
NeoWsClient
Master
Dev
NeoWsClient - client for NASA Open Api "Near Earth Object Web Service" or NeoWs in short. All NeoWs data is from the NASA JPL Asteroid team.
NeoWsClient supports NeoWs v1 with resources:
- feed
- neo
- stats
Requirements
Installation
Update to your composer.json
with:
Examples
To run examples please create parameters.yml
in config
directory using as a template parameters.yml.dist.
The DEMO_KEY
is a valid api token. It has limitation as requests per hour, per day.
More information in NASA official documentation.
Example list:
- Statistics: GET /rest/v1/stats
- Neo: GET /rest/v1/neo/{asteroid_id}
- Neo browse: GET /rest/v1/neo/browse
- Feed: GET /rest/v1/feed
- Feed detailed: GET /rest/v1/feed
- Feed today: GET /rest/v1/feed/today
- Feed today detailed: GET /rest/v1/feed/today
- Wrong resource 404: GET /rest/v1/wrong-resource
- Wrong api token 403: GET /rest/v1/wrong-resource
- Symfony 2.8 integration: NeoWsExample
Arbitrary precision math
NeoWsClient formats only Date to DateTime object all others keeps original API's.
NeoWs uses string for long precision float like e.g. .6304873017364636
execution floatval
on them would removes last two digits.
Therefore NeoWsClient does not convert strings to int
or float
. To make any math with string floats
please use BCMath.
BCMath takes care of arbitrary precision mathematics.
Technical specification
That section describes extension and configuration points.
Dependency injection
NeoWsClient uses Symfony DI. It's configuration in services.yml.
Data mapping
NeoWsClient works with data mapping to create objects based on Api response.
To make customization or build objects from API response it's need to create mapper repository object.
Mapper repository object is a simple data storage over schema with implementation Mapper\Api\RespositoryInterface
.
The schema contains:
Name | Is required | Description |
---|---|---|
source | yes | Key in API response |
destination | yes | Property inside NeoWsClient value object |
destinationContainer | yes | Name of NeoWsClient object where destination property is located |
schema | no | Sub schema |
collectionOf | no | Interface name of NeoWsClient objects that will be present inside collection. It's an interface of destinationContainer in sub-schema . |
filter | no | Name of NeoWsClient filter object, it runs over API's data |
Errors
There are three different error types:
- Response HTTP codes: 401, 403, 404
- Response HTTP code 200 with empty body
- Exception
Response HTTP codes: 401, 403, 404
In case of getting HTTP codes: 401, 403, 404 or any unsuccessful one application return empty response.
Empty response means valid Response
object where:
- code: is a http code
- data:
stdClass
over body response string - rateLimit: valid rate limit object with data if they are present in API's header
Response HTTP code 200 with empty body
If API returns empty body with HTTP code 200 with several simultaneously requests. The NeoWsClient Manager rise exception ManagerException
in that case.
Because HTTP code 200 means OK, but body is wrong therefore NeoWsClient can not distinguish valid/invalid data by HTTP code.
That exception SHOULD be catch without putting any logic like resend, wait 3 sec. then resend again etc. Instead it's better to have cache over API.
Exception
The full exception list that NeoWsClient rises is in Exception folder. If exception rise it means that application can not proceed request, it does not have any business logic in it.
Documentation
- UML class diagram: class.diagram.png
- Generated documentation: instruction
Developing
To configure developing environment please:
- Follow Docker installation steps
- Run inside Docker container
composer install
Contribution
If you find this project worth to use please add a star. Follow changes to see all activities. And if you see room for improvement, proposals please feel free to create an issue or send pull request. Here is a great guide to start contributing.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project and its community you agree to abide by those terms.
License
NeoWsClient is licensed under the MIT License. Please see the LICENSE file for details.
All versions of neo-ws-client with dependencies
psr/http-message Version ~1.0
guzzlehttp/guzzle Version ~6.2
symfony/dependency-injection Version ~2.8 || ~3.1
symfony/proxy-manager-bridge Version ~2.8 || ~3.1
symfony/config Version ~2.8 || ~3.1
symfony/yaml Version ~2.8 || ~3.1