Skip to content

Commit

Permalink
Merge pull request #14 from castle/feat/review-api
Browse files Browse the repository at this point in the history
feat(Review): Added new review endpoint
  • Loading branch information
lluft authored Feb 13, 2017
2 parents 1eb233b + 0e2be9c commit fd57680
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Castle.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ function lcfirst( $str ) {
require(dirname(__FILE__) . '/RestModel/Model.php');
require(dirname(__FILE__) . '/Castle/Models/Context.php');
require(dirname(__FILE__) . '/Castle/Models/Authenticate.php');
require(dirname(__FILE__) . '/Castle/Models/Review.php');
require(dirname(__FILE__) . '/Castle/CurlTransport.php');
require(dirname(__FILE__) . '/Castle/Request.php');
12 changes: 11 additions & 1 deletion lib/Castle/Castle.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class Castle

public static $scrubHeaders = array('Cookie');

const VERSION = '1.3.0';
const VERSION = '1.4.0';

public static function getApiKey()
{
Expand Down Expand Up @@ -64,6 +64,16 @@ public static function authenticate(Array $attributes)
return $auth;
}

/**
* Authenticate an action
* @param String $attributes 'user_id' and 'name' are required
* @return Castle_Authenticate
*/
public static function fetchReview($id)
{
return Castle_Review::find($id);
}

/**
* Updates user information. Call when a user logs in or updates their information.
* @param String $user_id Id of the user
Expand Down
6 changes: 6 additions & 0 deletions lib/Castle/Models/Review.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

class Castle_Review extends RestModel
{

}
1 change: 1 addition & 0 deletions test/Castle.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function assertRequest($method, $url, $headers=null)
require(dirname(__FILE__) . '/../lib/RestModel/Resource.php');
require(dirname(__FILE__) . '/../lib/RestModel/Model.php');
require(dirname(__FILE__) . '/../lib/Castle/Models/Authenticate.php');
require(dirname(__FILE__) . '/../lib/Castle/Models/Review.php');
require(dirname(__FILE__) . '/../lib/Castle/Models/Context.php');
require(dirname(__FILE__) . '/TestTransport.php');
require(dirname(__FILE__) . '/../lib/Castle/Request.php');
8 changes: 8 additions & 0 deletions test/CastleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ public function testIdentify()
));
$this->assertRequest('post', '/identify');
}

public function testReview()
{
Castle_RequestTransport::setResponse(200, '{ "id": "123553", "reviewed": true, "user_id" : "1234546", "context": {} }');
$review = Castle::fetchReview('123553');
$this->assertRequest('get', '/reviews/123553');
$this->assertEquals($review->id, '123553');
}
}

0 comments on commit fd57680

Please sign in to comment.