PaymentResource
extends BaseResource
in package
Table of Contents
Constants
Properties
- $defaultsPath : string
- $httpClient : HttpClient
- $model : string
- $resourcePath : string
- $staticPathParams : string
- $subResourcePath : string
Methods
- __construct() : mixed
- create() : DataTransferObject
- Create a resource from either an array or a DataModel object.
- defaults() : DataTransferObject
- Get the default settings for an account resource.
- get() : DataTransferObject
- Get a single resource with the corresponding id.
- buildQueryString() : string
- createResponseError() : void
- Parse the json response for payments endpoint errors and create a FreshBooksException from it.
- getUrl() : string
- The the url to the payment resource.
- makeRequest() : array<string|int, mixed>
- Make a request against the payments resource and return an array of the json response.
Constants
DELETE
protected
mixed
DELETE
= 'DELETE'
GET
protected
mixed
GET
= 'GET'
PATCH
protected
mixed
PATCH
= 'PATCH'
POST
protected
mixed
POST
= 'POST'
PUT
protected
mixed
PUT
= 'PUT'
Properties
$defaultsPath
private
string
$defaultsPath
$httpClient
private
HttpClient
$httpClient
$model
private
string
$model
$resourcePath
private
string
$resourcePath
$staticPathParams
private
string
$staticPathParams
$subResourcePath
private
string
$subResourcePath
Methods
__construct()
public
__construct(HttpClient $httpClient, string $resourcePath, string $model[, string $subResourcePath = null ][, string $defaultsPath = null ][, string $staticPathParams = null ]) : mixed
Parameters
- $httpClient : HttpClient
- $resourcePath : string
- $model : string
- $subResourcePath : string = null
- $defaultsPath : string = null
- $staticPathParams : string = null
create()
Create a resource from either an array or a DataModel object.
public
create(string $accountId, int $resourceId[, DataModel $model = null ][, array<string|int, mixed> $data = null ]) : DataTransferObject
Parameters
- $accountId : string
-
The alpha-numeric account id
- $resourceId : int
- $model : DataModel = null
-
(Optional) The model to create
- $data : array<string|int, mixed> = null
-
(Optional) The data to create the model with
Return values
DataTransferObject —Model of the new resource's response data.
defaults()
Get the default settings for an account resource.
public
defaults(string $accountId) : DataTransferObject
Parameters
- $accountId : string
-
The alpha-numeric account id
Return values
DataTransferObject —The result model with the default data
get()
Get a single resource with the corresponding id.
public
get(string $accountId, int $resourceId) : DataTransferObject
Parameters
- $accountId : string
-
The alpha-numeric account id
- $resourceId : int
-
Id of the resource to return
Return values
DataTransferObject —The result model
buildQueryString()
protected
buildQueryString(array<string|int, mixed>|null $builders) : string
Parameters
- $builders : array<string|int, mixed>|null
Return values
stringcreateResponseError()
Parse the json response for payments endpoint errors and create a FreshBooksException from it.
private
createResponseError(int $statusCode, array<string|int, mixed> $responseData, string $rawRespone) : void
Parameters
- $statusCode : int
-
HTTP status code
- $responseData : array<string|int, mixed>
-
The json-parsed response
- $rawRespone : string
-
The raw response body
getUrl()
The the url to the payment resource.
private
getUrl(int $accountId[, int $resourceId = null ]) : string
Parameters
- $accountId : int
- $resourceId : int = null
Return values
stringmakeRequest()
Make a request against the payments resource and return an array of the json response.
private
makeRequest(string $method, string $url[, array<string|int, mixed> $data = null ]) : array<string|int, mixed>
Throws a FreshBooksException if the response is not a 200 or if the response cannot be parsed.
Parameters
- $method : string
- $url : string
- $data : array<string|int, mixed> = null