Menu

## GraphCollectionRequest extends GraphRequest
in package

GraphCollectionRequest.php : 23

Class GraphCollectionRequest

##### Tags

copyright

  2021 Microsoft Corporation

license

  https://opensource.org/licenses/MIT MIT License

link
  https://developer.microsoft.com/graph

### Table of Contents

$deltaLink : string
  The delta link to use in calling /delta a subsequent time
$end : bool
  True if the user has reached the end of the collection
$nextLink : string
  The next link to use in calling a new page of results
$originalReturnType : string
  The return type that the user specified
$pageSize : int
  The size of page to divide the collection into
$requestType : string
  The type of request to make ("GET", "POST", etc.)
$returnsStream : bool
  True if the response should be returned as a stream
$returnType : string|null
  The object type to cast the response to
$graphClient : AbstractGraphClient
  The Graph client
$headers : array<string, string|string[]>
  An array of headers to send with the request
$httpRequest : Request
  PSR-7 Request to be passed to HTTP client
$requestBody : StreamInterface|string
  The body of the request (optional)
$requestUri : UriInterface
  Full Request URI (base URL + endpoint)
__construct() : mixed
  Constructs a new GraphCollectionRequest object
addHeaders() : GraphRequest
  Adds custom headers to the request
attachBody() : $this
  Attach a body to the request. Will JSON encode any Microsoft\Graph\Model objects as well as arrays
count() : int
  Gets the number of entries in the collection
download() : void
  Download a file from OneDrive to a given location
execute() : array<string|int, mixed>|GraphResponse|StreamInterface|object
  Executes the HTTP request using $graphClient's http client or a PSR-18 compliant HTTP client
executeAsync() : Promise
  Executes the HTTP request asynchronously using $client
getBody() : string|StreamInterface
  Get the body of the request
getDeltaLink() : string|null
  Gets a delta link to use with subsequent calls to /delta
getHeaders() : array<string, array<string|int, string>>
  Get the request headers
getPage() : array<string|int, mixed>
  Gets the next page of results
getPageSize() : int
  Get page size
getRequestUri() : UriInterface
isEnd() : bool
  Gets whether the user has reached the end of the collection
setAccessToken() : $this
  Sets a new accessToken
setPageSize() : GraphCollectionRequest
  Sets the number of results to return with each call to "getPage()"
setReturnType() : $this
  Sets the return type of the response object Can be set to a model or \Psr\Http\Message\StreamInterface
upload() : array<string|int, mixed>|GraphResponse|StreamInterface|object
  Upload a file from $path to Graph API
initPsr7HttpRequest() : void
initRequestUri() : void
  Creates full request URI by resolving $baseUrl and $endpoint based on RFC 3986
setRequestUri() : void
initHeaders() : void
  Sets default headers based on baseUrl being a Graph endpoint or not
processPageCallReturn() : mixed
  Clean up after making a page call request
setPageCallInfo() : GraphCollectionRequest
  Sets the required query information to get a new page

### Properties

#### $deltaLink

GraphCollectionRequest.php : 42

The delta link to use in calling /delta a subsequent time

`protected string $deltaLink`

#### $end

GraphCollectionRequest.php : 48

True if the user has reached the end of the collection

`protected bool $end`

#### $nextLink

GraphCollectionRequest.php : 36

The next link to use in calling a new page of results

`protected string $nextLink`

#### $originalReturnType

GraphCollectionRequest.php : 54

The return type that the user specified

`protected string $originalReturnType`

#### $pageSize

GraphCollectionRequest.php : 30

The size of page to divide the collection into

`protected int $pageSize`

#### $requestType

GraphRequest.php : 49

The type of request to make ("GET", "POST", etc.)

`protected string $requestType`

#### $returnsStream

GraphRequest.php : 56

True if the response should be returned as a stream

`protected bool $returnsStream`

#### $returnType

GraphRequest.php : 62

The object type to cast the response to

