Exemple #1
0
        internal ApiResponse ExecuteMethod(string MethodName, bool IsSaMethod, DataItemCollection Parameters)
        {
            IApiRequest request = this.provider.CreateRequest(MethodName, Parameters);

            request.Version    = this.Version;
            request.CallID     = GetCallID().ToString();
            request.ApiKey     = (IsSaMethod ? this.ApiKeySa : this.ApiKeyPublic);
            request.SessionID  = this.sessionID;
            request.SaPasscode = (IsSaMethod ? this.SaPasscode : string.Empty);
            request.CallOrigin = this.CallOrigin;

            ApiResponse response = this.provider.ExecuteRequest(request);

            //if (!response.ErrorCode.Equals(ErrorCode.NoError))
            //{
            //throw new Exception(string.Format("Error executing API method {0} ({1}). Message: '{2}'", MethodName, response.ErrorCode, response.ErrorMessage));
            //}

            return(response);
        }
Exemple #2
0
        internal ApiResponse ExecuteMethodWithUpload(string MethodName, bool IsSaMethod, DataItemCollection Parameters, string UploadFieldName, string UploadFileName, string UploadContentType)
        {
            IApiRequest request = this.provider.CreateRequest(MethodName, Parameters);

            request.Version    = this.Version;
            request.CallID     = GetCallID().ToString();
            request.ApiKey     = (IsSaMethod ? this.ApiKeySa : this.ApiKeyPublic);
            request.SessionID  = this.sessionID;
            request.SaPasscode = (IsSaMethod ? this.SaPasscode : string.Empty);
            request.CallOrigin = this.CallOrigin;

            NameValueCollection nvc = new NameValueCollection();
            //If we needed to send over other values in other fields, we could use the NVC here.

            ApiResponse response = this.provider.ExecuteRequestWithUpload(request, UploadFileName, UploadFieldName, UploadContentType, nvc);

            //if (!response.ErrorCode.Equals(ErrorCode.NoError))
            //{
            //throw new Exception(string.Format("Error executing API method {0} ({1}). Message: '{2}'", MethodName, response.ErrorCode, response.ErrorMessage));
            //}

            return(response);
        }
Exemple #3
0
 /// <summary>
 /// Executes an API method (MethodName) with the Arguments (Parameters) and returns the result.
 /// </summary>
 /// <param name="MethodName">The name of the method to execute (ex: Session.Create)</param>
 /// <param name="Parameters">Method arguments</param>
 /// <returns>ApiResponse object containing the results of the method call</returns>
 public ApiResponse ExecuteMethod(string MethodName, DataItemCollection Parameters)
 {
     return(ExecuteMethod(MethodName, false, Parameters));
 }