Commit 5b369e79 authored by Leo Jacoboni's avatar Leo Jacoboni
Browse files

add foule factory folder (api call)

parent 1f285df1
License:
========
The MIT License (MIT)
http://opensource.org/licenses/MIT
Copyright (c) 2014 - 2016 APIMATIC Limited
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Trade Mark:
==========
APIMATIC is a trade mark for APIMATIC Limited
\ No newline at end of file
FouleFactoryApiLib V 1.1.100
============================
This API SDK was automatically generated by [APIMATIC v2.0](https://apimatic.io/).
How To Configure:
=================
The generated code might need to be configured with your API credentials. To do that,
open the file "Configuration.php" and edit it's contents.
How To Build:
=============
The generated code has dependencies over external libraries. These dependencies
are defined in the `composer.json` file. To resolve these dependencies, we use
the *Composer* package manager. You will need internet access for this.
1. If you have not already installed Composer, [install the latest version](https://getcomposer.org/download/).
2. Once Composer is installed, from commandline, run `composer install`
to install dependencies.
How To Use:
===========
For using this SDK do the following:
1. Use Composer to install the dependencies. See the section "How To Build".
2. See that you have configured your SDK correctly. See the section "How To Configure".
3. Depending on your project setup, you might need to include composer's autoloader
in your PHP code to enable autoloading of classes.
```PHP
require_once "vendor/autoload.php";
```
4. Import the SDK client in your project:
```PHP
use FouleFactoryApiLib\FouleFactoryApiClient;
```
5. Instantiate the client. After this, you can now get the controllers and call the
respective methods:
```PHP
$client = new FouleFactoryApiClient();
$controller = $client->getTaskAnswerTexts();
```
{
"name": "apimatic/foulefactoryapi",
"type": "library",
"description": "TODO: add library description",
"keywords": ["FouleFactory Api","API","SDK"],
"homepage": "https://apimatic.io",
"license": "MIT",
"authors": [
{
"name": "Zeeshan @ APIMATIC",
"email": "zeeshan@apimatic.io",
"homepage": "https://github.com/apimatic",
"role": "Developer"
}
],
"require": {
"php": ">=5.4.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"mashape/unirest-php": "~3.0.1",
"apimatic/jsonmapper": "~1.0.0"
},
"autoload": {
"psr-4": {
"FouleFactoryApiLib\\": "src/"
}
}
}
\ No newline at end of file
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "5cc8fafc64b707750b6970c77ec6885f",
"packages": [
{
"name": "apimatic/jsonmapper",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/apimatic/jsonmapper.git",
"reference": "6925ede91d6a85a886d8e00819fe53e439d6e4c2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/apimatic/jsonmapper/zipball/6925ede91d6a85a886d8e00819fe53e439d6e4c2",
"reference": "6925ede91d6a85a886d8e00819fe53e439d6e4c2",
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "4.2.*",
"squizlabs/php_codesniffer": "~1.5"
},
"type": "library",
"autoload": {
"psr-4": {
"apimatic\\jsonmapper\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"OSL-3.0"
],
"authors": [
{
"name": "Christian Weiske",
"email": "christian.weiske@netresearch.de",
"homepage": "http://www.netresearch.de/",
"role": "Developer"
},
{
"name": "Mehdi Jaffery",
"email": "mehdi.jaffery@apimatic.io",
"homepage": "http://apimatic.io/",
"role": "Developer"
}
],
"description": "Map nested JSON structures onto PHP classes",
"time": "2017-01-24T12:48:47+00:00"
},
{
"name": "mashape/unirest-php",
"version": "v3.0.4",
"source": {
"type": "git",
"url": "https://github.com/Mashape/unirest-php.git",
"reference": "842c0f242dfaaf85f16b72e217bf7f7c19ab12cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Mashape/unirest-php/zipball/842c0f242dfaaf85f16b72e217bf7f7c19ab12cb",
"reference": "842c0f242dfaaf85f16b72e217bf7f7c19ab12cb",
"shasum": ""
},
"require": {
"ext-curl": "*",
"php": ">=5.4.0"
},
"require-dev": {
"codeclimate/php-test-reporter": "0.1.*",
"phpunit/phpunit": "~4.4"
},
"suggest": {
"ext-json": "Allows using JSON Bodies for sending and parsing requests"
},
"type": "library",
"autoload": {
"psr-0": {
"Unirest\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Unirest PHP",
"homepage": "https://github.com/Mashape/unirest-php",
"keywords": [
"client",
"curl",
"http",
"https",
"rest"
],
"time": "2016-08-11T17:49:21+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.4.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*"
},
"platform-dev": []
}
<?php
/*
* FouleFactoryApiLib
*
* This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ) on 09/14/2016
*/
namespace FouleFactoryApiLib;
use Exception;
/**
* Class for exceptions when there is a network error, status code error, etc.
*/
class APIException extends Exception {
/**
* Error message
* @var errorMessage
*/
private $errorMessage;
/**
* HTTP context
* @var HttpContext
*/
private $context;
/**
* The HTTP response code from the API request
* @param string $reason the reason for raising an exception
* @param int $responseCode the HTTP response code from the API request
* @param string $responseBody the HTTP response body from the API request
*/
public function __construct($reason, $context)
{
parent::__construct($reason, $context->getResponse()->getStatusCode(), NULL);
$this->context = $context;
$this->errorMessage = $reason;
if(!(get_class()=='APIException'))
$this->unbox();
}
public function unbox()
{
}
/**
* The HTTP context from the API request
* @return HttpContext
*/
public function getContext()
{
return $this->context;
}
/**
* The HTTP response code from the API request
* @return int
*/
public function getResponseCode()
{
return $this->context->getResponse()->getStatusCode();
}
/**
* The HTTP response body from the API request
* @return mixed
*/
public function getResponseBody()
{
return $this->context->getResponse()->getRawBody();
}
/**
* The reason for raising an exception
* @return string
*/
public function getReason()
{
return $this->message;
}
}
\ No newline at end of file
<?php
/*
* FouleFactoryApiLib
*
* This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ) on 09/14/2016
*/
namespace FouleFactoryApiLib;
use InvalidArgumentException;
/**
* API utility class
*/
class APIHelper {
/**
* Replaces template parameters in the given url
* @param string $queryBuilder The query string builder to replace the template parameters
* @param array $parameters The parameters to replace in the url
* @return void
*/
public static function appendUrlWithTemplateParameters(&$queryBuilder, $parameters)
{
//perform parameter validation
if (is_null($queryBuilder) || !is_string($queryBuilder)) {
throw new InvalidArgumentException('Given value for parameter "queryBuilder" is invalid.');
}
if (is_null($parameters)) {
return;
}
//iterate and append parameters
foreach ($parameters as $key => $value) {
$replaceValue = '';
//load parameter value
if (is_null($value)) {
$replaceValue = '';
} elseif (is_array($value)) {
$replaceValue = implode("/", array_map("urlencode", $value));
} else {
$replaceValue = urlencode(strval($value));
}
//find the template parameter and replace it with its value
$queryBuilder = str_replace('{' . strval($key) . '}', $replaceValue, $queryBuilder);
}
}
/**
* Appends the given set of parameters to the given query string
* @param string $queryBuilder The query url string to append the parameters
* @param array $parameters The parameters to append
* @return void
*/
public static function appendUrlWithQueryParameters(&$queryBuilder, $parameters)
{
//perform parameter validation
if (is_null($queryBuilder) || !is_string($queryBuilder)) {
throw new InvalidArgumentException('Given value for parameter "queryBuilder" is invalid.');
}
if (is_null($parameters)) {
return;
}
//does the query string already has parameters
$hasParams = (strrpos($queryBuilder, '?') > 0);
//if already has parameters, use the &amp; to append new parameters
$queryBuilder = $queryBuilder . (($hasParams) ? '&' : '?');
//append parameters
$queryBuilder = $queryBuilder . http_build_query($parameters);
}
/**
* Validates and processes the given Url
* @param string $url The given Url to process
* @return string Pre-processed Url as string */
public static function cleanUrl($url)
{
//perform parameter validation
if(is_null($url) || !is_string($url)) {
throw new InvalidArgumentException('Invalid Url.');
}
//ensure that the urls are absolute
$matchCount = preg_match("#^(https?://[^/]+)#", $url, $matches);
if ($matchCount == 0) {
throw new InvalidArgumentException('Invalid Url format.');
}
//get the http protocol match
$protocol = $matches[1];
//remove redundant forward slashes
$query = substr($url, strlen($protocol));
$query = preg_replace("#//+#", "/", $query);
//return process url
return $protocol.$query;
}
/**
* Encode multidimentional arrays for sending as post field in CURL
*
* Will handle files as well as models if found in the $data.
*
* @source https://bugs.php.net/patch-display.php?bug_id=67477&patch=add-http_build_query_develop-function&revision=latest
*
* @param array $data Input data to be encoded
* @return array Encoded data
*/
public static function httpBuildQueryDevelop($data) {
// if not array, $data is okay
if(!is_array($data)) {
return $data;
}
foreach($data as $key => $val) {
if(is_array($val)) {
foreach($val as $k => $v) {
if(is_array($v)) {
// flatten array and merge
$data = array_merge($data, static::httpBuildQueryDevelop(array( "{$key}[{$k}]" => $v)));
} else if(is_object($v)) {
// flatten object to array and merge
$data = array_merge($data, static::httpBuildQueryDevelop(array( "{$key}[{$k}]" => $v->jsonSerialize())));
} else {
// does not need flattening; primitive
$data["{$key}[{$k}]"] = $v;
}
}
unset($data[$key]);
}
}
return $data;
}
/**
* Deserialize a Json string
* @param string $json A valid Json string
* @param mixed $instance Instance of an object to map the json into
* @param boolean $isArray Is the Json an object array?
* @return mixed Decoded Json
*/
public static function deserialize($json, $instance = null, $isArray = false)
{
if($instance == null) {
return json_decode($json, true);
} else{
$mapper = new \apimatic\jsonmapper\JsonMapper();
if($isArray) {
return $mapper->mapArray(json_decode($json), array(), $instance);
} else {
return $mapper->map(json_decode($json), $instance);
}
}
}
}
\ No newline at end of file
<?php
/*
* FouleFactoryApiLib V 1.1.100
*
* This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ) on 09/14/2016
*/
namespace FouleFactoryApiLib;
/**
* App connexion
*
* login: headwork@foulefactory.com
* mot de passe: 123456
*
*/
/**
* All configuration including auth info and base URI for the API access
* are configured in this class.
*/
class Configuration {
/**
* The base Uri for API calls
* @var string
*/
public static $BASEURI = 'http://sandbox-api.foulefactory.com/';
/**
* The username to use with basic authentication
* @var string
*/
/**
* @todo Replace the $basicAuthUserName with an appropriate value
*/
public static $basicAuthUserName = 'headwork_foulefactory.com';
/**
* The password to use with basic authentication
* @var string
*/
/**
* @todo Replace the $basicAuthPassword with an appropriate value
*/
public static $basicAuthPassword = 'FwraKcDr1hfionJivBwYP3wNcreXb3yBBw==';
}
<?php
/*
* FouleFactoryApiLib
*
* This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ) on 09/14/2016
*/
namespace FouleFactoryApiLib\Controllers;
use FouleFactoryApiLib\APIException;
use FouleFactoryApiLib\APIHelper;
use FouleFactoryApiLib\Configuration;
use FouleFactoryApiLib\Models;
use FouleFactoryApiLib\Exceptions;
use FouleFactoryApiLib\Http\HttpRequest;
use FouleFactoryApiLib\Http\HttpResponse;
use FouleFactoryApiLib\Http\HttpMethod;
use FouleFactoryApiLib\Http\HttpContext;
use Unirest\Request;
/**
* @todo Add a general description for this controller.
*/
class AccountController extends BaseController {
/**
* @var AccountController The reference to *Singleton* instance of this class
*/
private static $instance;
/**
* Returns the *Singleton* instance of this class.
* @return AccountController The *Singleton* instance.
*/
public static function getInstance()
{
if (null === static::$instance) {
static::$instance = new static();
}
return static::$instance;
}
/**
* @todo Add general description for this endpoint
* @param string $transactionId Required parameter: Example:
* @param string $acceptLanguage Optional parameter: Example: fr
* @return mixed response from the API call
* @throws APIException Thrown if API call fails
*/
public function getAccountValidateTransaction (
$transactionId,
$acceptLanguage = 'fr')
{
//the base uri for api requests
$_queryBuilder = Configuration::$BASEURI;
//prepare query string for API call
$_queryBuilder = $_queryBuilder.'/v1.1/accounts/validateTransaction';
//process optional query parameters
APIHelper::appendUrlWithQueryParameters($_queryBuilder, array (
'transactionId' => $transactionId,
));
//validate and preprocess url
$_queryUrl = APIHelper::cleanUrl($_queryBuilder);
//prepare headers
$_headers = array (
'user-agent' => 'APIMATIC 2.0',
'Accept' => 'application/json',
'Accept-Language' => (null != $acceptLanguage) ? $acceptLanguage : 'fr'
);
//set HTTP basic auth parameters
Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword);
//call on-before Http callback
$_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl);
if($this->getHttpCallBack() != null) {
$this->getHttpCallBack()->callOnBeforeRequest($_httpRequest);
}
//and invoke the API call request to fetch the response
$response = Request::get($_queryUrl, $_headers);
//call on-after Http callback
if($this->getHttpCallBack() != null) {
$_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body);
$_httpContext = new HttpContext($_httpRequest, $_httpResponse);
$this->getHttpCallBack()->callOnAfterRequest($_httpContext);
}
//Error handling using HTTP status codes
if (($response->code < 200) || ($response->code > 208)) { //[200,208] = HTTP OK
throw new APIException