UploadResource
extends BaseResource
in package
Table of Contents
Constants
Properties
- $httpClient : HttpClient
- $resourceName : string
- $uploadPath : string
Methods
- __construct() : mixed
- get() : FileUpload
- Get an uploaded file.
- upload() : FileUpload
- Upload a file to FreshBooks.
- buildQueryString() : string
- getUrl() : string
- The the url to the upload resource.
- handleError() : void
- Create a FreshBooksException from the json response from the uploads endpoint.
- makeGetFileRequest() : FileUpload
- Make a request against the uploads resource. Returns an object containing a Psr\Http\Message\StreamInterface for flexibility.
- makeUploadRequest() : FileUpload
- Make creates a POST request to upload a file to FreshBooks.
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
$httpClient
protected
HttpClient
$httpClient
$resourceName
protected
string
$resourceName
$uploadPath
protected
string
$uploadPath
Methods
__construct()
public
__construct(HttpClient $httpClient, string $uploadPath, string $resourceName) : mixed
Parameters
- $httpClient : HttpClient
- $uploadPath : string
- $resourceName : string
get()
Get an uploaded file.
public
get(string $jwt) : FileUpload
Parameters
- $jwt : string
-
JWT provided by FreshBooks when the file was uploaded.
Return values
FileUpload —Object containing the file name, content type, and stream of data.
upload()
Upload a file to FreshBooks.
public
upload(string $accountId, mixed $file) : FileUpload
Parameters
- $accountId : string
-
The alpha-numeric account id
- $file : mixed
Return values
FileUpload —Object containing the JWT, file name, content type.
buildQueryString()
protected
buildQueryString(array<string|int, mixed>|null $builders) : string
Parameters
- $builders : array<string|int, mixed>|null
Return values
stringgetUrl()
The the url to the upload resource.
protected
getUrl([string $accountId = null ][, string $jwt = null ]) : string
Parameters
- $accountId : string = null
- $jwt : string = null
Return values
stringhandleError()
Create a FreshBooksException from the json response from the uploads endpoint.
protected
handleError(int $statusCode, string $contents) : void
Parameters
- $statusCode : int
-
HTTP status code
- $contents : string
-
The response contents
makeGetFileRequest()
Make a request against the uploads resource. Returns an object containing a Psr\Http\Message\StreamInterface for flexibility.
private
makeGetFileRequest(string $url) : FileUpload
Throws a FreshBooksException if the response is not a 200.
Parameters
- $url : string
Return values
FileUploadmakeUploadRequest()
Make creates a POST request to upload a file to FreshBooks.
private
makeUploadRequest(string $url, mixed $file) : FileUpload
Throws a FreshBooksException if the response is not a 200.
Parameters
- $url : string
- $file : mixed