Overview
  • Namespace
  • Class

Namespaces

  • Klarna
    • Rest
      • Checkout
      • OrderManagement
      • Transport
        • Exception

Classes

  • Connector
  • ResponseValidator
  • UserAgent

Interfaces

  • ConnectorInterface
  • UserAgentInterface

Class ResponseValidator

HTTP response validator helper class.

Namespace: Klarna\Rest\Transport
Located at Klarna/Rest/Transport/ResponseValidator.php

Methods summary

public
# __construct( Psr\Http\Message\ResponseInterface $response )

Constructs a response validator instance.

Constructs a response validator instance.

Parameters

$response
Response to validate
public Psr\Http\Message\ResponseInterface
# getResponse( )

Gets the response object.

Gets the response object.

Returns

Psr\Http\Message\ResponseInterface
public Klarna\Rest\Transport\ResponseValidator
# status( string|string[] $status )

Asserts the HTTP response status code.

Asserts the HTTP response status code.

Parameters

$status
Expected status code(s)

Returns

Klarna\Rest\Transport\ResponseValidator

Throws

RuntimeException
If status code does not match
public Klarna\Rest\Transport\ResponseValidator
# contentType( string $mediaType )

Asserts the Content-Type header.

Asserts the Content-Type header.

Parameters

$mediaType
Expected media type

Returns

Klarna\Rest\Transport\ResponseValidator

Throws

RuntimeException
If Content-Type header is missing
RuntimeException
If Content-Type header does not match
public array
# getJson( )

Get the decoded JSON response.

Get the decoded JSON response.

Returns

array

Throws

RuntimeException
If the response body is not in JSON format
InvalidArgumentException
If the JSON cannot be parsed
public string
# getLocation( )

Gets the Location header.

Gets the Location header.

Returns

string

Throws

RuntimeException
If the Location header is missing

Magic methods summary

Properties summary

protected Psr\Http\Message\ResponseInterface $response

HTTP response to validate against.

HTTP response to validate against.

#
API documentation generated by ApiGen