`protected string|null $returnType`

#### $graphClient

GraphRequest.php : 68

The Graph client

`private AbstractGraphClient $graphClient`

#### $headers

GraphRequest.php : 37

An array of headers to send with the request

`private array<string, string|string[]> $headers`

#### $httpRequest

GraphRequest.php : 74

PSR-7 Request to be passed to HTTP client

`private Request $httpRequest`

#### $requestBody

GraphRequest.php : 43

The body of the request (optional)

`private StreamInterface|string $requestBody = null`

#### $requestUri

GraphRequest.php : 80

Full Request URI (base URL + endpoint)

`private UriInterface $requestUri`

### Methods

#### __construct()

GraphCollectionRequest.php : 65

Constructs a new GraphCollectionRequest object

`public __construct(string $requestType, string $endpoint, AbstractGraphClient $graphClient[, string $baseUrl = "" ]) : mixed`

##### Parameters

$requestType : string

  The HTTP verb for the request ("GET", "POST", "PUT", etc.)

$endpoint : string

  The URI of the endpoint to hit

$graphClient : AbstractGraphClient
$baseUrl : string = ""

  (optional) If empty, it's set to $client's national cloud

##### Tags

throws
  GraphClientException

##### Return values

mixed —

#### addHeaders()

GraphRequest.php : 159

Adds custom headers to the request

`public addHeaders(array<string, string|string[]> $headers) : GraphRequest`

##### Parameters

$headers : array<string, string|string[]>

  An array of custom headers

##### Tags

throws
  GraphClientException

  if attempting to overwrite SdkVersion header

##### Return values

GraphRequest —

object

#### attachBody()

GraphRequest.php : 188

Attach a body to the request. Will JSON encode any Microsoft\Graph\Model objects as well as arrays

`public attachBody(string|StreamInterface|object|array<string|int, mixed> $body) : $this`

##### Parameters

$body : string|StreamInterface|object|array<string|int, mixed>

  The payload to include in the request

##### Return values

$this —

object

#### count()

GraphCollectionRequest.php : 82

Gets the number of entries in the collection

`public count() : int`

##### Tags

throws
  ClientExceptionInterface|GraphClientException

##### Return values

int —

the number of entries

#### download()

GraphRequest.php : 299

Download a file from OneDrive to a given location

`public download(string $path[, ClientInterface|null $client = null ]) : void`

##### Parameters

$path : string

  path to download the file contents to

$client : ClientInterface|null = null

  (optional) When null, defaults to $graphClient's http client

##### Tags

throws
  ClientExceptionInterface|GraphClientException

  when unable to open $path for writing

##### Return values

void —

#### execute()

GraphRequest.php : 219

Executes the HTTP request using $graphClient's http client or a PSR-18 compliant HTTP client

`public execute([ClientInterface|null $client = null ]) : array<string|int, mixed>|GraphResponse|StreamInterface|object`

##### Parameters

$client : ClientInterface|null = null

  (optional) When null, uses $graphClient's http client

##### Tags

throws
  ClientExceptionInterface

##### Return values

array<string|int, mixed>|GraphResponse|StreamInterface|object —

Graph Response object or response body cast to $returnType

#### executeAsync()

GraphRequest.php : 256

Executes the HTTP request asynchronously using $client

`public executeAsync([HttpAsyncClient|null $client = null ]) : Promise`

##### Parameters

$client : HttpAsyncClient|null = null

  (optional) When null, uses $graphClient's http client

##### Tags

throws
  Exception

  when promise fails

##### Return values

Promise —

Resolves to GraphResponse object|response body cast to $returnType. Fails throwing the exception

#### getBody()

GraphRequest.php : 207

Get the body of the request

`public getBody() : string|StreamInterface`

##### Return values

string|StreamInterface —

request body

#### getDeltaLink()

GraphCollectionRequest.php : 214

Gets a delta link to use with subsequent calls to /delta

