timegraph-client 0.1.10

Timegraph Client
Documentation
use graphql_client::{GraphQLQuery, QueryBody};
use serde::{Deserialize, Serialize};

pub const OPERATION_NAME: &str = "CollectData";
pub const QUERY: &str = r#"
mutation CollectData(
    $feed: String!,
    $timechainBlock: Int!,
    $targetBlock: Int!,
    $taskCycle: Int!,
    $taskId: Int!,
    $signature: String!,
    $shardId: Int!
    $data: [String!]!
    $eventId: Int
    ) {
        collect(
            feed: $feed,
            timechainBlock: $timechainBlock,
            targetBlock: $targetBlock,
            taskCycle: $taskCycle,
            taskId: $taskId,
            signature: $signature,
            shardId: $shardId,
            data: $data,
            eventId: $eventId) { status }
    }"#;

type Int = i64;

#[derive(Serialize, Debug)]
pub struct Variables {
    pub feed: String,
    #[serde(rename = "taskId")]
    pub task_id: Int,
    #[serde(rename = "taskCycle")]
    pub task_cycle: Int,
    #[serde(rename = "targetBlock")]
    pub target_block: Int,
    #[serde(rename = "timechainBlock")]
    pub timechain_block: Int,
    #[serde(rename = "shardId")]
    pub shard_id: Int,
    pub signature: String,
    pub data: Vec<String>,
}

#[derive(Deserialize, Debug)]
pub struct ResponseData {
    pub collect: CollectDataCollect,
}

#[derive(Deserialize, Debug)]
pub struct CollectDataCollect {
    pub status: String,
}

pub struct CollectData;

impl GraphQLQuery for CollectData {
    type Variables = Variables;
    type ResponseData = ResponseData;
    fn build_query(variables: Self::Variables) -> QueryBody<Self::Variables> {
        QueryBody {
            variables,
            query: QUERY,
            operation_name: OPERATION_NAME,
        }
    }
}