Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit dbe252f

Browse files
committed
wip - before 0.1
1 parent e340280 commit dbe252f

18 files changed

+1303
-2
lines changed

Diff for: Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM php:7.1.3-fpm
2+
3+
#System update
4+
RUN apt update
5+
6+
# Because some basic tools come in handy...
7+
RUN apt-get install -q -y \
8+
zlib1g-dev \
9+
libxml2-dev \
10+
curl \
11+
unzip
12+
13+
# Install PHP modules
14+
RUN docker-php-ext-install zip soap
15+
16+
# Install Composer
17+
RUN curl -sS https://getcomposer.org/installer | php \
18+
&& mv composer.phar /usr/bin/composer
19+
20+
# Add the application
21+
WORKDIR /canvas

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Canvas APIs client library for PHP
22

3+
Don't trust anything here. We're going to delete the git history before realeasing version 0.1
4+
35
[![Latest Version on Packagist][ico-version]][link-packagist]
46
[![Software License][ico-license]](LICENSE.md)
57
[![Build Status][ico-travis]][link-travis]

Diff for: index.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
use \Canvas\CanvasClient;
3+
4+
$client = new CanvasClient();
5+

Diff for: src/ApiOperations/Request.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Canvas\ApiOperations;
4+
5+
/**
6+
* Trait for resources that need to make API requests.
7+
*
8+
* This trait should only be applied to classes that derive from CanvasObject.
9+
*/
10+
trait Request
11+
{
12+
/**
13+
* @param array|null|mixed $params The list of parameters to validate
14+
*
15+
* @throws \Canvas\Exception\Api if $params exists and is not an array
16+
*/
17+
protected static function _validateParams($params = null)
18+
{
19+
if ($params && !is_array($params)) {
20+
$message = "You must pass an array as the first argument to Stripe API "
21+
. "method calls.";
22+
throw new \Canvas\Exception\Api($message);
23+
}
24+
}
25+
/**
26+
* @param string $method HTTP method ('get', 'post', etc.)
27+
* @param string $url URL for the request
28+
* @param array $params list of parameters for the request
29+
* @param array|string|null $options
30+
*
31+
* @return array tuple containing (the JSON response, $options)
32+
*/
33+
protected function _request($method, $url, $params = [], $options = null)
34+
{
35+
$opts = $this->_opts->merge($options);
36+
list($resp, $options) = static::_staticRequest($method, $url, $params, $opts);
37+
$this->setLastResponse($resp);
38+
return [$resp->json, $options];
39+
}
40+
/**
41+
* @param string $method HTTP method ('get', 'post', etc.)
42+
* @param string $url URL for the request
43+
* @param array $params list of parameters for the request
44+
* @param array|string|null $options
45+
*
46+
* @return array tuple containing (the JSON response, $options)
47+
*/
48+
protected static function _staticRequest($method, $url, $params, $options)
49+
{
50+
$requestOptions = \Canvas\Util\RequestOptions::parse($options);
51+
$baseUrl = isset($requestOptions->apiBase) ? $requestOptions->requestOptions : static::baseUrl();
52+
$requestor = new \Canvas\ApiRequestor($requestOptions->apiKey, $baseUrl);
53+
list($response, $requestOptions->apiKey) = $requestor->request($method, $url, $params, $requestOptions->headers);
54+
$requestOptions->discardNonPersistentHeaders();
55+
return [$response, $requestOptions];
56+
}
57+
58+
}

0 commit comments

Comments
 (0)