From b5ce7905e672f18ab6f73e88b97094aefa766064 Mon Sep 17 00:00:00 2001 From: Ross Grambo Date: Mon, 5 Aug 2019 16:37:42 -0700 Subject: [PATCH] Added handling for opting out of asana_change logging --- README.md | 23 +++++++++++++++++++++++ src/Asana/Client.php | 7 ++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2afadb2..9fef0c5 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,29 @@ Events: * `poll_interval` (default: 5): polling interval for getting new events via `events->getNext` and `events->getIterator` * `sync`: sync token returned by previous calls to `events->get` (in `response->sync`) +## Asana Change Warnings +You will receive warning logs if performing requests that may be affected by a deprecation. The warning contains a link that explains the deprecation. + +If you receive one of these warnings, you should: + +Read about the deprecation. +Resolve sections of your code that would be affected by the deprecation. +Add the deprecation flag to your "asana-enable" header. +You can place it on the client for all requests, or place it on a single request. + + $client = Asana\Client::accessToken('ASANA_PERSONAL_ACCESS_TOKEN', + array('headers' => array('asana-disable' => 'string_ids'))) + +or + + $client = Asana\Client::accessToken('ASANA_PERSONAL_ACCESS_TOKEN', + array('headers' => array('asana-enable' => 'string_ids,new_sections'))) + +If you would rather suppress these warnings, you can set + + $client = Asana\Client::accessToken('ASANA_PERSONAL_ACCESS_TOKEN', + array('log_asana_change_warnings' => false)) + ## Collections ### Items Iterator diff --git a/src/Asana/Client.php b/src/Asana/Client.php index 48deffd..3ee9b4d 100644 --- a/src/Asana/Client.php +++ b/src/Asana/Client.php @@ -28,7 +28,8 @@ class Client 'poll_interval' => 5, 'max_retries' => 5, 'full_payload' => null, - 'iterator_type' => 'items' + 'iterator_type' => 'items', + 'log_asana_change_warnings' => true ); private static $QUERY_OPTIONS = array('limit', 'offset' , 'sync'); @@ -113,6 +114,10 @@ public function request($method, $path, $options) private function logAsanaChangeHeaders($reqHeaders, $resHeaders) { + if (!$this->options['log_asana_change_warnings']) { + return; + } + $changeHeaderKey = null; foreach ((array) $resHeaders as $key => $value) {