/* tslint:disable */
/* eslint-disable */
/**
 * Stacks 2.0 Blockchain API
 * This is the documentation for the Stacks 2.0 Blockchain API.  It is comprised of two parts; the Stacks Blockchain API and the Stacks Core API.  [![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/614feab5c108d292bffa#?env%5BStacks%20Blockchain%20API%5D=W3sia2V5Ijoic3R4X2FkZHJlc3MiLCJ2YWx1ZSI6IlNUMlRKUkhESE1ZQlE0MTdIRkIwQkRYNDMwVFFBNVBYUlg2NDk1RzFWIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJibG9ja19pZCIsInZhbHVlIjoiMHgiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6Im9mZnNldCIsInZhbHVlIjoiMCIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoibGltaXRfdHgiLCJ2YWx1ZSI6IjIwMCIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoibGltaXRfYmxvY2siLCJ2YWx1ZSI6IjMwIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJ0eF9pZCIsInZhbHVlIjoiMHg1NDA5MGMxNmE3MDJiNzUzYjQzMTE0ZTg4NGJjMTlhODBhNzk2MzhmZDQ0OWE0MGY4MDY4Y2RmMDAzY2RlNmUwIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJjb250cmFjdF9pZCIsInZhbHVlIjoiU1RKVFhFSlBKUFBWRE5BOUIwNTJOU1JSQkdRQ0ZOS1ZTMTc4VkdIMS5oZWxsb193b3JsZFxuIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJidGNfYWRkcmVzcyIsInZhbHVlIjoiYWJjIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJjb250cmFjdF9hZGRyZXNzIiwidmFsdWUiOiJTVEpUWEVKUEpQUFZETkE5QjA1Mk5TUlJCR1FDRk5LVlMxNzhWR0gxIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJjb250cmFjdF9uYW1lIiwidmFsdWUiOiJoZWxsb193b3JsZCIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoiY29udHJhY3RfbWFwIiwidmFsdWUiOiJzdG9yZSIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoiY29udHJhY3RfbWV0aG9kIiwidmFsdWUiOiJnZXQtdmFsdWUiLCJlbmFibGVkIjp0cnVlfV0=) 
 *
 * The version of the OpenAPI document: 1.0.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import { exists, mapValues } from '../runtime';
import {
    RosettaAccount,
    RosettaAccountFromJSON,
    RosettaAccountFromJSONTyped,
    RosettaAccountToJSON,
    RosettaAmount,
    RosettaAmountFromJSON,
    RosettaAmountFromJSONTyped,
    RosettaAmountToJSON,
    RosettaBlockMetadata,
    RosettaBlockMetadataFromJSON,
    RosettaBlockMetadataFromJSONTyped,
    RosettaBlockMetadataToJSON,
    RosettaCoinChange,
    RosettaCoinChangeFromJSON,
    RosettaCoinChangeFromJSONTyped,
    RosettaCoinChangeToJSON,
    RosettaOperationIdentifier,
    RosettaOperationIdentifierFromJSON,
    RosettaOperationIdentifierFromJSONTyped,
    RosettaOperationIdentifierToJSON,
    RosettaRelatedOperation,
    RosettaRelatedOperationFromJSON,
    RosettaRelatedOperationFromJSONTyped,
    RosettaRelatedOperationToJSON,
} from './';

/**
 * Operations contain all balance-changing information within a transaction. They are always one-sided (only affect 1 AccountIdentifier) and can succeed or fail independently from a Transaction.
 * @export
 * @interface RosettaOperation
 */
export interface RosettaOperation {
    /**
     * 
     * @type {RosettaOperationIdentifier}
     * @memberof RosettaOperation
     */
    operation_identifier: RosettaOperationIdentifier;
    /**
     * Restrict referenced related_operations to identifier indexes < the current operation_identifier.index. This ensures there exists a clear DAG-structure of relations. Since operations are one-sided, one could imagine relating operations in a single transfer or linking operations in a call tree.
     * @type {Array<RosettaRelatedOperation>}
     * @memberof RosettaOperation
     */
    related_operations?: Array<RosettaRelatedOperation>;
    /**
     * The network-specific type of the operation. Ensure that any type that can be returned here is also specified in the NetworkStatus. This can be very useful to downstream consumers that parse all block data.
     * @type {string}
     * @memberof RosettaOperation
     */
    type: string;
    /**
     * The network-specific status of the operation. Status is not defined on the transaction object because blockchains with smart contracts may have transactions that partially apply. Blockchains with atomic transactions (all operations succeed or all operations fail) will have the same status for each operation.
     * @type {string}
     * @memberof RosettaOperation
     */
    status: string;
    /**
     * 
     * @type {RosettaAccount}
     * @memberof RosettaOperation
     */
    account?: RosettaAccount;
    /**
     * 
     * @type {RosettaAmount}
     * @memberof RosettaOperation
     */
    amount?: RosettaAmount;
    /**
     * 
     * @type {RosettaCoinChange}
     * @memberof RosettaOperation
     */
    coin_change?: RosettaCoinChange;
    /**
     * 
     * @type {RosettaBlockMetadata}
     * @memberof RosettaOperation
     */
    metadata?: RosettaBlockMetadata;
}

export function RosettaOperationFromJSON(json: any): RosettaOperation {
    return RosettaOperationFromJSONTyped(json, false);
}

export function RosettaOperationFromJSONTyped(json: any, ignoreDiscriminator: boolean): RosettaOperation {
    if ((json === undefined) || (json === null)) {
        return json;
    }
    return {
        
        'operation_identifier': RosettaOperationIdentifierFromJSON(json['operation_identifier']),
        'related_operations': !exists(json, 'related_operations') ? undefined : ((json['related_operations'] as Array<any>).map(RosettaRelatedOperationFromJSON)),
        'type': json['type'],
        'status': json['status'],
        'account': !exists(json, 'account') ? undefined : RosettaAccountFromJSON(json['account']),
        'amount': !exists(json, 'amount') ? undefined : RosettaAmountFromJSON(json['amount']),
        'coin_change': !exists(json, 'coin_change') ? undefined : RosettaCoinChangeFromJSON(json['coin_change']),
        'metadata': !exists(json, 'metadata') ? undefined : RosettaBlockMetadataFromJSON(json['metadata']),
    };
}

export function RosettaOperationToJSON(value?: RosettaOperation | null): any {
    if (value === undefined) {
        return undefined;
    }
    if (value === null) {
        return null;
    }
    return {
        
        'operation_identifier': RosettaOperationIdentifierToJSON(value.operation_identifier),
        'related_operations': value.related_operations === undefined ? undefined : ((value.related_operations as Array<any>).map(RosettaRelatedOperationToJSON)),
        'type': value.type,
        'status': value.status,
        'account': RosettaAccountToJSON(value.account),
        'amount': RosettaAmountToJSON(value.amount),
        'coin_change': RosettaCoinChangeToJSON(value.coin_change),
        'metadata': RosettaBlockMetadataToJSON(value.metadata),
    };
}


