import {PatchRequest} from '@serenity-js/rest/lib/model'
public class | source

PatchRequest

The PATCH method requests that a set of changes described in the request entity be applied to the resource identified by the resourceUri.

Extends:

Question<Promise<AxiosRequestConfig>>HTTPRequest → PatchRequest

Examples:

Add new resource to a collection
 import { Actor } from '@serenity-js/core';
 import { CallAnApi, LastResponse, PatchRequest, Send } from '@serenity-js/rest'
 import { Ensure, equals } from '@serenity-js/assertions';

 const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));

 actor.attemptsTo(
     Send.a(PatchRequest.to('/books/0-688-00230-7').with({
         lastReadOn: '2016-06-16',
     })),
     Ensure.that(LastResponse.status(), equals(204)),
 );

Tests:

Static Method Summary

Static Public Methods
public static

to(resourceUri: Answerable<string>): PatchRequest

Configures the object with a destination URI.

Method Summary

Public Methods
public

using(config: Answerable<AxiosRequestConfig>): PatchRequest

Overrides the default Axios request configuration provided when CallAnApi Ability was instantiated.

public

with(data: Answerable<any>): PatchRequest

Configures the object with a request body.

Inherited Summary

From class HTTPRequest
public

subject: string

public

answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<AxiosRequestConfig>

Resolves the Question in the context of a given Actor

Static Public Methods

public static to(resourceUri: Answerable<string>): PatchRequest source

Configures the object with a destination URI.

When the resourceUri is not a fully qualified URL but a path, such as /products/2, it gets concatenated with the URL provided to the Axios instance when the CallAnApi Ability was instantiated.

Params:

NameTypeAttributeDescription
resourceUri Answerable<string>

The URI where the Actor should send the HTTPRequest.

Returns:

PatchRequest

Public Methods

public using(config: Answerable<AxiosRequestConfig>): PatchRequest source

Overrides the default Axios request configuration provided when CallAnApi Ability was instantiated.

Params:

NameTypeAttributeDescription
config Answerable<AxiosRequestConfig>

Axios request configuration overrides

Returns:

PatchRequest

public with(data: Answerable<any>): PatchRequest source

Configures the object with a request body.

Params:

NameTypeAttributeDescription
data Answerable<any>

Data to be sent to the resourceUri

Returns:

PatchRequest