/// <summary> /// Creates a new contract initiated by the current token user with the specified parameters. /// Requires <see cref="APIPermission.CONTRACTS" /> /// <summary> /// <param name="client">The client to use to process this request.</param> /// <param name="userId">The id of the other user to begin the contract with.</param> /// <param name="position">The current user's position in the contract.</param> /// <param name="terms">The terms of the contract.</param> /// <param name="yourProduct">The user's product.</param> /// <param name="yourCurrency">The user's currency.</param> /// <param name="yourAmount">The user's amount (and currency if ContractCurrency.OTHER).</param> /// <param name="theirProduct">The other user's product.</param> /// <param name="theirCurrency">The other user's currency.</param> /// <param name="theirAmount">The other user's amount (and currency if ContractCurrency.OTHER).</param> /// <param name="threadId">The id of the thread to link this contract to.</param> /// <param name="middlemanId">The user id of the middleman.</param> /// <param name="timeoutDays">The time (in days) that the contract will expire.</param> /// <param name="isPublic">Whether this is a public contract.</param> /// <param name="paymentAddress">The payment address.</param> public static ContractResult Create(HttpClient client, int userId, ContractPosition position, string terms, string yourProduct = null, ContractCurrency yourCurrency = ContractCurrency.NONE, string yourAmount = null, string theirProduct = null, ContractCurrency theirCurrency = ContractCurrency.NONE, string theirAmount = null, int threadId = 0, int middlemanId = 0, int timeoutDays = 0, bool isPublic = false, string paymentAddress = null) { var request = new ContractRequest(); request.Type = RequestType.Write; request.Parameters.Add("_action", "new"); request.Parameters.Add("_uid", userId); request.Parameters.Add("_position", position); request.Parameters.Add("_terms", terms); if (yourProduct != null) { request.Parameters.Add("_yourproduct", yourProduct); } if (yourCurrency != ContractCurrency.NONE) { request.Parameters.Add("_yourcurrency", yourCurrency.ToString()); } if (yourAmount != null) { request.Parameters.Add("_youramount", yourAmount); } if (theirProduct != null) { request.Parameters.Add("_theirproduct", theirProduct); } if (theirCurrency != ContractCurrency.NONE) { request.Parameters.Add("_theircurrency", theirCurrency.ToString()); } if (theirAmount != null) { request.Parameters.Add("_theiramount", theirAmount); } if (threadId != 0) { request.Parameters.Add("_tid", threadId); } if (middlemanId != 0) { request.Parameters.Add("_muid", middlemanId); } if (timeoutDays != 0) { request.Parameters.Add("_timeout", timeoutDays); } if (isPublic != false) { request.Parameters.Add("_public", "yes"); } if (paymentAddress != null) { request.Parameters.Add("_address", paymentAddress); } request.AddResultParameters(); return(request.ProcessRequest <ContractResult>(client)); }
/// <summary> /// Creates a new contract initiated by the current token user with the specified parameters. /// Requires <see cref="APIPermission.CONTRACTS" /> /// <summary> /// <param name="userId">The id of the other user to begin the contract with.</param> /// <param name="position">The current user's position in the contract.</param> /// <param name="terms">The terms of the contract.</param> /// <param name="yourProduct">The user's product.</param> /// <param name="yourCurrency">The user's currency.</param> /// <param name="yourAmount">The user's amount (and currency if ContractCurrency.OTHER).</param> /// <param name="theirProduct">The other user's product.</param> /// <param name="theirCurrency">The other user's currency.</param> /// <param name="theirAmount">The other user's amount (and currency if ContractCurrency.OTHER).</param> /// <param name="threadId">The id of the thread to link this contract to.</param> /// <param name="middlemanId">The user id of the middleman.</param> /// <param name="timeoutDays">The time (in days) that the contract will expire.</param> /// <param name="isPublic">Whether this is a public contract.</param> /// <param name="paymentAddress">The payment address.</param> public ContractResult ContractCreate(int userId, ContractPosition position, string terms, string yourProduct = null, ContractCurrency yourCurrency = ContractCurrency.NONE, string yourAmount = null, string theirProduct = null, ContractCurrency theirCurrency = ContractCurrency.NONE, string theirAmount = null, int threadId = 0, int middlemanId = 0, int timeoutDays = 0, bool isPublic = false, string paymentAddress = null) => ContractRequest.Create(Client, userId, position, terms, yourProduct, yourCurrency, yourAmount, theirProduct, theirCurrency, theirAmount, threadId, middlemanId, timeoutDays, isPublic, paymentAddress);