dialogflow / dialogflow-nodejs-client

Node.js SDK for Dialogflow
Apache License 2.0
659 stars 287 forks source link

Add service method to delete/reset all contexts. #41

Closed coreyroach closed 7 years ago

coreyroach commented 7 years ago

I have added a prototype function to the apiai service module to delete/reset all active contexts. The update modifies the ContextsRequest object to accept a method option to pass DELETE as the method. This will default to POST if no method option is given. The end method also checks if the request method is POST before writing the body content.

The new method is named deleteContextsForSession and I have included an example.

sstepashka commented 7 years ago

This feature is useful, but... May we create new request class for delete contexts for splitting code and do its more clearly? This will simple code. Also, please, if you can, add type definition about this method to TS definition file (index.d.ts)?

coreyroach commented 7 years ago

Would this new class (call it DeleteContextsRequest) extend ContextsRequest or extend JSONApiRequest?

sstepashka commented 7 years ago

I think, use JSONApiRequest. just constructor with parameters with sessionId and override one method to provide DELETE http method.

coreyroach commented 7 years ago

I have created a new request class and reverted the ContextsRequest class. Also, I have updated the example and TS definition.

sstepashka commented 7 years ago

Thank you!