Skip to content

Commit

Permalink
Merge pull request #505 from stripe/remi-add-file-link
Browse files Browse the repository at this point in the history
Add support for the File Link resource
brandur-stripe authored Aug 2, 2018
2 parents 5c881b4 + e4ada8a commit c9a59a2
Showing 6 changed files with 99 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ php:

env:
global:
- STRIPE_MOCK_VERSION=0.24.1
- STRIPE_MOCK_VERSION=0.25.0
matrix:
- AUTOLOAD=1
- AUTOLOAD=0
1 change: 1 addition & 0 deletions init.php
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@
require(dirname(__FILE__) . '/lib/EphemeralKey.php');
require(dirname(__FILE__) . '/lib/Event.php');
require(dirname(__FILE__) . '/lib/ExchangeRate.php');
require(dirname(__FILE__) . '/lib/FileLink.php');
require(dirname(__FILE__) . '/lib/FileUpload.php');
require(dirname(__FILE__) . '/lib/Invoice.php');
require(dirname(__FILE__) . '/lib/InvoiceItem.php');
30 changes: 30 additions & 0 deletions lib/FileLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Stripe;

/**
* Class FileLink
*
* @property string $id
* @property string $object
* @property int $created
* @property bool $expired
* @property int $expires_at
* @property string $file
* @property string $purpose
* @property bool $livemode
* @property StripeObject $metadata
* @property string $url
*
* @package Stripe
*/
class FileLink extends ApiResource
{

const OBJECT_NAME = "file_link";

use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
}
1 change: 1 addition & 0 deletions lib/Util/Util.php
Original file line number Diff line number Diff line change
@@ -90,6 +90,7 @@ public static function convertToStripeObject($resp, $opts)
\Stripe\Event::OBJECT_NAME => 'Stripe\\Event',
\Stripe\ExchangeRate::OBJECT_NAME => 'Stripe\\ExchangeRate',
\Stripe\ApplicationFeeRefund::OBJECT_NAME => 'Stripe\\ApplicationFeeRefund',
\Stripe\FileLink::OBJECT_NAME => 'Stripe\\FileLink',
\Stripe\FileUpload::OBJECT_NAME => 'Stripe\\FileUpload',
\Stripe\Invoice::OBJECT_NAME => 'Stripe\\Invoice',
\Stripe\InvoiceItem::OBJECT_NAME => 'Stripe\\InvoiceItem',
65 changes: 65 additions & 0 deletions tests/Stripe/FileLinkTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Stripe;

class FileLinkTest extends TestCase
{
const TEST_RESOURCE_ID = 'fl_123';

public function testIsListable()
{
$this->expectsRequest(
'get',
'/v1/file_links'
);
$resources = FileLink::all();
$this->assertTrue(is_array($resources->data));
$this->assertInstanceOf("Stripe\\FileLink", $resources->data[0]);
}

public function testIsRetrievable()
{
$this->expectsRequest(
'get',
'/v1/file_links/' . self::TEST_RESOURCE_ID
);
$resource = FileLink::retrieve(self::TEST_RESOURCE_ID);
$this->assertInstanceOf("Stripe\\FileLink", $resource);
}

public function testIsCreatable()
{
$this->expectsRequest(
'post',
'/v1/file_links'
);
$resource = FileLink::create([
"file" => "file_123"
]);
$this->assertInstanceOf("Stripe\\FileLink", $resource);
}

public function testIsSaveable()
{
$resource = FileLink::retrieve(self::TEST_RESOURCE_ID);
$resource->metadata["key"] = "value";
$this->expectsRequest(
'post',
'/v1/file_links/' . $resource->id
);
$resource->save();
$this->assertInstanceOf("Stripe\\FileLink", $resource);
}

public function testIsUpdatable()
{
$this->expectsRequest(
'post',
'/v1/file_links/' . self::TEST_RESOURCE_ID
);
$resource = FileLink::update(self::TEST_RESOURCE_ID, [
"metadata" => ["key" => "value"],
]);
$this->assertInstanceOf("Stripe\\FileLink", $resource);
}
}
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

define("MOCK_MINIMUM_VERSION", "0.24.1");
define("MOCK_MINIMUM_VERSION", "0.25.0");
define("MOCK_PORT", getenv("STRIPE_MOCK_PORT") ?: 12111);

// Send a request to stripe-mock

0 comments on commit c9a59a2

Please sign in to comment.