code: def add(self, value, date=None, return_value=False, key=None):
          
          data = {}
          if self._metric_id is None:
              self.tcex.handle_error(715, [self._metric_name])
  
          body = {'value': value}
          if date is not None:
              body['date'] = self.tcex.utils.format_datetime(date, date_format='%Y-%m-%dT%H:%M:%SZ')
          if key is not None:
              body['name'] = key
          self.tcex.log.debug('metric data: {}'.format(body))
          params = {}
          if return_value:
              params = {'returnValue': 'true'}
          url = '/v2/customMetrics/{}/data'.format(self._metric_id)
          r = self.tcex.session.post(url, json=body, params=params)
          if r.status_code == 200 and 'application/json' in r.headers.get('content-type', ''):
              data = r.json()
          elif r.status_code == 204:
              pass
          else:
              self.tcex.handle_error(710, [r.status_code, r.text])
  
          return data
docs: Add metrics data to collection.
  
          Args:
              value (str): The value of the metric.
              date (str, optional): The optional date of the metric.
              return_value (bool, default:False): Tell the API to return the updates metric value.
              key (str, optional): The key value for keyed metrics.
  
          Return:
              dict: If return_value is True a dict with the current value for the time period
                  is returned.