public async Task <object> _post(string url, Dictionary <string, object> query = null, Dictionary <string, FB_File> files = null, bool as_graphql = false, CancellationToken cancellationToken = default(CancellationToken), bool retry = true) { query.update(get_params()); var r = await this._cleanPost(Utils.prefix_url(url), query : query, files : files, cancellationToken : cancellationToken); var content = await State.check_request(r); try { if (as_graphql) { return(GraphQL.response_to_json(content)); } else { var j = Utils.to_json(content); // TODO: Remove this, and move it to _payload_post instead // We can't yet, since errors raised in here need to be caught below Utils.handle_payload_error(j); return(j); } } catch (FBchatPleaseRefresh ex) { if (retry) { await this._do_refresh(); return(await _post(url, query, files, as_graphql, cancellationToken)); } throw ex; } }
public async Task <JToken> graphql_request(GraphQL query) { /* * Shorthand for `graphql_requests(query)[0]` * :raises: Exception if request failed */ return((await this.graphql_requests(new[] { query }.ToList()))[0]); }
public async Task <List <JToken> > graphql_requests(List <GraphQL> queries) { /* * :param queries: Zero or more dictionaries * :type queries: dict * : raises: FBchatException if request failed * : return: A tuple containing json graphql queries * :rtype: tuple * */ var data = new Dictionary <string, object>() { { "method", "GET" }, { "response_format", "json" }, { "queries", GraphQL.queries_to_json(queries) } }; return((List <JToken>) await this._post("/api/graphqlbatch/", data, as_graphql : true)); }