anchor.diff:          .replaceAll("+", "%2B");
     }
   
  -  FirestoreDatabase(this._project, this._authToken);
  -
  -  static const apiUrl = 'https://firestore.googleapis.com/v1beta1';
  -
  -  String get projectUrl => '$apiUrl/projects/$_project';
  -
  -  String get documentsUrl => '$projectUrl/databases/(default)/documents';
  -
  -  String get queryUrl => '$documentsUrl:runQuery';
  -
  -  Map<String, String> get _headers {
  -    return {
  -      'Authorization': 'Bearer $_authToken',
  +  FirestoreDatabase._(this._headers, this._documentsUrl, this._queryUrl,
  +      this._beginTransactionUrl, this._commitUrl);
  +
  +  factory FirestoreDatabase(String project, String authToken) {
  +    var databaseUrl = _apiUrl.resolve('projects/$project/databases/(default)/');
  +    var documentsUrl = databaseUrl.resolve('documents/');
  +    var queryUrl = databaseUrl.resolveUri(Uri(path: 'documents:runQuery'));
  +    var beginTransactionUrl =
  +        databaseUrl.resolveUri(Uri(path: 'documents:beginTransaction'));
  +    var commitUrl = databaseUrl.resolveUri(Uri(path: 'documents:commit'));
  +    var headers = {
  +      'Authorization': 'Bearer $authToken',
         'Accept': 'application/json',
         'Content-Type': 'application/json'
       };
  -  }
  +    return FirestoreDatabase._(
  +        headers, documentsUrl, queryUrl, beginTransactionUrl, commitUrl);
  +  }
  +
  +  static final _apiUrl = Uri.https('firestore.googleapis.com', 'v1beta1/');
   
     Future<List /*!*/ > runQuery(Query query) async {
       var body = jsonEncode(query.data);
  -    var response = await _client.post(queryUrl, headers: _headers, body: body);
  +    var response = await _client.post(_queryUrl, headers: _headers, body: body);
       if (response.statusCode == HttpStatus.ok) {
         return jsonDecode(response.body);
       } else {
  
positive.code:     if (_currentTransaction != null) {
        throw Exception('Error: nested transactions');
      }
      var url = '$documentsUrl:beginTransaction';
      var body = '{"options": {}}';
      var response = await _client.post(url, headers: _headers, body: body);
      if (response.statusCode == HttpStatus.ok) {
        var result = jsonDecode(response.body);
        _currentTransaction = result['transaction'] as String;
  
negative.code:   }
  
    Future<Map> getDocument(String collectionName, String documentName) async {
      var url = _documentsUrl.resolveUri(Uri(
          path: '$collectionName/$documentName',
          query: _currentTransaction == null
              ? null
              : 'transaction=${_escapedCurrentTransaction}'));
      var response = await _client.get(url, headers: _headers);
      if (response.statusCode == HttpStatus.ok) {
        var document = jsonDecode(response.body);
  