Example #1
0
        /// <summary>
        /// Add a subaccount for the authenticated user or client Add a subaccount for the authenticated user or client
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="accountId">Account ID</param>
        /// <param name="data">Subaccount data</param>
        /// <returns>Task of AccountFull</returns>
        public async System.Threading.Tasks.Task <AccountFull> CreateAccountSubaccountAsync(int?accountId, CreateSubaccountParams data)
        {
            ApiResponse <AccountFull> localVarResponse = await CreateAccountSubaccountAsyncWithHttpInfo(accountId, data);

            return(localVarResponse.Data);
        }
Example #2
0
        /// <summary>
        /// Add a subaccount for the authenticated user or client Add a subaccount for the authenticated user or client
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="accountId">Account ID</param>
        /// <param name="data">Subaccount data</param>
        /// <returns>Task of ApiResponse (AccountFull)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <AccountFull> > CreateAccountSubaccountAsyncWithHttpInfo(int?accountId, CreateSubaccountParams data)
        {
            // verify the required parameter 'accountId' is set
            if (accountId == null)
            {
                throw new ApiException(400, "Missing required parameter 'accountId' when calling SubaccountsApi->CreateAccountSubaccount");
            }
            // verify the required parameter 'data' is set
            if (data == null)
            {
                throw new ApiException(400, "Missing required parameter 'data' when calling SubaccountsApi->CreateAccountSubaccount");
            }

            var    localVarPath         = "/accounts/{account_id}/subaccounts";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (accountId != null)
            {
                localVarPathParams.Add("account_id", Configuration.ApiClient.ParameterToString(accountId));                    // path parameter
            }
            if (data != null && data.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(data); // http body (model) parameter
            }
            else
            {
                localVarPostBody = data; // byte array
            }

            // authentication (apiKey) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Authorization")))
            {
                localVarHeaderParams["Authorization"] = Configuration.GetApiKeyWithPrefix("Authorization");
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("CreateAccountSubaccount", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <AccountFull>(localVarStatusCode,
                                                 localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                 (AccountFull)Configuration.ApiClient.Deserialize(localVarResponse, typeof(AccountFull))));
        }
Example #3
0
        /// <summary>
        /// Add a subaccount for the authenticated user or client Add a subaccount for the authenticated user or client
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="accountId">Account ID</param>
        /// <param name="data">Subaccount data</param>
        /// <returns>AccountFull</returns>
        public AccountFull CreateAccountSubaccount(int?accountId, CreateSubaccountParams data)
        {
            ApiResponse <AccountFull> localVarResponse = CreateAccountSubaccountWithHttpInfo(accountId, data);

            return(localVarResponse.Data);
        }