<commit_before>LaravelShipStation
===============
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Latest Version on Packagist][packagist-downloads]][link-packagist]
[![Build Status](https://travis-ci.org/joecampo/laravel-shipstation.svg?branch=master)](https://travis-ci.org/joecampo/laravel-shipstation)

This is a simple PHP API wrapper for [ShipStation](http://shipstation.com) built for Laravel 5.\*.

Installation
------------
This package can be installed via [Composer](http://getcomposer.org) by requiring the ```campo/laravel-shipstation``` package in your project's ```composer.json```
```json
{
    "require": {
        "campo/laravel-shipstation": "~3.0"
    }
}
```

Then at your Laravel project root run:
```sh
composer update
```

Second, add the LaravelShipStation service provider to your providers array located in ```config/app.php```
```php
LaravelShipStation\ShipStationServiceProvider::class
```

After installing via composer you will need to publish the configuration:
```php
php artisan vendor:publish
```
This will create the configuration file for your API key and API secret key at ```config/shipstation.php```. You will need to obtain your API & Secret key from ShipStation: [How can I get access to ShipStation's API?](https://help.shipstation.com/hc/en-us/articles/206638917-How-can-I-get-access-to-ShipStation-s-API-)
## Dependencies
LaravelShipStation uses ```GuzzleHttp\Guzzle```
## Endpoints
Endpoints for the API are accessed via properties (e.g. ```$shipStation->orders->get($options)``` will make a GET request to ```/orders/{$options}```). The default endpoint is /orders/. Valid endpoints include:
* accounts
* carriers
* customers
* fulfillments
* orders
* products
* shipments
* stores
* users
* warehouses
* webhooks

## Methods
### GET
```php
$shipStation->{$endpoint}->get($options = [], $endpoint = '');
```
Example of getting an order with the orderId of 1.
```php
$shipStation = $this->app['LaravelShipStation\ShipStation'];
$options = ['orderId' => 1];
$order = $shipStation->orders->get($options);
````
### POST
```php
$shipStation->{$endpoint}->post($options = [], $endpoint = '');
```
The second parameter ($endpoint) is for any additional endpoints that need to be added. For example, to create an order the POST request would go to /orders/createorder. "createorder" is the additional endpoint since we specify the root endpoint as a property: ```$shipstation->orders->post($options, 'createorders')```

There are models that contain all of the properties available via the API. These models will be converted to arrays when passed to the API.
<commit_msg>Fetching by `orderId` done with `$endpoint` argument. `$options` returns all results.<commit_after>LaravelShipStation
===============
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Latest Version on Packagist][packagist-downloads]][link-packagist]
[![Build Status](https://travis-ci.org/joecampo/laravel-shipstation.svg?branch=master)](https://travis-ci.org/joecampo/laravel-shipstation)

This is a simple PHP API wrapper for [ShipStation](http://shipstation.com) built for Laravel 5.\*.

Installation
------------
This package can be installed via [Composer](http://getcomposer.org) by requiring the ```campo/laravel-shipstation``` package in your project's ```composer.json```
```json
{
    "require": {
        "campo/laravel-shipstation": "~3.0"
    }
}
```

Then at your Laravel project root run:
```sh
composer update
```

Second, add the LaravelShipStation service provider to your providers array located in ```config/app.php```
```php
LaravelShipStation\ShipStationServiceProvider::class
```

After installing via composer you will need to publish the configuration:
```php
php artisan vendor:publish
```
This will create the configuration file for your API key and API secret key at ```config/shipstation.php```. You will need to obtain your API & Secret key from ShipStation: [How can I get access to ShipStation's API?](https://help.shipstation.com/hc/en-us/articles/206638917-How-can-I-get-access-to-ShipStation-s-API-)
## Dependencies
LaravelShipStation uses ```GuzzleHttp\Guzzle```
## Endpoints
Endpoints for the API are accessed via properties (e.g. ```$shipStation->orders->get($options)``` will make a GET request to ```/orders/{$options}```). The default endpoint is /orders/. Valid endpoints include:
* accounts
* carriers
* customers
* fulfillments
* orders
* products
* shipments
* stores
* users
* warehouses
* webhooks

## Methods
### GET
```php
$shipStation->{$endpoint}->get($options = [], $endpoint = '');
```
Example of getting an order with the orderId of 1.
```php
$shipStation = $this->app['LaravelShipStation\ShipStation'];

// Fetch an order by orderId == 123, orderId is defined by ShipStation
$order = $shipStation->orders->get([], $endpoint = 123); // returns \stdClass

// Fetch an orderId by the orderNumber, which may be user defined
$order = $shipStation->orders->getOrderId('ORD-789'); // returns integer
````
### POST
```php
$shipStation->{$endpoint}->post($options = [], $endpoint = '');
```
The second parameter ($endpoint) is for any additional endpoints that need to be added. For example, to create an order the POST request would go to /orders/createorder. "createorder" is the additional endpoint since we specify the root endpoint as a property: ```$shipstation->orders->post($options, 'createorders')```

There are models that contain all of the properties available via the API. These models will be converted to arrays when passed to the API.

{'fraction_non_alphanumeric': 0.14889086069210292, 'fraction_numerical': 0.006388642413487134, 'mean_word_length': 5.213891951488423, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5335144', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1626, 'n_words': 553}