<commit_before><?php
/**
 * Created by IntelliJ IDEA.
 * User: mduncan
 * Date: 8/13/15
 * Time: 2:59 PM
 */

namespace Fulfillment\OMS;
require __DIR__ . '/../vendor/autoload.php';


use Dotenv;
use Fulfillment\Api\Api;
use Fulfillment\Api\Configuration\ApiConfiguration;
use Fulfillment\OMS\Api\ApiRequestBase;
use Fulfillment\OMS\Api\InventoryApi;
use Fulfillment\OMS\Api\OrdersApi;
use Fulfillment\OMS\Api\UsersApi;
use Fulfillment\OMS\Utilities\ArrayUtil;
use League\CLImate\CLImate;
use GuzzleHttp;

date_default_timezone_set('Europe/London');

class OmsClient
{
    public $orders;

    /**
     *
     * @param $config mixed Must be either an absolute string pointing to a directory with a .env file or an array containing configuration information
     * @throws \Exception Thrown if a configuration is not valid
     */
    public function __construct($config)
    {
        $this->climate = new CLImate;
        //defined('STDOUT');

        //parse config
        if (is_string($config) || is_null($config)) {
            if (!is_null($config)) {
                if (!is_dir($config)) {
                    throw new \Exception('The provided directory location does not exist at ' . $config);
                }
                Dotenv::load($config);
                Dotenv::required(['API_ENDPOINT']);

            }
            $username     = getenv('USERNAME') ?: null;
            $password     = getenv('PASSWORD') ?: null;
            $clientId     = getenv('CLIENT_ID') ?: null;
            $clientSecret = getenv('CLIENT_SECRET') ?: null;
            $accessToken  = getenv('ACCESS_TOKEN') ?: null;
            $endpoint     = getenv('API_ENDPOINT') ?: null;
            $authEndpoint = getenv('AUTH_ENDPOINT') ?: null;
            $jsonOnly     = getenv('JSON_ONLY') ?: null;
        } else if (is_array($config)) {
            $username   = ArrayUtil::get($config['username']);
            $password   = ArrayUtil::get($config['password']);
            $clientId     = ArrayUtil::get($config['clientId']);
            $clientSecret = ArrayUtil::get($config['clientSecret']);
            $accessToken  = ArrayUtil::get($config['accessToken']);
            $endpoint     = ArrayUtil::get($config['endpoint']);
            $authEndpoint = ArrayUtil::get($config['authEndpoint']);
            $jsonOnly     = ArrayUtil::get($config['jsonOnly'], false);
        } else {
            throw new \InvalidArgumentException('A configuration must be provided');
        }

        $apiConfig = new ApiConfiguration([
            'username' => $username,
            'password' => <PASSWORD>,
            'clientId' => $clientId,
            'clientSecret' => $clientSecret,
            'accessToken' => $accessToken,
            'endpoint' => $endpoint,
            'authEndpoint' => $authEndpoint,
            'scope' => 'oms'
        ]);

        $apiClient = new Api($apiConfig);<commit_msg>Add storage token prefix config parameter<commit_after><?php
/**
 * Created by IntelliJ IDEA.
 * User: mduncan
 * Date: 8/13/15
 * Time: 2:59 PM
 */

namespace Fulfillment\OMS;
require __DIR__ . '/../vendor/autoload.php';


use Dotenv;
use Fulfillment\Api\Api;
use Fulfillment\Api\Configuration\ApiConfiguration;
use Fulfillment\OMS\Api\ApiRequestBase;
use Fulfillment\OMS\Api\InventoryApi;
use Fulfillment\OMS\Api\OrdersApi;
use Fulfillment\OMS\Api\UsersApi;
use Fulfillment\OMS\Utilities\ArrayUtil;
use League\CLImate\CLImate;
use GuzzleHttp;

date_default_timezone_set('Europe/London');

class OmsClient
{
    public $orders;

    /**
     *
     * @param $config mixed Must be either an absolute string pointing to a directory with a .env file or an array containing configuration information
     * @throws \Exception Thrown if a configuration is not valid
     */
    public function __construct($config)
    {
        $this->climate = new CLImate;
        //defined('STDOUT');

        //parse config
        if (is_string($config) || is_null($config)) {
            if (!is_null($config)) {
                if (!is_dir($config)) {
                    throw new \Exception('The provided directory location does not exist at ' . $config);
                }
                Dotenv::load($config);
                Dotenv::required(['API_ENDPOINT']);

            }
            $username           = getenv('USERNAME') ?: null;
            $password           = getenv('PASSWORD') ?: null;
            $clientId           = getenv('CLIENT_ID') ?: null;
            $clientSecret       = getenv('CLIENT_SECRET') ?: null;
            $accessToken        = getenv('ACCESS_TOKEN') ?: null;
            $endpoint           = getenv('API_ENDPOINT') ?: null;
            $authEndpoint       = getenv('AUTH_ENDPOINT') ?: null;
            $jsonOnly           = getenv('JSON_ONLY') ?: null;
            $storageTokenPrefix = getenv('STORAGE_TOKEN_PREFIX') ?: null;
        } else {
            if (is_array($config)) {
                $username           = ArrayUtil::get($config['username']);
                $password           = ArrayUtil::get($config['password']);
                $clientId           = ArrayUtil::get($config['clientId']);
                $clientSecret       = ArrayUtil::get($config['clientSecret']);
                $accessToken        = ArrayUtil::get($config['accessToken']);
                $endpoint           = ArrayUtil::get($config['endpoint']);
                $authEndpoint       = ArrayUtil::get($config['authEndpoint']);
                $storageTokenPrefix = ArrayUtil::get($config['storageTokenPrefix']);
                $jsonOnly           = ArrayUtil::get($config['jsonOnly'], false);
            } else {
                throw new \InvalidArgumentException('A configuration must be provided');
            }
        }

        $apiConfig = new ApiConfiguration([
                                              'username'           => $username,
                                              'password'           => <PASSWORD>,
                                              'clientId'           => $clientId,
                                              'clientSecret'       => $clientSecret,
                                              'accessToken'        => $accessToken,
                                              'endpoint'           => $endpoint,
                                              'authEndpoint'       => $authEndpoint,
                                              'storageTokenPrefix' => $storageTokenPrefix,
                                              'scope'              => 'oms'
                                          ]);

        $apiClient = new Api($apiConfig);
{'fraction_non_alphanumeric': 0.12556526982212843, 'fraction_numerical': 0.002411817907747965, 'mean_word_length': 1.8078713499788404, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7104159', 'n_tokens_mistral': 1764, 'n_tokens_neox': 1723, 'n_words': 365}