/**
* Module: StorageApi.cs
* Description: Represents a collection of functions to interact with the API endpoints
* Author: Moralis Web3 Technology AB, 559307-5988 - David B. Goodrich
*
* NOTE: THIS FILE HAS BEEN AUTOMATICALLY GENERATED. ANY CHANGES MADE TO THIS
* FILE WILL BE LOST
*
* MIT License
*
* Copyright (c) 2022 Moralis Web3 Technology AB, 559307-5988
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the 'Software'), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Net;
using Cysharp.Threading.Tasks;
using MoralisUnity.Web3Api.Client;
using MoralisUnity.Web3Api.Core;
using MoralisUnity.Web3Api.Core.Models;
using MoralisUnity.Web3Api.Interfaces;
using MoralisUnity.Web3Api.Models;
namespace MoralisUnity.Web3Api.Api
{
///
/// Represents a collection of functions to interact with the API endpoints
///
public class StorageApi : IStorageApi
{
///
/// Initializes a new instance of the class.
///
/// an instance of ApiClient (optional)
///
public StorageApi(ApiClient apiClient = null)
{
if (apiClient == null) // use the default one in Configuration
this.ApiClient = Configuration.DefaultApiClient;
else
this.ApiClient = apiClient;
}
///
/// Initializes a new instance of the class.
///
///
public StorageApi(String basePath)
{
this.ApiClient = new ApiClient(basePath);
}
///
/// Sets the base path of the API client.
///
/// The base path
/// The base path
public void SetBasePath(String basePath)
{
this.ApiClient.BasePath = basePath;
}
///
/// Gets the base path of the API client.
///
/// The base path
/// The base path
public String GetBasePath(String basePath)
{
return this.ApiClient.BasePath;
}
///
/// Gets or sets the API client.
///
/// An instance of the ApiClient
public ApiClient ApiClient {get; set;}
///
/// Uploads multiple files and place them in a folder directory
///
///
/// Array of JSON and Base64 Supported
/// Returns the path to the uploaded files
public async UniTask> UploadFolder (List abi)
{
// Verify the required parameter 'abi' is set
if (abi == null) throw new ApiException(400, "Missing required parameter 'abi' when calling UploadFolder");
var postBody = new List();
var queryParams = new Dictionary();
var headerParams = new Dictionary();
var formParams = new Dictionary();
var fileParams = new Dictionary();
var path = "/ipfs/uploadFolder";
path = path.Replace("{format}", "json");
if (abi != null) postBody.Add(ApiClient.ParameterToString(abi));
// Authentication setting, if any
String[] authSettings = new String[] { "ApiKeyAuth" };
string bodyData = postBody.Count > 0 ? JsonConvert.SerializeObject(postBody) : null;
Tuple, string> response =
await ApiClient.CallApi(path, Method.POST, queryParams, bodyData, headerParams, formParams, fileParams, authSettings);
if (((int)response.Item1) >= 400)
throw new ApiException((int)response.Item1, "Error calling UploadFolder: " + response.Item3, response.Item3);
else if (((int)response.Item1) == 0)
throw new ApiException((int)response.Item1, "Error calling UploadFolder: " + response.Item3, response.Item3);
return (List)ApiClient.Deserialize(response.Item3, typeof(List), response.Item2);
}
}
}