`public getDeltaLink() : string|null`

##### Return values

string|null —

The delta link

#### getHeaders()

GraphRequest.php : 175

Get the request headers

`public getHeaders() : array<string, array<string|int, string>>`

##### Return values

array<string, array<string|int, string>> —

of headers

#### getPage()

GraphCollectionRequest.php : 126

Gets the next page of results

`public getPage() : array<string|int, mixed>`

##### Tags

throws
  ClientExceptionInterface

##### Return values

array<string|int, mixed> —

of objects of class $returnType

#### getPageSize()

GraphCollectionRequest.php : 223

Get page size

`public getPageSize() : int`

##### Return values

int —

#### getRequestUri()

GraphRequest.php : 114
`public getRequestUri() : UriInterface`

##### Return values

UriInterface —

#### isEnd()

GraphCollectionRequest.php : 203

Gets whether the user has reached the end of the collection

`public isEnd() : bool`

##### Return values

bool —

The end

#### setAccessToken()

GraphRequest.php : 125

Sets a new accessToken

`public setAccessToken(string $accessToken) : $this`

##### Parameters

$accessToken : string

  A valid access token to validate the Graph call

##### Return values

$this —

object

#### setPageSize()

GraphCollectionRequest.php : 111

Sets the number of results to return with each call to "getPage()"

`public setPageSize(int $pageSize) : GraphCollectionRequest`

##### Parameters

$pageSize : int

  The page size

##### Tags

throws
  GraphClientException

  if the requested page size exceeds the Graph's defined page size limit

##### Return values

GraphCollectionRequest —

object

#### setReturnType()

GraphRequest.php : 141

Sets the return type of the response object Can be set to a model or \Psr\Http\Message\StreamInterface

`public setReturnType(string $returnClass) : $this`

##### Parameters

$returnClass : string

  The class name to use

##### Tags

throws
  GraphClientException

  when $returnClass is not an existing class

##### Return values

$this —

object

#### upload()

GraphRequest.php : 323

Upload a file from $path to Graph API

`public upload(string $path[, ClientInterface|null $client = null ]) : array<string|int, mixed>|GraphResponse|StreamInterface|object`

##### Parameters

$path : string

  path of file to be uploaded

$client : ClientInterface|null = null

  (optional)

##### Tags

throws
  ClientExceptionInterface|GraphClientException

  if $path cannot be opened for reading

##### Return values

array<string|int, mixed>|GraphResponse|StreamInterface|object —

Graph Response object or response body cast to $returnType

#### initPsr7HttpRequest()

GraphRequest.php : 377
`protected initPsr7HttpRequest() : void`

##### Return values

void —

#### initRequestUri()

GraphRequest.php : 369

Creates full request URI by resolving $baseUrl and $endpoint based on RFC 3986

`protected initRequestUri(string $baseUrl, string $endpoint) : void`

##### Parameters

$baseUrl : string
$endpoint : string

##### Tags

throws
  GraphClientException

##### Return values

void —

#### setRequestUri()

GraphRequest.php : 109
`protected setRequestUri(UriInterface $uri) : void`

##### Parameters

$uri : UriInterface

##### Return values

void —

#### initHeaders()

GraphRequest.php : 341

Sets default headers based on baseUrl being a Graph endpoint or not

`private initHeaders(string $baseUrl) : void`

##### Parameters

$baseUrl : string

##### Return values

void —

#### processPageCallReturn()

GraphCollectionRequest.php : 174

Clean up after making a page call request

`private processPageCallReturn(GraphResponse $response) : mixed`

##### Parameters

$response : GraphResponse

  The GraphResponse returned after making a page call

##### Return values

mixed —

result of the call, formatted according to the returnType set by the user

#### setPageCallInfo()

GraphCollectionRequest.php : 139

Sets the required query information to get a new page

`private setPageCallInfo() : GraphCollectionRequest`

##### Return values

GraphCollectionRequest —

## Search results