├── .gitignore ├── .vs └── config │ └── applicationhost.config ├── BillBeeApiSDK.sln ├── Billbee.Api.Client.Demo ├── Billbee.Api.Client.Demo.csproj ├── Config.json.dummy ├── Logger.cs └── Program.cs ├── Billbee.Api.Client.Test ├── .gitignore ├── ApiClientTest.cs ├── ApiSyncTest.cs ├── Billbee.Api.Client.Test.csproj ├── Config.test.json ├── EndPointIntegrationTests │ ├── AutomaticProvisionEndPointIntegrationTest.cs │ ├── CloudStoragesEndPointIntegrationTest.cs │ ├── CustomerAddressesEndPointIntegrationTest.cs │ ├── CustomerEndPointIntegrationTest.cs │ ├── EnumEndPointIntegrationTest.cs │ ├── EventEndPointIntegrationTest.cs │ ├── Helpers │ │ ├── CrudHelpers.cs │ │ ├── IntegrationTestHelpers.cs │ │ ├── IntegrationTestSettings.cs │ │ └── RequiresApiAccessAttribute.cs │ ├── OrderEndPointIntegrationTest.cs │ ├── ProductEndPointIntegrationTest.cs │ ├── SearchEndPointIntegrationTest.cs │ ├── ShipmentEndPointIntegrationTest.cs │ └── WebhookEndPointIntegrationTest.cs ├── EndPointTests │ ├── AutomaticProvisionEndPointTest.cs │ ├── CloudStoragesEndPointTest.cs │ ├── CustomerAddressesEndPointTest.cs │ ├── CustomerEndPointTest.cs │ ├── EnumEndPointTest.cs │ ├── EventEndPointTest.cs │ ├── OrderEndPointTest.cs │ ├── ProductEndPointTest.cs │ ├── SearchEndPointTest.cs │ ├── ShipmentEndPointTest.cs │ └── WebhookEndPointTest.cs ├── TestCategories.cs ├── TestHelpers.cs ├── Usings.cs ├── config.test.json └── readme.txt ├── Billbee.Api.Client ├── ApiClient.cs ├── ApiConfiguration.cs ├── ApiMappingAttribute.cs ├── Billbee.Api.Client.csproj ├── Billbee.Api.Client.csproj.user ├── BillbeeRestClient.cs ├── Endpoint │ ├── AutomaticProvisionEndPoint.cs │ ├── CloudStoragesEndPoint.cs │ ├── CustomerAddressesEndPoint.cs │ ├── CustomerEndPoint.cs │ ├── EnumEndPoint.cs │ ├── EventEndPoint.cs │ ├── Interfaces │ │ ├── IAutomaticProvisionEndPoint.cs │ │ ├── ICloudStoragesEndPoint.cs │ │ ├── ICustomerAddressesEndPoint.cs │ │ ├── ICustomerEndPoint.cs │ │ ├── IEnumEndPoint.cs │ │ ├── IEventEndPoint.cs │ │ ├── IOrderEndPoint.cs │ │ ├── IProductEndPoint.cs │ │ ├── ISearchEndPoint.cs │ │ ├── IShipmentEndPoint.cs │ │ └── IWebhookEndPoint.cs │ ├── OrderEndPoint.cs │ ├── ProductEndPoint.cs │ ├── SearchEndPoint.cs │ ├── ShipmentEndPoint.cs │ └── WebhookEndPoint.cs ├── Enums │ ├── ErrorHandlingEnum.cs │ ├── EventTypeEnum.cs │ ├── OrderStateEnum.cs │ ├── PaymentTypeEnum.cs │ ├── ProductIdType.cs │ ├── ReportTemplates.cs │ ├── ShipmentTypeEnum.cs │ ├── ShippingCarrierEnum.cs │ └── VatModeEnum.cs ├── IApiClient.cs ├── IBillbeeRestClient.cs ├── ILogger.cs ├── InvalidValueException.cs ├── Model │ ├── Account.cs │ ├── Address.cs │ ├── ApiResult.cs │ ├── ArticleCategory.cs │ ├── ArticleCustomFieldDefinition.cs │ ├── ArticleImage.cs │ ├── ArticleSource.cs │ ├── AtticleCustomFieldValue.cs │ ├── CloudStorage.cs │ ├── Comment.cs │ ├── CreateUserResult.cs │ ├── CurrentStock.cs │ ├── Customer.cs │ ├── CustomerAddress.cs │ ├── CustomerForCreation.cs │ ├── CustomerSearchResult.cs │ ├── DeletedImages.cs │ ├── DeliveryNote.cs │ ├── EnumEntry.cs │ ├── Event.cs │ ├── GetReservedAmountResult.cs │ ├── Invoice.cs │ ├── InvoiceDetail.cs │ ├── InvoicePosition.cs │ ├── LayoutTemplate.cs │ ├── MultiLanguageString.cs │ ├── Order.cs │ ├── OrderItem.cs │ ├── OrderItemAttribute.cs │ ├── OrderItemProduct.cs │ ├── OrderPayment.cs │ ├── OrderProductImage.cs │ ├── OrderResult.cs │ ├── OrderSearchResult.cs │ ├── OrderShipment.cs │ ├── OrderShippingId.cs │ ├── OrderUser.cs │ ├── ParsePlaceholdersQuery.cs │ ├── ParsePlaceholdersResult.cs │ ├── Product.cs │ ├── ProductSearchResult.cs │ ├── Search.cs │ ├── SearchResult.cs │ ├── SendMessage.cs │ ├── Shipment.cs │ ├── ShipmentAddress.cs │ ├── ShipmentDimensions.cs │ ├── ShipmentPost.cs │ ├── ShipmentResult.cs │ ├── ShipmentWithLabel.cs │ ├── ShipmentWithLabelResult.cs │ ├── ShippingCarrier.cs │ ├── ShippingProduct.cs │ ├── ShippingProvider.cs │ ├── Stock.cs │ ├── StockArticle.cs │ ├── TermsResult.cs │ ├── TriggerEventContainer.cs │ ├── UpdateStock.cs │ ├── UpdateStockCode.cs │ ├── Webhook.cs │ └── WebhookFilter.cs ├── favicon_32.ico └── forUnitTests.cs ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio. 3 | ################################################################################ 4 | 5 | /packages 6 | /.vs/BillBeeApiSDK/v15 7 | /Billbee.Api.Client/bin/Debug 8 | /Billbee.Api.Client/obj/Debug 9 | /Billbee.Api.Client.Demo/bin/Debug 10 | /Billbee.Api.Client.Demo/obj/Debug 11 | /Billbee.Api.Client.Demo/Config.json 12 | /Billbee.Api.Client/obj/Release 13 | /Billbee.Api.Client.Demo/obj/Release 14 | /.vs 15 | -------------------------------------------------------------------------------- /BillBeeApiSDK.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27004.2006 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Billbee.Api.Client", "Billbee.Api.Client\Billbee.Api.Client.csproj", "{814BD848-4AED-411F-B585-4519A6E0E44D}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Billbee.Api.Client.Demo", "Billbee.Api.Client.Demo\Billbee.Api.Client.Demo.csproj", "{37E147A5-6B5B-4012-A38E-0828D8E229EA}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Billbee.Api.Client.Test", "Billbee.Api.Client.Test\Billbee.Api.Client.Test.csproj", "{3ADDE5CD-C642-476E-8ABA-6EC3031AE247}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {814BD848-4AED-411F-B585-4519A6E0E44D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {814BD848-4AED-411F-B585-4519A6E0E44D}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {814BD848-4AED-411F-B585-4519A6E0E44D}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {814BD848-4AED-411F-B585-4519A6E0E44D}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {37E147A5-6B5B-4012-A38E-0828D8E229EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {37E147A5-6B5B-4012-A38E-0828D8E229EA}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {37E147A5-6B5B-4012-A38E-0828D8E229EA}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {37E147A5-6B5B-4012-A38E-0828D8E229EA}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {3ADDE5CD-C642-476E-8ABA-6EC3031AE247}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {3ADDE5CD-C642-476E-8ABA-6EC3031AE247}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {3ADDE5CD-C642-476E-8ABA-6EC3031AE247}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {3ADDE5CD-C642-476E-8ABA-6EC3031AE247}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {5BA9C842-6A9F-4A2A-A89C-2A06EC820EAB} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Billbee.Api.Client.Demo/Billbee.Api.Client.Demo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 2.4.2.0 7 | Billbee.Api.Client.Demo 8 | Billbee GmbH 9 | Copyright©, 2023 by Billbee GmbH 10 | Billbee GmbH 11 | 2.4.2.0 12 | 2.4.2.0 13 | The Billbee API SDK for .Net 14 | https://github.com/billbeeio/billbee-csharp-sdk 15 | git 16 | true 17 | enable 18 | enable 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Billbee.Api.Client.Demo/Config.json.dummy: -------------------------------------------------------------------------------- 1 | { 2 | "Username": "", 3 | "Password": "", 4 | "ApiKey": "", 5 | "BaseUrl": "https: //app.billbee.io/api/v1", 6 | "errorHandlingBehaviour": 0 7 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Demo/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Billbee.Api.Client.Demo 4 | { 5 | /// 6 | /// Very simple logger, for writing data from the api to the console. 7 | /// 8 | public class Logger : ILogger 9 | { 10 | /// 11 | /// Generates a log message to the console. 12 | /// 13 | /// The message, that describes the content of the log entry 14 | /// The severy, in which context the log message was created 15 | public void LogMsg(string message, LogSeverity severity) 16 | { 17 | Console.WriteLine($"{DateTime.Now} {severity}: {message}"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/.gitignore: -------------------------------------------------------------------------------- 1 | config.integration-tests.json -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/ApiClientTest.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Text; 3 | using Billbee.Api.Client.EndPoint; 4 | using Billbee.Api.Client.Enums; 5 | 6 | namespace Billbee.Api.Client.Test; 7 | 8 | [TestClass] 9 | public class ApiClientTest 10 | { 11 | [TestMethod] 12 | public void ApiClient_Init_Test() 13 | { 14 | var uut = new ApiClient(); 15 | 16 | Assert.IsNotNull(uut); 17 | Assert.IsNotNull(uut.Configuration); 18 | Assert.IsNull(uut.Configuration.Username); 19 | Assert.IsNull(uut.Configuration.Password); 20 | Assert.IsNull(uut.Configuration.ApiKey); 21 | Assert.AreEqual("https://app.billbee.io/api/v1", uut.Configuration.BaseUrl); 22 | Assert.AreEqual(ErrorHandlingEnum.ThrowException, uut.Configuration.ErrorHandlingBehaviour); 23 | 24 | Assert.IsNotNull(uut.AutomaticProvision); 25 | Assert.IsNotNull(uut.CloudStorages); 26 | Assert.IsNotNull(uut.Customer); 27 | Assert.IsNotNull(uut.Events); 28 | Assert.IsNotNull(uut.Orders); 29 | Assert.IsNotNull(uut.Products); 30 | Assert.IsNotNull(uut.Search); 31 | Assert.IsNotNull(uut.Shipment); 32 | Assert.IsNotNull(uut.Webhooks); 33 | } 34 | 35 | [TestMethod] 36 | public void ApiClient_InitWithConfig_Test() 37 | { 38 | var config = new ApiConfiguration 39 | { 40 | Username = "myUser", 41 | Password = "myPwd", 42 | ApiKey = "myApiKey", 43 | BaseUrl = "myBaseUrl", 44 | ErrorHandlingBehaviour = ErrorHandlingEnum.ReturnErrorContent 45 | }; 46 | 47 | var uut = new ApiClient(config); 48 | 49 | Assert.IsNotNull(uut); 50 | Assert.IsNotNull(uut.Configuration); 51 | Assert.AreEqual("myUser", uut.Configuration.Username); 52 | Assert.AreEqual("myPwd", uut.Configuration.Password); 53 | Assert.AreEqual("myApiKey", uut.Configuration.ApiKey); 54 | Assert.AreEqual("myBaseUrl", uut.Configuration.BaseUrl); 55 | Assert.AreEqual(ErrorHandlingEnum.ReturnErrorContent, uut.Configuration.ErrorHandlingBehaviour); 56 | } 57 | 58 | [TestMethod] 59 | public void ApiClient_InitWithConfigFile_Test() 60 | { 61 | var fiDll = new FileInfo(Assembly.GetExecutingAssembly().Location); 62 | Assert.IsNotNull(fiDll); 63 | Assert.IsNotNull(fiDll.Directory); 64 | var path = Path.Combine(fiDll.Directory.FullName, "../../../config.test"); 65 | var uut = new ApiClient(path); 66 | 67 | Assert.IsNotNull(uut); 68 | Assert.IsNotNull(uut.Configuration); 69 | Assert.AreEqual("myUserFromFile", uut.Configuration.Username); 70 | Assert.AreEqual("myPwdFromFile", uut.Configuration.Password); 71 | Assert.AreEqual("myApiKeyFromFile", uut.Configuration.ApiKey); 72 | Assert.AreEqual("myBaseUrlFromFile", uut.Configuration.BaseUrl); 73 | Assert.AreEqual(ErrorHandlingEnum.ReturnErrorContent, uut.Configuration.ErrorHandlingBehaviour); 74 | } 75 | 76 | private class TypeMapping 77 | { 78 | public TypeMapping(string uutClass, string uutTypeName, string testTypeName, bool foundMapping) 79 | { 80 | UutClass = uutClass; 81 | UutTypeName = uutTypeName; 82 | TestTypeName = testTypeName; 83 | FoundMapping = foundMapping; 84 | } 85 | 86 | public string UutClass { get; } 87 | public string UutTypeName { get; } 88 | public string TestTypeName { get; } 89 | public bool FoundMapping { get; } 90 | } 91 | 92 | [TestMethod] 93 | public void CheckAllTests_UnitTestsForAllEndpointsTest() 94 | { 95 | _checkTestMethods("Test", "_Test"); 96 | } 97 | 98 | [TestMethod] 99 | public void CheckAllTests_IntegrationTestsForAllEndpointsTest() 100 | { 101 | _checkTestMethods( "IntegrationTest", "_IntegrationTest"); 102 | } 103 | 104 | private void _checkTestMethods(string testClassPostfix, string testMethodPostfix) 105 | { 106 | var clientAssembly = Assembly.Load("Billbee.Api.Client"); 107 | var clientTypes = clientAssembly.GetTypes(); 108 | var testAssembly = Assembly.GetExecutingAssembly(); 109 | var testTypes = testAssembly.GetTypes(); 110 | 111 | var typeMappingsTestMethods = new List(); 112 | foreach (var clientType in clientTypes) 113 | { 114 | var clientTypeName = clientType.Name; 115 | if (clientType.Namespace == null || !clientType.Namespace.StartsWith("Billbee.Api.Client.EndPoint")) 116 | { 117 | continue; 118 | } 119 | 120 | var entityNamePrefix = clientTypeName.Substring(0, clientTypeName.IndexOf("EndPoint")) + "_"; 121 | 122 | var testTypeName = clientType.Name + testClassPostfix; 123 | var testType = testTypes.FirstOrDefault(t => t.IsClass && t.IsPublic && t.Name == testTypeName && t.GetCustomAttributes().Any(a => a is TestClassAttribute)); 124 | Assert.IsNotNull(testType); 125 | 126 | var bindingFlags = BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance; 127 | var clientMethods = clientType.GetMethods(bindingFlags); 128 | var testMethods = testType.GetMethods(bindingFlags).Where(m => m.GetCustomAttributes().Any(a => a is TestMethodAttribute)).ToList(); 129 | foreach (var clientMethod in clientMethods) 130 | { 131 | var clientMethodName = clientMethod.Name; 132 | 133 | var testMethodName = entityNamePrefix + clientMethodName + testMethodPostfix; 134 | var foundMapping = testMethods.Any(t => t.Name == testMethodName); 135 | if (clientTypeName != nameof(EnumEndPoint)) 136 | { 137 | typeMappingsTestMethods.Add(new TypeMapping(clientTypeName, clientMethodName, testMethodName, foundMapping)); 138 | } 139 | } 140 | } 141 | 142 | Console.WriteLine($"#SdkMethods={typeMappingsTestMethods.Count}, #{testMethodPostfix}Methods={typeMappingsTestMethods.Count(t => t.FoundMapping)}"); 143 | Console.WriteLine(); 144 | Console.WriteLine($"Test implemented,ClassName,UutTypeName,TestTypeName"); 145 | foreach (var typeMapping in typeMappingsTestMethods) 146 | { 147 | Console.WriteLine($"{typeMapping.FoundMapping},{typeMapping.UutClass},{typeMapping.UutTypeName},{typeMapping.TestTypeName}"); 148 | } 149 | 150 | Assert.IsTrue(typeMappingsTestMethods.All(t => t.FoundMapping)); 151 | } 152 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/ApiSyncTest.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Reflection; 3 | using Microsoft.OpenApi; 4 | using Microsoft.OpenApi.Extensions; 5 | using Microsoft.OpenApi.Models; 6 | using Microsoft.OpenApi.Readers; 7 | 8 | namespace Billbee.Api.Client.Test; 9 | 10 | [TestClass] 11 | public class ApiSyncTest 12 | { 13 | [DebuggerDisplay("{Path}:{HttpOperation}")] 14 | public class ApiOperation 15 | { 16 | public string Path { get; set; } = null!; 17 | public HttpOperation HttpOperation { get; set; } 18 | 19 | public override string ToString() => $"{Path}:{HttpOperation}"; 20 | } 21 | 22 | [TestMethod] 23 | public async Task Api_SyncCheck_Test() 24 | { 25 | var sdkOps = GetSdkOperations(); 26 | var apiOps = await GetApiOperations(); 27 | 28 | var missingSdkOps = new List(); 29 | foreach (var apiOp in apiOps) 30 | { 31 | if (!sdkOps.Any(sdkOp => sdkOp.Path == apiOp.Path && sdkOp.HttpOperation == apiOp.HttpOperation)) 32 | { 33 | missingSdkOps.Add(apiOp); 34 | } 35 | } 36 | 37 | Console.WriteLine($"#ApiOps={apiOps.Count}, #SdkOps={sdkOps.Count}, #MissingSdkOps={missingSdkOps.Count}"); 38 | 39 | if (missingSdkOps.Count > 0) 40 | { 41 | Console.WriteLine("Missing Sdk Operations:"); 42 | foreach (var missingSdkOp in missingSdkOps) 43 | { 44 | Console.WriteLine(missingSdkOp.ToString()); 45 | } 46 | } 47 | 48 | Assert.AreEqual(0, missingSdkOps.Count); 49 | } 50 | 51 | private async Task> GetApiOperations() 52 | { 53 | var apiOps = new List(); 54 | var openApiDoc = await GetOpenApiDoc(); 55 | foreach (var path in openApiDoc.Paths) 56 | { 57 | foreach (var op in path.Value.Operations) 58 | { 59 | if (Enum.TryParse(op.Key.ToString(), out HttpOperation httpOperation)) 60 | { 61 | var apiOp = new ApiOperation 62 | { 63 | Path = path.Key, 64 | HttpOperation = httpOperation 65 | }; 66 | apiOps.Add(apiOp); 67 | } 68 | else 69 | { 70 | Assert.Fail("unknown Path.OperationType"); 71 | } 72 | } 73 | } 74 | 75 | return apiOps; 76 | } 77 | 78 | private static List GetSdkOperations() 79 | { 80 | var sdkOps = new List(); 81 | var endpointTypes = Assembly.GetAssembly(typeof(ApiClient))?.GetTypes() 82 | .Where(t => t.Namespace == "Billbee.Api.Client.EndPoint"); 83 | Assert.IsNotNull(endpointTypes); 84 | foreach (var endpoint in endpointTypes) 85 | { 86 | foreach (var methodInfo in endpoint.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | 87 | BindingFlags.Public)) 88 | { 89 | if (methodInfo.GetCustomAttributes(true).FirstOrDefault(x => x is ApiMappingAttribute) is 90 | ApiMappingAttribute apiMappingAttr) 91 | { 92 | var op = new ApiOperation 93 | { 94 | Path = apiMappingAttr.ApiPath, 95 | HttpOperation = apiMappingAttr.HttpOperation 96 | }; 97 | sdkOps.Add(op); 98 | } 99 | } 100 | } 101 | 102 | return sdkOps; 103 | } 104 | 105 | private async Task GetOpenApiDoc() 106 | { 107 | var httpClient = new HttpClient 108 | { 109 | BaseAddress = new Uri("https://app.billbee.io/") 110 | }; 111 | 112 | var stream = await httpClient.GetStreamAsync("/swagger/docs/v1"); 113 | 114 | return new OpenApiStreamReader().Read(stream, out var diagnostic); 115 | } 116 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/Billbee.Api.Client.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | Billbee.Api.Client.Test 8 | Billbee GmbH 9 | Copyright©, 2023 by Billbee GmbH 10 | Billbee GmbH 11 | 2.4.2.0 12 | 2.4.2.0 13 | 14 | false 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | all 25 | runtime; build; native; contentfiles; analyzers; buildtransitive 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/Config.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "Username": "myUserFromFile", 3 | "Password": "myPwdFromFile", 4 | "ApiKey": "myApiKeyFromFile", 5 | "BaseUrl": "myBaseUrlFromFile", 6 | "errorHandlingBehaviour": 1 7 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/AutomaticProvisionEndPointIntegrationTest.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using Billbee.Api.Client.Model; 3 | using Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 4 | 5 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers 6 | { 7 | public static partial class TestData 8 | { 9 | public static Account Account(string name) => new Account 10 | { 11 | EMail = "john+" + name + "@test.com", 12 | Password = "1Ufuyk2s", 13 | AcceptTerms = true, 14 | Address = new Account.UserAddress 15 | { 16 | Company = "Test Company GmbH", 17 | Name = name, 18 | Address1 = "Paulinenstr. 4", 19 | Address2 = "address 2", 20 | Zip = "12345", 21 | City = "Flipstadt", 22 | Country = "DE", 23 | VatId = name + "-VatId" 24 | }, 25 | AffiliateCouponCode = "affiliateCouponCode", 26 | Vat1Rate = 19, 27 | Vat2Rate = 7, 28 | DefaultVatMode = 0, 29 | DefaultCurrrency = "EUR", 30 | DefaultVatIndex = 0 31 | }; 32 | } 33 | } 34 | 35 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests 36 | { 37 | [TestClass] 38 | [TestCategory(TestCategories.IntegrationTests)] 39 | public class AutomaticProvisionEndPointIntegrationTest 40 | { 41 | #pragma warning disable CS8618 42 | public TestContext TestContext { get; set; } 43 | #pragma warning restore CS8618 44 | 45 | [TestInitialize] 46 | public void TestInitialize() 47 | { 48 | IntegrationTestHelpers.CheckAccess(TestContext.ManagedType, TestContext.ManagedMethod); 49 | } 50 | 51 | [TestMethod] 52 | [RequiresApiAccess] 53 | public void AutomaticProvision_CreateAccount_IntegrationTest() 54 | { 55 | Assert.Inconclusive(); 56 | return; 57 | 58 | // var account = TestData.Account(Guid.NewGuid().ToString()); 59 | // var result = 60 | // CrudHelpers.CreateApiResult(x => IntegrationTestHelpers.ApiClient.AutomaticProvision.CreateAccount(x), 61 | // account, false); 62 | // var createUserResult = result.Data; 63 | // Assert.IsNotNull(createUserResult.Password); 64 | // Assert.IsNotNull(createUserResult.UserId); 65 | } 66 | 67 | [TestMethod] 68 | [RequiresApiAccess] 69 | public async Task AutomaticProvision_TermsInfo_IntegrationTest() 70 | { 71 | var result = IntegrationTestHelpers.ApiClient.AutomaticProvision.TermsInfo(); 72 | Assert.IsNotNull(result); 73 | 74 | var termsResult = result.Data; 75 | 76 | Assert.IsNotNull(termsResult); 77 | Assert.IsNotNull(termsResult.LinkToTermsWebPage); 78 | await _checkLink(termsResult.LinkToTermsWebPage); 79 | Assert.IsNotNull(termsResult.LinkToPrivacyWebPage); 80 | await _checkLink(termsResult.LinkToPrivacyWebPage); 81 | 82 | Assert.AreEqual(string.Empty, termsResult.LinkToTermsHtmlContent); 83 | Assert.AreEqual(string.Empty, termsResult.LinkToPrivacyHtmlContent); 84 | } 85 | 86 | private async Task _checkLink(string url) 87 | { 88 | var httpClient = new HttpClient(); 89 | var response = await httpClient.GetAsync(url); 90 | response.EnsureSuccessStatusCode(); 91 | 92 | Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/CloudStoragesEndPointIntegrationTest.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 2 | 3 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests; 4 | 5 | [TestClass] 6 | [TestCategory(TestCategories.IntegrationTests)] 7 | public class CloudStoragesEndPointIntegrationTest 8 | { 9 | #pragma warning disable CS8618 10 | public TestContext TestContext { get; set; } 11 | #pragma warning restore CS8618 12 | 13 | [TestInitialize] 14 | public void TestInitialize() 15 | { 16 | IntegrationTestHelpers.CheckAccess(TestContext.ManagedType, TestContext.ManagedMethod); 17 | } 18 | 19 | [TestMethod] 20 | [RequiresApiAccess] 21 | public void CloudStorages_GetCloudStorageList_IntegrationTest() 22 | { 23 | CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.CloudStorages.GetCloudStorageList()); 24 | } 25 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/CustomerAddressesEndPointIntegrationTest.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Model; 2 | using Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 3 | 4 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers 5 | { 6 | public static partial class TestData 7 | { 8 | public static CustomerAddress CustomerAddress => 9 | new CustomerAddress 10 | { 11 | FirstName = "John", 12 | LastName = "Doe", 13 | Street = "Mustergasse", 14 | Housenumber = "1", 15 | Zip = "12345", 16 | City = "Musterstadt", 17 | AddressType = 1, 18 | CountryCode = "DE", 19 | CustomerId = 0 20 | }; 21 | 22 | public static CustomerAddress GetCustomerAddress(long? customerId) 23 | { 24 | var address = CustomerAddress; 25 | address.CustomerId = customerId; 26 | address.Street = Guid.NewGuid().ToString().Replace("-", ""); 27 | return address; 28 | } 29 | } 30 | } 31 | 32 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests 33 | { 34 | [TestClass] 35 | [TestCategory(TestCategories.IntegrationTests)] 36 | public class CustomerAddressesEndPointIntegrationTest 37 | { 38 | #pragma warning disable CS8618 39 | public TestContext TestContext { get; set; } 40 | #pragma warning restore CS8618 41 | 42 | [TestInitialize] 43 | public void TestInitialize() 44 | { 45 | IntegrationTestHelpers.CheckAccess(TestContext.ManagedType, TestContext.ManagedMethod); 46 | } 47 | 48 | [TestMethod] 49 | [RequiresApiAccess] 50 | public void CustomerAddresses_GetCustomerAddresses_IntegrationTest() 51 | { 52 | CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.CustomerAddresses.GetCustomerAddresses(1, 5)); 53 | } 54 | 55 | [TestMethod] 56 | [RequiresApiAccess] 57 | public void CustomerAddresses_GetCustomerAddress_IntegrationTest() 58 | { 59 | var customer = 60 | CrudHelpers.CreateApiResult(c => IntegrationTestHelpers.ApiClient.Customer.AddCustomer(c), 61 | TestData.Customer).Data; 62 | 63 | var customerAddress = 64 | CrudHelpers.CreateApiResult( 65 | a => IntegrationTestHelpers.ApiClient.CustomerAddresses.AddCustomerAddress(a), 66 | TestData.GetCustomerAddress(customer.Id)).Data; 67 | Assert.IsNotNull(customerAddress.Id); 68 | CrudHelpers.GetOneApiResult( 69 | (id) => IntegrationTestHelpers.ApiClient.CustomerAddresses.GetCustomerAddress(id), 70 | customerAddress.Id.Value); 71 | } 72 | 73 | [TestMethod] 74 | [RequiresApiAccess] 75 | public void CustomerAddresses_AddCustomerAddress_IntegrationTest() 76 | { 77 | CustomerAddresses_GetCustomerAddress_IntegrationTest(); 78 | } 79 | 80 | [TestMethod] 81 | [RequiresApiAccess] 82 | public void CustomerAddresses_UpdateCustomerAddress_IntegrationTest() 83 | { 84 | var customer = 85 | CrudHelpers.CreateApiResult(c => IntegrationTestHelpers.ApiClient.Customer.AddCustomer(c), 86 | TestData.Customer).Data; 87 | 88 | var customerAddress = 89 | CrudHelpers.CreateApiResult( 90 | a => IntegrationTestHelpers.ApiClient.CustomerAddresses.AddCustomerAddress(a), 91 | TestData.GetCustomerAddress(customer.Id)).Data; 92 | Assert.IsNotNull(customerAddress.Id); 93 | var result = CrudHelpers.GetOneApiResult( 94 | (id) => IntegrationTestHelpers.ApiClient.CustomerAddresses.GetCustomerAddress(id), 95 | customerAddress.Id.Value); 96 | var address = result.Data; 97 | 98 | address.LastName = "Modified"; 99 | CrudHelpers.Put( 100 | c => IntegrationTestHelpers.ApiClient.CustomerAddresses.UpdateCustomerAddress(c), 101 | address); 102 | CrudHelpers.GetOneApiResult( 103 | (id) => IntegrationTestHelpers.ApiClient.CustomerAddresses.GetCustomerAddress(id), 104 | customerAddress.Id.Value); 105 | Assert.AreEqual("Modified", address.LastName); 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/EnumEndPointIntegrationTest.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Endpoint.Interfaces; 2 | using Billbee.Api.Client.Enums; 3 | using Billbee.Api.Client.Model; 4 | using Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 5 | 6 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests; 7 | 8 | [TestClass] 9 | [TestCategory(TestCategories.IntegrationTests)] 10 | public class EnumEndPointIntegrationTest 11 | { 12 | #pragma warning disable CS8618 13 | public TestContext TestContext { get; set; } 14 | #pragma warning restore CS8618 15 | 16 | [TestInitialize] 17 | public void TestInitialize() 18 | { 19 | IntegrationTestHelpers.CheckAccess(TestContext.ManagedType, TestContext.ManagedMethod); 20 | } 21 | 22 | [TestMethod] 23 | [RequiresApiAccess] 24 | public void Enum_GetPaymentTypes_IntegrationTest() 25 | { 26 | _executeEnumSyncTest(x => x.GetPaymentTypes()); 27 | } 28 | 29 | [TestMethod] 30 | [RequiresApiAccess] 31 | public void Enum_GetShippingCarriers_IntegrationTest() 32 | { 33 | _executeEnumSyncTest(x => x.GetShippingCarriers()); 34 | } 35 | 36 | [TestMethod] 37 | [RequiresApiAccess] 38 | public void Enum_GetShipmentTypes_IntegrationTest() 39 | { 40 | _executeEnumSyncTest(x => x.GetShipmentTypes()); 41 | } 42 | 43 | [TestMethod] 44 | [RequiresApiAccess] 45 | public void Enum_GetOrderStates_IntegrationTest() 46 | { 47 | _executeEnumSyncTest(x => x.GetOrderStates()); 48 | } 49 | 50 | private void _executeEnumSyncTest(Func> endpointFunc) where T: struct, System.Enum 51 | { 52 | var apiEnumEntries = endpointFunc(IntegrationTestHelpers.ApiClient.Enums); 53 | 54 | // enum entries in api, but not in sdk 55 | var missingSdkPaymentTypes = _getMissingSdkEnumEntries(apiEnumEntries); 56 | 57 | // enum entries in api and sdk, but with wrong number in sdk 58 | var sdkEnumEntriesWithWrongNumber = _getSdkEnumEntriesWithWrongNumber(apiEnumEntries); 59 | 60 | // enum entries in sdk, but not in api 61 | var deprecatedSdkPaymentTypes = _getDeprecatedSdkEnumEntries(apiEnumEntries); 62 | 63 | Assert.AreEqual(0, missingSdkPaymentTypes.Count); 64 | Assert.AreEqual(0, sdkEnumEntriesWithWrongNumber.Count); 65 | Assert.AreEqual(0, deprecatedSdkPaymentTypes.Count()); 66 | } 67 | 68 | private List _getMissingSdkEnumEntries(List apiEnumEntries) where T: struct, System.Enum 69 | { 70 | var result = apiEnumEntries 71 | .Where(apiEnumEntry => !Enum.TryParse(apiEnumEntry.Name, out T _)) 72 | .OrderBy(x => x.Id) 73 | .ToList(); 74 | 75 | if (result.Count > 0) 76 | { 77 | Console.WriteLine("Missing sdk enum entries:"); 78 | foreach (var enumEntry in result) 79 | { 80 | Console.WriteLine($"{enumEntry.Name}: {enumEntry.Id}"); 81 | } 82 | } 83 | 84 | return result; 85 | } 86 | 87 | private Dictionary _getSdkEnumEntriesWithWrongNumber(List apiEnumEntries) where T: struct, System.Enum 88 | { 89 | var result = apiEnumEntries 90 | .Where(apiEnumEntry => Enum.TryParse(apiEnumEntry.Name, out T sdkEnumEntry)) 91 | .Select(apiEnumEntry => 92 | { 93 | Enum.TryParse(apiEnumEntry.Name, out T sdkEnumEntry); 94 | return new KeyValuePair(sdkEnumEntry, (apiEnumEntry.Id, Convert.ToInt32(sdkEnumEntry))); 95 | }) 96 | .Where(x => x.Value.Item1 != x.Value.Item2) 97 | .OrderBy(x => x.Value.Item1) 98 | .ToDictionary(x => x.Key, x => x.Value); 99 | 100 | 101 | if (result.Count > 0) 102 | { 103 | Console.WriteLine("Sdk enum entries with wrong number:"); 104 | foreach (var pair in result) 105 | { 106 | Console.WriteLine($"{pair.Key}: expected:{pair.Value.Item1}, actual:{pair.Value.Item2}"); 107 | } 108 | } 109 | 110 | return result; 111 | } 112 | 113 | private IEnumerable _getDeprecatedSdkEnumEntries(List apiEnumEntries) where T: struct, System.Enum 114 | { 115 | var result = new List(); 116 | foreach (var sdkEnumEntry in Enum.GetValues()) 117 | { 118 | var apiEnumEntry = apiEnumEntries.FirstOrDefault(x => x.Id == Convert.ToInt32(sdkEnumEntry)); 119 | if (apiEnumEntry == null) 120 | { 121 | result.Add(sdkEnumEntry); 122 | } 123 | } 124 | 125 | if (result.Count > 0) 126 | { 127 | Console.WriteLine("Deprecated sdk enum entries:"); 128 | foreach (var enumEntry in result) 129 | { 130 | Console.WriteLine($"{enumEntry}: {Convert.ToInt32(enumEntry)}"); 131 | } 132 | } 133 | 134 | return result; 135 | } 136 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/EventEndPointIntegrationTest.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 2 | 3 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests; 4 | 5 | [TestClass] 6 | [TestCategory(TestCategories.IntegrationTests)] 7 | public class EventEndPointIntegrationTest 8 | { 9 | #pragma warning disable CS8618 10 | public TestContext TestContext { get; set; } 11 | #pragma warning restore CS8618 12 | 13 | [TestInitialize] 14 | public void TestInitialize() 15 | { 16 | IntegrationTestHelpers.CheckAccess(TestContext.ManagedType, TestContext.ManagedMethod); 17 | } 18 | 19 | [TestMethod] 20 | [RequiresApiAccess] 21 | public void Event_GetEvents_IntegrationTest() 22 | { 23 | var result = CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Events.GetEvents()); 24 | Assert.IsTrue(result.Data.Count > 0); 25 | } 26 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/Helpers/IntegrationTestHelpers.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 4 | 5 | public static class IntegrationTestHelpers 6 | { 7 | private static ApiClient? _apiClient; 8 | 9 | public static void CheckAccess(string? testContextManagedType, string? testContextManagedMethod) 10 | { 11 | Assert.IsNotNull(testContextManagedType); 12 | Assert.IsNotNull(testContextManagedMethod); 13 | if (!IntegrationTestSettings.RunIntegrationTests) 14 | { 15 | Assert.Inconclusive( 16 | $"This test is an integration-test. But integration-tests are disable currently (see property {nameof(IntegrationTestSettings)}{nameof(IntegrationTestSettings.RunIntegrationTests)})."); 17 | return; 18 | } 19 | 20 | var type = Assembly.GetExecutingAssembly().GetType(testContextManagedType); 21 | Assert.IsNotNull(type); 22 | var mi = type.GetMethod(testContextManagedMethod); 23 | Assert.IsNotNull(mi); 24 | bool requiresApiAccess = mi.GetCustomAttributes().Any(); 25 | if (requiresApiAccess && !IntegrationTestSettings.AllowReadWriteAccessToBillbeeApi) 26 | { 27 | Assert.Inconclusive( 28 | $"This test is an integration-test and requires api-access. But api-access is not granted currently (see property {nameof(IntegrationTestSettings)}{nameof(IntegrationTestSettings.AllowReadWriteAccessToBillbeeApi)})."); 29 | } 30 | } 31 | 32 | public static ApiClient ApiClient 33 | { 34 | get 35 | { 36 | if (_apiClient == null) 37 | { 38 | var fiDll = new FileInfo(Assembly.GetExecutingAssembly().Location); 39 | Assert.IsNotNull(fiDll.Directory); 40 | var di = new DirectoryInfo(Path.Combine(fiDll.Directory.FullName, "../../../")); 41 | var path = Path.Combine(di.FullName, "config.integration-tests.json"); 42 | if (!File.Exists(path)) 43 | { 44 | Assert.Fail( 45 | $"This test requires api-access, but the required config-file could not be found: '{path}'"); 46 | } 47 | 48 | _apiClient = new ApiClient(path, null, IntegrationTestSettings.AllowReadWriteAccessToBillbeeApi); 49 | Assert.IsTrue(_apiClient.TestConfiguration()); 50 | } 51 | 52 | Thread.Sleep(500); // throttle api-calls when executing multiple tests 53 | 54 | return _apiClient; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/Helpers/IntegrationTestSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 2 | 3 | public static class IntegrationTestSettings 4 | { 5 | public static bool RunIntegrationTests = false; 6 | 7 | // !!! be careful: setting the following property to 'true' will potentially add/change/delete parts your billbee data !!! 8 | public static bool AllowReadWriteAccessToBillbeeApi = false; 9 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/Helpers/RequiresApiAccessAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 2 | 3 | public class RequiresApiAccessAttribute : Attribute 4 | { 5 | 6 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/SearchEndPointIntegrationTest.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Model; 2 | using Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 3 | using Newtonsoft.Json; 4 | using RestSharp.Serialization.Json; 5 | using JsonSerializer = System.Text.Json.JsonSerializer; 6 | 7 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests; 8 | 9 | [TestClass] 10 | [TestCategory(TestCategories.IntegrationTests)] 11 | public class SearchEndPointIntegrationTest 12 | { 13 | #pragma warning disable CS8618 14 | public TestContext TestContext { get; set; } 15 | #pragma warning restore CS8618 16 | 17 | [TestInitialize] 18 | public void TestInitialize() 19 | { 20 | IntegrationTestHelpers.CheckAccess(TestContext.ManagedType, TestContext.ManagedMethod); 21 | } 22 | 23 | [TestMethod] 24 | [RequiresApiAccess] 25 | public void Search_SearchTerm_IntegrationTest() 26 | { 27 | var customer = CrudHelpers.CreateApiResult(c => IntegrationTestHelpers.ApiClient.Customer.AddCustomer(c), TestData.Customer); 28 | Assert.IsNotNull(customer); 29 | 30 | var search = new Search 31 | { 32 | Term = "john", 33 | Type = new List { "customer" } 34 | }; 35 | var result = IntegrationTestHelpers.ApiClient.Search.SearchTerm(search); 36 | Assert.IsNotNull(result); 37 | Assert.IsNotNull(result.Customers); 38 | Assert.IsTrue(result.Customers.Count > 0); 39 | } 40 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/ShipmentEndPointIntegrationTest.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Model; 2 | using Billbee.Api.Client.Model.Rechnungsdruck.WebApp.Model.Api; 3 | using Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 4 | 5 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers 6 | { 7 | public static partial class TestData 8 | { 9 | public static ShipmentWithLabel GetShipmentWithLabel(long orderId, string? printerName, long productId, long providerId) => new ShipmentWithLabel 10 | { 11 | OrderId = orderId, 12 | Dimension = new ShipmentDimensions 13 | { 14 | height = 10, 15 | length = 10, 16 | width = 10, 17 | }, 18 | ClientReference = "clientRef", 19 | PrinterName = printerName, 20 | ProductId = productId, 21 | ProviderId = providerId, 22 | ShipDate = DateTime.Now, 23 | WeightInGram = 500, 24 | ChangeStateToSend = true, 25 | }; 26 | 27 | public static PostShipment GetPostShipment(string? printerName, string providerName, byte shippingCarrier, string productCode) => 28 | new PostShipment 29 | { 30 | Dimension = new ShipmentDimensions 31 | { 32 | height = 10, 33 | length = 10, 34 | width = 10, 35 | }, 36 | ClientReference = "clientRef", 37 | PrinterName = printerName, 38 | ProviderName = providerName, 39 | ShipDate = DateTime.Now, 40 | WeightInGram = 500, 41 | shippingCarrier = shippingCarrier, 42 | Services = new List(), 43 | ReceiverAddress = new ShipmentAddress 44 | { 45 | FirstName = "John", 46 | LastName = "Doe", 47 | Street = "Teststraße", 48 | Housenumber = "1", 49 | Zip = "12345", 50 | City = "Teststadt", 51 | CountryCode = "DE", 52 | Email = "john@doe.com", 53 | Telephone = "0123456789", 54 | }, 55 | OrderSum = 10.0M, 56 | OrderCurrencyCode = "EUR", 57 | TotalNet = 8.40M, 58 | ProductCode = productCode, 59 | }; 60 | } 61 | } 62 | 63 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests 64 | { 65 | [TestClass] 66 | [TestCategory(TestCategories.IntegrationTests)] 67 | public class ShipmentEndPointIntegrationTest 68 | { 69 | #pragma warning disable CS8618 70 | public TestContext TestContext { get; set; } 71 | #pragma warning restore CS8618 72 | 73 | [TestInitialize] 74 | public void TestInitialize() 75 | { 76 | IntegrationTestHelpers.CheckAccess(TestContext.ManagedType, TestContext.ManagedMethod); 77 | } 78 | 79 | [TestMethod] 80 | [RequiresApiAccess] 81 | public void Shipment_GetShipments_IntegrationTest() 82 | { 83 | CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Shipment.GetShipments()); 84 | } 85 | 86 | [TestMethod] 87 | [RequiresApiAccess] 88 | public void Shipment_GetShippingProvider_IntegrationTest() 89 | { 90 | CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Shipment.GetShippingProvider()); 91 | } 92 | 93 | [TestMethod] 94 | [RequiresApiAccess] 95 | public void Shipment_ShipOrderWithLabel_IntegrationTest() 96 | { 97 | var provider = CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Shipment.GetShippingProvider()) 98 | .First(); 99 | 100 | var customer = 101 | CrudHelpers.CreateApiResult(c => IntegrationTestHelpers.ApiClient.Customer.AddCustomer(c), 102 | TestData.Customer).Data; 103 | var customerAddress = 104 | CrudHelpers.CreateApiResult( 105 | a => IntegrationTestHelpers.ApiClient.CustomerAddresses.AddCustomerAddress(a), 106 | TestData.GetCustomerAddress(customer.Id)).Data; 107 | var extRef = Guid.NewGuid().ToString(); 108 | var testOrder = TestData.Order; 109 | testOrder.Customer = customer; 110 | Assert.IsNotNull(customerAddress.Id); 111 | var address = new Address{ BillbeeId = customerAddress.Id.Value }; 112 | testOrder.InvoiceAddress = address; 113 | testOrder.ShippingAddress = address; 114 | 115 | var order = new OrderEndPointIntegrationTest().CreateOrder(testOrder, extRef); 116 | var orderId = order.BillBeeOrderId; 117 | Assert.IsNotNull(orderId); 118 | var providerId = provider.id; 119 | var productId = provider.products.First().id; 120 | 121 | var shipmentWithLabel = TestData.GetShipmentWithLabel(orderId.Value, null, productId, providerId); 122 | var result = CrudHelpers.CreateApiResult( 123 | s => IntegrationTestHelpers.ApiClient.Shipment.ShipOrderWithLabel(s), shipmentWithLabel, false); 124 | Assert.AreEqual(shipmentWithLabel.OrderId, result.Data.OrderId); 125 | } 126 | 127 | [TestMethod] 128 | [RequiresApiAccess] 129 | public void Shipment_PostShipment_IntegrationTest() 130 | { 131 | var provider = CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Shipment.GetShippingProvider()) 132 | .First(); 133 | var carrier = CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Shipment.GetShippingCarriers()).FirstOrDefault(x => x.Name == "dhl"); 134 | var carriers = IntegrationTestHelpers.ApiClient.Shipment.GetShippingCarriers().Select(x => $"{x.Id}:{x.Name}"); 135 | Console.WriteLine(carriers); 136 | 137 | Assert.IsNotNull(carrier); 138 | var postShipment = TestData.GetPostShipment(null, provider.name, carrier.Id, provider.products.First().productName); 139 | var shipment = CrudHelpers.CreateApiResult(x => IntegrationTestHelpers.ApiClient.Shipment.PostShipment(x), 140 | postShipment, false); 141 | Console.WriteLine($"Shipment created, ShippingId={shipment.Data.ShippingId}"); 142 | 143 | Assert.IsFalse(string.IsNullOrWhiteSpace(shipment.Data.ShippingId)); 144 | } 145 | 146 | [TestMethod] 147 | [RequiresApiAccess] 148 | public void Shipment_GetShippingCarriers_IntegrationTest() 149 | { 150 | CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Shipment.GetShippingCarriers()); 151 | } 152 | } 153 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointIntegrationTests/WebhookEndPointIntegrationTest.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Model; 2 | using Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers; 3 | 4 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests.Helpers 5 | { 6 | public static partial class TestData 7 | { 8 | public static Webhook WebHook => new Webhook 9 | { 10 | Id = null, 11 | WebHookUri = "https://webhook.site/5290627f-b5e3-4123-a715-26a721054617?noecho", 12 | Secret = "4e4451af-63c5-44f4-a3c5-1dcf8617fc5c", 13 | Description = "A simple description", 14 | IsPaused = true, 15 | Filters = new List { "order.created" }, 16 | Headers = new Dictionary 17 | { { "TestHeader", "TestHeaderValue" }, { "Another Testheader", "Another Value" } }, 18 | Properties = new Dictionary() 19 | }; 20 | } 21 | } 22 | 23 | namespace Billbee.Api.Client.Test.EndPointIntegrationTests 24 | { 25 | [TestClass] 26 | [TestCategory(TestCategories.IntegrationTests)] 27 | public class WebhookEndPointIntegrationTest 28 | { 29 | #pragma warning disable CS8618 30 | public TestContext TestContext { get; set; } 31 | #pragma warning restore CS8618 32 | private long _countBeforeTest = -1; 33 | private long _countExpectedAfterTest = -1; 34 | 35 | [TestInitialize] 36 | public void TestInitialize() 37 | { 38 | IntegrationTestHelpers.CheckAccess(TestContext.ManagedType, TestContext.ManagedMethod); 39 | 40 | var result = CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Webhooks.GetWebhooks()); 41 | _countBeforeTest = result.Count; 42 | _countExpectedAfterTest = result.Count; 43 | } 44 | 45 | [TestCleanup] 46 | public void TestCleanup() 47 | { 48 | IntegrationTestHelpers.CheckAccess(TestContext.ManagedType, TestContext.ManagedMethod); 49 | 50 | var result = CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Webhooks.GetWebhooks()); 51 | Assert.AreEqual(_countExpectedAfterTest, result.Count); 52 | } 53 | 54 | [TestMethod] 55 | [RequiresApiAccess] 56 | public void Webhook_GetFilters_IntegrationTest() 57 | { 58 | CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Webhooks.GetFilters()); 59 | } 60 | 61 | [TestMethod] 62 | [RequiresApiAccess] 63 | public void Webhook_GetWebhooks_IntegrationTest() 64 | { 65 | CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Webhooks.GetWebhooks()); 66 | } 67 | 68 | [TestMethod] 69 | [RequiresApiAccess] 70 | public void Webhook_GetWebhook_IntegrationTest() 71 | { 72 | var webhook = CrudHelpers.Create(w => IntegrationTestHelpers.ApiClient.Webhooks.CreateWebhook(w), 73 | TestData.WebHook); 74 | CrudHelpers.GetOne((id) => IntegrationTestHelpers.ApiClient.Webhooks.GetWebhook(id), webhook.Id); 75 | 76 | // cleanup 77 | CrudHelpers.DeleteOne((id) => IntegrationTestHelpers.ApiClient.Webhooks.DeleteWebhook(id), 78 | webhook.Id); 79 | } 80 | 81 | [TestMethod] 82 | [RequiresApiAccess] 83 | public void Webhook_CreateWebhook_IntegrationTest() 84 | { 85 | var webhook = CrudHelpers.Create(w => IntegrationTestHelpers.ApiClient.Webhooks.CreateWebhook(w), 86 | TestData.WebHook); 87 | Assert.AreEqual(TestData.WebHook.WebHookUri, webhook.WebHookUri); 88 | 89 | // cleanup 90 | CrudHelpers.DeleteOne((id) => IntegrationTestHelpers.ApiClient.Webhooks.DeleteWebhook(id), 91 | webhook.Id); 92 | } 93 | 94 | [TestMethod] 95 | [RequiresApiAccess] 96 | public void Webhook_DeleteAllWebhooks_IntegrationTest() 97 | { 98 | if (_countBeforeTest > 0) 99 | { 100 | Assert.Inconclusive( 101 | "The connected account contains webhooks. Cannot execute this test-method, because it would delete all existing webhooks."); 102 | } 103 | 104 | CrudHelpers.Create(w => IntegrationTestHelpers.ApiClient.Webhooks.CreateWebhook(w), TestData.WebHook); 105 | CrudHelpers.Create(w => IntegrationTestHelpers.ApiClient.Webhooks.CreateWebhook(w), TestData.WebHook); 106 | var webhooks = CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Webhooks.GetWebhooks()); 107 | Assert.AreEqual(2, webhooks.Count); 108 | 109 | CrudHelpers.DeleteAll(() => IntegrationTestHelpers.ApiClient.Webhooks.DeleteAllWebhooks()); 110 | 111 | webhooks = CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Webhooks.GetWebhooks()); 112 | Assert.AreEqual(0, webhooks.Count); 113 | 114 | _countExpectedAfterTest = 0; 115 | } 116 | 117 | [TestMethod] 118 | [RequiresApiAccess] 119 | public void Webhook_DeleteWebhook_IntegrationTest() 120 | { 121 | var webhook = CrudHelpers.Create(w => IntegrationTestHelpers.ApiClient.Webhooks.CreateWebhook(w), 122 | TestData.WebHook); 123 | var webhooks = CrudHelpers.GetAll(() => IntegrationTestHelpers.ApiClient.Webhooks.GetWebhooks()); 124 | Assert.IsTrue(webhooks.Count > 0); 125 | 126 | var webhookToDelete = webhook; 127 | Assert.IsNotNull(webhookToDelete); 128 | CrudHelpers.DeleteOne((id) => IntegrationTestHelpers.ApiClient.Webhooks.DeleteWebhook(id), 129 | webhookToDelete.Id); 130 | 131 | CrudHelpers.GetOneExpectException((id) => IntegrationTestHelpers.ApiClient.Webhooks.GetWebhook(id), 132 | webhookToDelete.Id); 133 | } 134 | 135 | [TestMethod] 136 | [RequiresApiAccess] 137 | public void Webhook_UpdateWebhook_IntegrationTest() 138 | { 139 | var webhook = CrudHelpers.Create(w => IntegrationTestHelpers.ApiClient.Webhooks.CreateWebhook(w), 140 | TestData.WebHook); 141 | webhook = CrudHelpers.GetOne((id) => IntegrationTestHelpers.ApiClient.Webhooks.GetWebhook(id), 142 | webhook.Id); 143 | 144 | webhook.Description = "modified"; 145 | CrudHelpers.Put((webhook) => IntegrationTestHelpers.ApiClient.Webhooks.UpdateWebhook(webhook), 146 | webhook); 147 | 148 | webhook = CrudHelpers.GetOne((id) => IntegrationTestHelpers.ApiClient.Webhooks.GetWebhook(id), 149 | webhook.Id); 150 | Assert.AreEqual("modified", webhook.Description); 151 | 152 | // cleanup 153 | CrudHelpers.DeleteOne((id) => IntegrationTestHelpers.ApiClient.Webhooks.DeleteWebhook(id), 154 | webhook.Id); 155 | } 156 | } 157 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointTests/AutomaticProvisionEndPointTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Linq.Expressions; 3 | using Billbee.Api.Client.EndPoint; 4 | using Billbee.Api.Client.Model; 5 | using Moq; 6 | 7 | namespace Billbee.Api.Client.Test.EndPointTests; 8 | 9 | [TestClass] 10 | [TestCategory(TestCategories.EndpointTests)] 11 | public class AutomaticProvisionEndPointTest 12 | { 13 | [TestMethod] 14 | public void AutomaticProvision_CreateAccount_Test() 15 | { 16 | var testAccount = new Account(); 17 | var testCreateUserResult = new CreateUserResult 18 | { 19 | UserId = new Guid("cf65821e-6549-4944-be0b-a71112cf50a9"), 20 | Password = "thePwd", 21 | OneTimeLoginUrl = "theOneTimeLoginUrl" 22 | }; 23 | 24 | Expression> expression = x => x.Post>("/automaticprovision/createaccount", testAccount, null); 25 | var mockResult = TestHelpers.GetApiResult(testCreateUserResult); 26 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 27 | { 28 | var uut = new AutomaticProvisionEndPoint(restClient); 29 | var result = uut.CreateAccount(testAccount); 30 | Assert.IsNotNull(result.Data); 31 | }); 32 | } 33 | 34 | [TestMethod] 35 | public void AutomaticProvision_TermsInfo_Test() 36 | { 37 | var testTermsResult = new TermsResult(); 38 | 39 | Expression> expression = x => x.Get>("/automaticprovision/termsinfo", null); 40 | object mockResult = TestHelpers.GetApiResult(testTermsResult); 41 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 42 | { 43 | var uut = new AutomaticProvisionEndPoint(restClient); 44 | var result = uut.TermsInfo(); 45 | Assert.IsNotNull(result.Data); 46 | }); 47 | } 48 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointTests/CloudStoragesEndPointTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Linq.Expressions; 3 | using Billbee.Api.Client.EndPoint; 4 | using Billbee.Api.Client.Model; 5 | using Moq; 6 | 7 | namespace Billbee.Api.Client.Test.EndPointTests; 8 | 9 | [TestClass] 10 | [TestCategory(TestCategories.EndpointTests)] 11 | public class CloudStoragesEndPointTest 12 | { 13 | [TestMethod] 14 | public void CloudStorages_GetCloudStorageList_Test() 15 | { 16 | var testCloudStorage = new CloudStorage(); 17 | 18 | Expression> expression = x => x.Get>>($"/cloudstorages", null); 19 | object mockResult = TestHelpers.GetApiResult(new List { testCloudStorage }); 20 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 21 | { 22 | var uut = new CloudStoragesEndPoint(restClient); 23 | var result = uut.GetCloudStorageList(); 24 | Assert.IsNotNull(result.Data); 25 | }); 26 | } 27 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointTests/CustomerAddressesEndPointTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Linq.Expressions; 3 | using Billbee.Api.Client.EndPoint; 4 | using Billbee.Api.Client.Model; 5 | 6 | namespace Billbee.Api.Client.Test.EndPointTests; 7 | 8 | [TestClass] 9 | [TestCategory(TestCategories.EndpointTests)] 10 | public class CustomerAddressesEndPointTest 11 | { 12 | [TestMethod] 13 | public void CustomerAddresses_GetCustomerAddresses_Test() 14 | { 15 | var testCustomerAddress = new CustomerAddress { Id = 4711 }; 16 | var page = 1; 17 | var pageSize = 5; 18 | NameValueCollection parameters = new NameValueCollection 19 | { 20 | { "page", page.ToString() }, 21 | { "pageSize", pageSize.ToString() } 22 | }; 23 | 24 | Expression> expression = x => x.Get>>($"/customer-addresses", parameters); 25 | object mockResult = TestHelpers.GetApiPagedResult(new List { testCustomerAddress }); 26 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 27 | { 28 | var uut = new CustomerAddressesEndPoint(restClient); 29 | var result = uut.GetCustomerAddresses(page, pageSize); 30 | Assert.IsNotNull(result.Data); 31 | }); 32 | } 33 | 34 | [TestMethod] 35 | public void CustomerAddresses_GetCustomerAddress_Test() 36 | { 37 | var testCustomerAddress = new CustomerAddress { Id = 4711 }; 38 | 39 | Expression> expression = x => x.Get>($"/customer-addresses/{testCustomerAddress.Id}", null); 40 | object mockResult = TestHelpers.GetApiResult(testCustomerAddress); 41 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 42 | { 43 | var uut = new CustomerAddressesEndPoint(restClient); 44 | var result = uut.GetCustomerAddress(testCustomerAddress.Id.Value); 45 | Assert.IsNotNull(result.Data); 46 | }); 47 | } 48 | 49 | [TestMethod] 50 | public void CustomerAddresses_AddCustomerAddress_Test() 51 | { 52 | var testCustomerAddress = new CustomerAddress { Id = 4711 }; 53 | 54 | Expression> expression = x => x.Post>($"/customer-addresses", testCustomerAddress, null); 55 | object mockResult = TestHelpers.GetApiResult(testCustomerAddress); 56 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 57 | { 58 | var uut = new CustomerAddressesEndPoint(restClient); 59 | var result = uut.AddCustomerAddress(testCustomerAddress); 60 | Assert.IsNotNull(result.Data); 61 | }); 62 | } 63 | 64 | [TestMethod] 65 | public void CustomerAddresses_UpdateCustomerAddress_Test() 66 | { 67 | var testCustomerAddress = new CustomerAddress { Id = 4711 }; 68 | 69 | Expression> expression = x => x.Put>($"/customer-addresses/{testCustomerAddress.Id}", testCustomerAddress, null); 70 | object mockResult = TestHelpers.GetApiResult(testCustomerAddress); 71 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 72 | { 73 | var uut = new CustomerAddressesEndPoint(restClient); 74 | 75 | testCustomerAddress.Id = null; 76 | Assert.ThrowsException(() => uut.UpdateCustomerAddress(testCustomerAddress)); 77 | 78 | testCustomerAddress.Id = 4711; 79 | var result = uut.UpdateCustomerAddress(testCustomerAddress); 80 | Assert.IsNotNull(result.Data); 81 | }); 82 | } 83 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointTests/EnumEndPointTest.cs: -------------------------------------------------------------------------------- 1 | using System.Linq.Expressions; 2 | using Billbee.Api.Client.EndPoint; 3 | using Billbee.Api.Client.Endpoint.Interfaces; 4 | using Billbee.Api.Client.Enums; 5 | using Billbee.Api.Client.Model; 6 | 7 | namespace Billbee.Api.Client.Test.EndPointTests; 8 | 9 | [TestClass] 10 | [TestCategory(TestCategories.EndpointTests)] 11 | public class EnumEndPointTest 12 | { 13 | [TestMethod] 14 | public void Enum_GetPaymentTypes_Test() 15 | { 16 | _executeEnumTest("paymenttypes", x => x.GetPaymentTypes()); 17 | } 18 | 19 | [TestMethod] 20 | public void Enum_GetShippingCarriers_Test() 21 | { 22 | _executeEnumTest("shippingcarriers", x => x.GetShippingCarriers()); 23 | } 24 | 25 | [TestMethod] 26 | public void Enum_GetShipmentTypes_Test() 27 | { 28 | _executeEnumTest("shipmenttypes", x => x.GetShipmentTypes()); 29 | } 30 | 31 | [TestMethod] 32 | public void Enum_GetOrderStates_Test() 33 | { 34 | _executeEnumTest("orderstates", x => x.GetOrderStates()); 35 | } 36 | 37 | private void _executeEnumTest(string endpoint, Func> endpointFunc) 38 | { 39 | var testEnumEntryList = new List 40 | { 41 | new() { Id = 1, Name = "entry1" }, 42 | new() { Id = 2, Name = "entry2" }, 43 | }; 44 | 45 | Expression> expression = x => 46 | x.Get>($"/enums/{endpoint}", null); 47 | object mockResult = testEnumEntryList; 48 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 49 | { 50 | var uut = new EnumEndPoint(restClient); 51 | var result = endpointFunc(uut); 52 | Assert.IsNotNull(result); 53 | Assert.AreEqual(2, result.Count); 54 | }); 55 | } 56 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointTests/EventEndPointTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Linq.Expressions; 3 | using Billbee.Api.Client.EndPoint; 4 | using Billbee.Api.Client.Enums; 5 | using Billbee.Api.Client.Model; 6 | using Moq; 7 | 8 | namespace Billbee.Api.Client.Test.EndPointTests; 9 | 10 | [TestClass] 11 | [TestCategory(TestCategories.EndpointTests)] 12 | public class EventEndPointTest 13 | { 14 | [TestMethod] 15 | public void Event_GetEvents_Test() 16 | { 17 | var testEvent = new Event(); 18 | DateTime? minDate = DateTime.Now.AddDays(-2); 19 | DateTime? maxDate = DateTime.Now.AddDays(-1); 20 | int page = 1; 21 | int pageSize = 5; 22 | List typeIds = new List { EventTypeEnum.OrderImported }; 23 | long? orderId = 4711; 24 | NameValueCollection parameters = new NameValueCollection 25 | { 26 | { "minDate", minDate.Value.ToString("yyyy-MM-dd HH:mm") }, 27 | { "maxDate", maxDate.Value.ToString("yyyy-MM-dd") }, 28 | { "page", page.ToString() }, 29 | { "pageSize", pageSize.ToString() }, 30 | { "orderId", orderId.ToString() } 31 | }; 32 | int index = 0; 33 | foreach (var typeId in typeIds) 34 | { 35 | parameters.Add($"typeId[{index}]", ((int) typeId).ToString()); 36 | index++; 37 | } 38 | 39 | Expression> expression = x => x.Get>>($"/events", parameters); 40 | object mockResult = TestHelpers.GetApiPagedResult(new List { testEvent }); 41 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 42 | { 43 | var uut = new EventEndPoint(restClient); 44 | var result = uut.GetEvents(minDate, maxDate, page, pageSize, typeIds, orderId); 45 | Assert.IsNotNull(result.Data); 46 | Assert.AreEqual(1, result.Data.Count); 47 | }); 48 | } 49 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointTests/SearchEndPointTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Linq.Expressions; 3 | using Billbee.Api.Client.EndPoint; 4 | using Billbee.Api.Client.Model; 5 | using Moq; 6 | 7 | namespace Billbee.Api.Client.Test.EndPointTests; 8 | 9 | [TestClass] 10 | [TestCategory(TestCategories.EndpointTests)] 11 | public class SearchEndPointTest 12 | { 13 | private static SearchResult CreateTestSearchResult() => new(); 14 | 15 | [TestMethod] 16 | public void Search_SearchTerm_Test() 17 | { 18 | var testSearchResult = CreateTestSearchResult(); 19 | var search = new Search 20 | { 21 | Term = "foo", 22 | Type = new List { "customer", "order" } 23 | }; 24 | 25 | Expression> expression = x => x.Post($"/search", search, null); 26 | object mockResult = testSearchResult; 27 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 28 | { 29 | var uut = new SearchEndPoint(restClient); 30 | var result = uut.SearchTerm(search); 31 | Assert.IsNotNull(result); 32 | }); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointTests/ShipmentEndPointTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Linq.Expressions; 3 | using System.Net; 4 | using Billbee.Api.Client.EndPoint; 5 | using Billbee.Api.Client.Model; 6 | using Billbee.Api.Client.Model.Rechnungsdruck.WebApp.Model.Api; 7 | using Moq; 8 | 9 | namespace Billbee.Api.Client.Test.EndPointTests; 10 | 11 | [TestClass] 12 | [TestCategory(TestCategories.EndpointTests)] 13 | public class ShipmentEndPointTest 14 | { 15 | [TestMethod] 16 | public void Shipment_GetShippingProvider_Test() 17 | { 18 | var testShippingProvider = new ShippingProvider(); 19 | 20 | Expression> expression = x => x.Get>($"/shipment/shippingproviders", null); 21 | object mockResult = new List { testShippingProvider }; 22 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 23 | { 24 | var uut = new ShipmentEndPoint(restClient); 25 | var result = uut.GetShippingProvider(); 26 | Assert.AreEqual(1, result.Count); 27 | }); 28 | } 29 | 30 | [TestMethod] 31 | public void Shipment_GetShipments_Test() 32 | { 33 | var testShipment = new Shipment(); 34 | 35 | Expression> expression = x => x.Get>>($"/shipment/shipments", It.IsAny()); 36 | object mockResult = TestHelpers.GetApiPagedResult(new List { testShipment }); 37 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 38 | { 39 | var uut = new ShipmentEndPoint(restClient); 40 | var result = uut.GetShipments(1, 20); 41 | Assert.AreEqual(1, result.Data.Count); 42 | }); 43 | } 44 | 45 | [TestMethod] 46 | public void Shipment_PostShipment_Test() 47 | { 48 | var testShipmentResult = new ShipmentResult(); 49 | var testPostShipment = new PostShipment(); 50 | 51 | Expression> expression = x => x.Post>($"/shipment/shipment", testPostShipment, null); 52 | object mockResult = TestHelpers.GetApiResult(testShipmentResult); 53 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 54 | { 55 | var uut = new ShipmentEndPoint(restClient); 56 | var result = uut.PostShipment(testPostShipment); 57 | Assert.IsNotNull(result.Data); 58 | }); 59 | } 60 | 61 | [TestMethod] 62 | public void Shipment_ShipOrderWithLabel_Test() 63 | { 64 | var testShipmentWithLabel = new ShipmentWithLabel(); 65 | var testShipmentWithLabelResult = new ShipmentWithLabelResult(); 66 | 67 | Expression> expression = x => x.Post>($"/shipment/shipwithlabel", testShipmentWithLabel, null); 68 | object mockResult = TestHelpers.GetApiResult(testShipmentWithLabelResult); 69 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 70 | { 71 | var uut = new ShipmentEndPoint(restClient); 72 | var result = uut.ShipOrderWithLabel(testShipmentWithLabel); 73 | Assert.IsNotNull(result.Data); 74 | }); 75 | } 76 | 77 | [TestMethod] 78 | public void Shipment_GetShippingCarriers_Test() 79 | { 80 | var testShippingCarrier = new ShippingCarrier(); 81 | 82 | Expression> expression = x => x.Get>($"/shipment/shippingcarriers", null); 83 | object mockResult = new List { testShippingCarrier }; 84 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 85 | { 86 | var uut = new ShipmentEndPoint(restClient); 87 | var result = uut.GetShippingCarriers(); 88 | Assert.AreEqual(1, result.Count); 89 | }); 90 | } 91 | 92 | [TestMethod] 93 | public void Shipment_Ping_Test() 94 | { 95 | var restClientMock = new Mock(); 96 | restClientMock 97 | .Setup(x => x.Get(It.IsAny())) 98 | .Returns(HttpStatusCode.OK); 99 | 100 | var uut = new ShipmentEndPoint(restClientMock.Object); 101 | var result = uut.Ping(); 102 | Assert.AreEqual(true, result); 103 | 104 | restClientMock 105 | .Setup(x => x.Get(It.IsAny())) 106 | .Returns(HttpStatusCode.NotFound); 107 | result = uut.Ping(); 108 | restClientMock.Verify(x => x.Get($"/shipment/ping")); 109 | Assert.AreEqual(false, result); 110 | } 111 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/EndPointTests/WebhookEndPointTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Linq.Expressions; 3 | using Billbee.Api.Client.EndPoint; 4 | using Billbee.Api.Client.Model; 5 | using Moq; 6 | using RestSharp; 7 | 8 | namespace Billbee.Api.Client.Test.EndPointTests; 9 | 10 | [TestClass] 11 | [TestCategory(TestCategories.EndpointTests)] 12 | public class WebhookEndPointTest 13 | { 14 | private static Webhook CreateTestWebHook() 15 | { 16 | return new Webhook 17 | { 18 | Description = "theDesc", 19 | Filters = new List { "filter1", "filter2" }, 20 | Headers = new Dictionary { { "key1", "value1" }, { "key2", "value2" } }, 21 | Id = "theId", 22 | Properties = new Dictionary { { "prop1", "foo" }, { "prop2", 5 } }, 23 | Secret = "theSecret", 24 | IsPaused = false, 25 | WebHookUri = "theWebHookUri" 26 | }; 27 | } 28 | 29 | private static readonly WebhookFilter TestWebHookFilter = new WebhookFilter 30 | { 31 | Description = "theDesc", 32 | Name = "theName" 33 | }; 34 | 35 | [TestMethod] 36 | public void Webhook_GetWebhooks_Test() 37 | { 38 | var testWebHook = CreateTestWebHook(); 39 | 40 | Expression> expression = x => x.Get>("/webhooks", null); 41 | object mockResult = new List { testWebHook }; 42 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 43 | { 44 | var uut = new WebhookEndPoint(restClient); 45 | var result = uut.GetWebhooks(); 46 | Assert.IsNotNull(result); 47 | Assert.AreEqual(1, result.Count); 48 | Assert.AreEqual(testWebHook.Id, result.First().Id); 49 | }); 50 | } 51 | 52 | [TestMethod] 53 | public void Webhook_GetWebhook_Test() 54 | { 55 | var testWebHook = CreateTestWebHook(); 56 | 57 | Expression> expression = x => x.Get($"/webhooks/{testWebHook.Id}", null); 58 | object mockResult = testWebHook; 59 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 60 | { 61 | var uut = new WebhookEndPoint(restClient); 62 | var result = uut.GetWebhook(testWebHook.Id); 63 | Assert.AreEqual(testWebHook.Id, result.Id); 64 | }); 65 | } 66 | 67 | [TestMethod] 68 | public void Webhook_GetFilters_Test() 69 | { 70 | Expression> expression = x => x.Get>("/webhooks/filters", null); 71 | object mockResult = new List { TestWebHookFilter }; 72 | TestHelpers.RestClientMockTest(expression, mockResult, (restClient) => 73 | { 74 | var uut = new WebhookEndPoint(restClient); 75 | var result = uut.GetFilters(); 76 | Assert.AreEqual(TestWebHookFilter.Name, result.First().Name); 77 | }); 78 | } 79 | 80 | [TestMethod] 81 | public void Webhook_DeleteAllWebhooks_Test() 82 | { 83 | var restClientMock = new Mock(); 84 | restClientMock 85 | .Setup(x => x.Delete(It.IsAny(), It.IsAny(), It.IsAny())); 86 | var uut = new WebhookEndPoint(restClientMock.Object); 87 | 88 | uut.DeleteAllWebhooks(); 89 | 90 | restClientMock.Verify(x => x.Delete("/webhooks", null, ParameterType.QueryString)); 91 | } 92 | 93 | [TestMethod] 94 | public void Webhook_DeleteWebhook_Test() 95 | { 96 | var testWebHook = CreateTestWebHook(); 97 | var restClientMock = new Mock(); 98 | restClientMock 99 | .Setup(x => x.Delete(It.IsAny(), It.IsAny(), It.IsAny())); 100 | var uut = new WebhookEndPoint(restClientMock.Object); 101 | 102 | uut.DeleteWebhook(testWebHook.Id); 103 | 104 | restClientMock.Verify(x => x.Delete($"/webhooks/{testWebHook.Id}", null, ParameterType.QueryString)); 105 | } 106 | 107 | [TestMethod] 108 | public void Webhook_UpdateWebhook_Test() 109 | { 110 | var testWebHook = CreateTestWebHook(); 111 | var restClientMock = new Mock(); 112 | restClientMock 113 | .Setup(x => x.Put(It.IsAny(), It.IsAny(), It.IsAny())); 114 | var uut = new WebhookEndPoint(restClientMock.Object); 115 | 116 | uut.UpdateWebhook(testWebHook); 117 | 118 | restClientMock.Verify(x => x.Put($"/webhooks/{testWebHook.Id}", testWebHook, null)); 119 | } 120 | 121 | [TestMethod] 122 | public void Webhook_CreateWebhook_Test() 123 | { 124 | var testWebHook = CreateTestWebHook(); 125 | testWebHook.Id = "4711"; 126 | var restClientMock = new Mock(); 127 | restClientMock 128 | .Setup(x => x.Post(It.IsAny(), It.IsAny())); 129 | var uut = new WebhookEndPoint(restClientMock.Object); 130 | 131 | Assert.ThrowsException(() => uut.CreateWebhook(testWebHook)); 132 | 133 | testWebHook.Id = null; 134 | testWebHook.Secret = "theSecret"; 135 | Assert.ThrowsException(() => uut.CreateWebhook(testWebHook)); 136 | 137 | testWebHook.Secret = "0123456789012345678901234567890123456789"; 138 | uut.CreateWebhook(testWebHook); 139 | restClientMock.Verify(x => x.Post("/webhooks", testWebHook, null)); 140 | } 141 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/TestCategories.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Test; 2 | 3 | public static class TestCategories 4 | { 5 | public const string IntegrationTests = "IntegrationTests"; 6 | public const string EndpointTests = "EndpointTests"; 7 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/TestHelpers.cs: -------------------------------------------------------------------------------- 1 | using System.Linq.Expressions; 2 | using Billbee.Api.Client.Model; 3 | using Moq; 4 | 5 | namespace Billbee.Api.Client.Test; 6 | 7 | public static class TestHelpers 8 | { 9 | public static void RestClientMockTest(Expression> expression, T mockResult, Action actAndAssert) 10 | { 11 | // arrange 12 | var restClientMock = new Mock(); 13 | restClientMock 14 | .Setup(expression) 15 | .Returns(mockResult); 16 | 17 | // act & assert 18 | actAndAssert(restClientMock.Object); 19 | restClientMock.Verify(expression); 20 | } 21 | 22 | public static ApiResult GetApiResult(T t, ApiResult.ErrorCodeEnum errorCode = ApiResult.ErrorCodeEnum.NoError, string? errorMessage = null) 23 | { 24 | return new ApiResult 25 | { 26 | ErrorCode = errorCode, 27 | ErrorMessage = errorMessage, 28 | Data = t 29 | }; 30 | } 31 | 32 | public static ApiPagedResult> GetApiPagedResult(List ts, int page = 1, int pageSize = 5, int totalPages = 10, ApiResult>.ErrorCodeEnum errorCode = ApiResult>.ErrorCodeEnum.NoError, string? errorMessage = null) 33 | { 34 | return new ApiPagedResult> 35 | { 36 | ErrorCode = errorCode, 37 | ErrorMessage = errorMessage, 38 | Data = ts, 39 | Paging = new ApiPagedResult>.PagingInformation 40 | { 41 | Page = page, 42 | PageSize = pageSize, 43 | TotalPages = totalPages, 44 | TotalRows = pageSize * totalPages 45 | } 46 | }; 47 | } 48 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/Usings.cs: -------------------------------------------------------------------------------- 1 | global using Microsoft.VisualStudio.TestTools.UnitTesting; -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/config.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "Username": "myUserFromFile", 3 | "Password": "myPwdFromFile", 4 | "ApiKey": "myApiKeyFromFile", 5 | "BaseUrl": "myBaseUrlFromFile", 6 | "errorHandlingBehaviour": 1 7 | } -------------------------------------------------------------------------------- /Billbee.Api.Client.Test/readme.txt: -------------------------------------------------------------------------------- 1 | The folder EndPointTests contains UnitTests for each endpoint, where the api is mocked. 2 | Thus, these UnitTests do not access the Billbee Api. 3 | 4 | The folder EndPointIntegrationTests contains UnitTests for each endpoint, which DO require access to the Billbee Api. 5 | It's required to provide a file named 'config.prod.json' on the project-level of this UnitTest project. 6 | To protect your Billbee data, these UnitTests will not be executed by default. 7 | -------------------------------------------------------------------------------- /Billbee.Api.Client/ApiClient.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.EndPoint; 2 | using Newtonsoft.Json; 3 | using System; 4 | using System.IO; 5 | using System.Reflection; 6 | using Billbee.Api.Client.Endpoint.Interfaces; 7 | 8 | namespace Billbee.Api.Client 9 | { 10 | /// 11 | public class ApiClient : IApiClient 12 | { 13 | private IBillbeeRestClient _restClient; 14 | 15 | public ApiClient(ApiConfiguration configuration = null, ILogger logger = null, bool allowReadWrite = true) 16 | { 17 | var config = configuration ?? new ApiConfiguration(); 18 | _init(config, logger, allowReadWrite); 19 | } 20 | 21 | public ApiClient(string configurationPath, ILogger logger = null, bool allowReadWrite = true) 22 | { 23 | var config = LoadConfigFromFile(configurationPath); 24 | _init(config, logger, allowReadWrite); 25 | } 26 | 27 | private void _init(ApiConfiguration configuration, ILogger logger, bool allowReadWrite = true) 28 | { 29 | Configuration = configuration; 30 | _restClient = new BillbeeRestClient(logger, Configuration, allowReadWrite); 31 | } 32 | 33 | public ApiConfiguration Configuration { get; private set; } 34 | 35 | public IEventEndPoint Events => new EventEndPoint(_restClient); 36 | 37 | public IShipmentEndPoint Shipment => new ShipmentEndPoint(_restClient); 38 | 39 | public IWebhookEndPoint Webhooks => new WebhookEndPoint(_restClient); 40 | 41 | public IProductEndPoint Products => new ProductEndPoint(_restClient); 42 | 43 | public IAutomaticProvisionEndPoint AutomaticProvision => new AutomaticProvisionEndPoint(_restClient); 44 | 45 | public ICustomerEndPoint Customer => new CustomerEndPoint(_restClient); 46 | 47 | public ICustomerAddressesEndPoint CustomerAddresses => new CustomerAddressesEndPoint(_restClient); 48 | 49 | public ISearchEndPoint Search => new SearchEndPoint(_restClient); 50 | 51 | public IOrderEndPoint Orders => new OrderEndPoint(_restClient); 52 | 53 | public ICloudStoragesEndPoint CloudStorages => new CloudStoragesEndPoint(_restClient); 54 | 55 | public IEnumEndPoint Enums => new EnumEndPoint(_restClient); 56 | 57 | public bool TestConfiguration() 58 | { 59 | try 60 | { 61 | return ((ShipmentEndPoint)Shipment).Ping(); 62 | } 63 | catch (Exception) // If user selects to throw exceptions on server side errors, or other errors occurs. 64 | { 65 | return false; 66 | } 67 | } 68 | 69 | private ApiConfiguration LoadConfigFromFile(string path = null) 70 | { 71 | if (string.IsNullOrWhiteSpace(path)) 72 | { 73 | path = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); 74 | } 75 | 76 | if (string.IsNullOrWhiteSpace(path)) 77 | { 78 | throw new FileNotFoundException($"The assembly file path could not be found."); 79 | } 80 | 81 | if (!path.ToLower().EndsWith(".json")) 82 | { 83 | path += ".json"; 84 | } 85 | 86 | if (!File.Exists(path)) 87 | { 88 | throw new FileNotFoundException($"The config file {path} could not be found."); 89 | } 90 | 91 | var configStr = File.ReadAllText(path); 92 | return JsonConvert.DeserializeObject(configStr); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Billbee.Api.Client/ApiConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Enums; 2 | 3 | namespace Billbee.Api.Client 4 | { 5 | /// 6 | /// Configuration parameters for the Billbee API client. 7 | /// 8 | public class ApiConfiguration 9 | { 10 | /// 11 | /// Username of the main user of your account. 12 | /// 13 | public string Username { get; set; } 14 | 15 | /// 16 | /// API password, could be set in Settings->Billbee API->General Settings 17 | /// 18 | public string Password { get; set; } 19 | 20 | /// 21 | /// The Api key for your application. Can be requested from the Billbee support. 22 | /// 23 | public string ApiKey { get; set; } 24 | 25 | /// 26 | /// The base url of the Billbee API. Typically, this sticks unchanged. 27 | /// 28 | public string BaseUrl { get; set; } = "https://app.billbee.io/api/v1"; 29 | 30 | /// 31 | /// How should the api treat server side errors 32 | /// 33 | public ErrorHandlingEnum ErrorHandlingBehaviour { get; set; } = ErrorHandlingEnum.ThrowException; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Billbee.Api.Client/ApiMappingAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | 4 | namespace Billbee.Api.Client 5 | { 6 | public enum HttpOperation 7 | { 8 | Get = 0, 9 | Post, 10 | Put, 11 | Patch, 12 | Delete, 13 | Head, 14 | Options, 15 | Trace 16 | } 17 | 18 | [AttributeUsage(AttributeTargets.Method)] 19 | public class ApiMappingAttribute : Attribute 20 | { 21 | public ApiMappingAttribute(string apiPath, HttpOperation httpOperation) 22 | { 23 | ApiPath = apiPath; 24 | HttpOperation = httpOperation; 25 | } 26 | 27 | public string ApiPath { get; set; } 28 | public HttpOperation HttpOperation { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Billbee.Api.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 2.4.2.0 6 | Billbee.Api.Client 7 | Billbee GmbH 8 | Copyright©, 2023 by Billbee GmbH 9 | Billbee GmbH 10 | 2.4.2.0 11 | 2.4.2.0 12 | Client SDK for the Billbee API 13 | https://github.com/billbeeio/billbee-csharp-sdk 14 | git 15 | true 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Billbee.Api.Client.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ProjectFiles 5 | 6 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/AutomaticProvisionEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using Billbee.Api.Client.Endpoint.Interfaces; 3 | using Billbee.Api.Client.Model; 4 | 5 | namespace Billbee.Api.Client.EndPoint 6 | { 7 | /// 8 | public class AutomaticProvisionEndPoint : IAutomaticProvisionEndPoint 9 | { 10 | private readonly IBillbeeRestClient _restClient; 11 | 12 | internal AutomaticProvisionEndPoint(IBillbeeRestClient restClient) 13 | { 14 | _restClient = restClient; 15 | } 16 | 17 | [ApiMapping("/api/v1/automaticprovision/createaccount", HttpOperation.Post)] 18 | public ApiResult CreateAccount(Account createAccountContainer) 19 | { 20 | return _restClient.Post>("/automaticprovision/createaccount", createAccountContainer); 21 | } 22 | 23 | [ApiMapping("/api/v1/automaticprovision/termsinfo", HttpOperation.Get)] 24 | public ApiResult TermsInfo() 25 | { 26 | return _restClient.Get>("/automaticprovision/termsinfo"); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/CloudStoragesEndPoint.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Model; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Billbee.Api.Client.Endpoint.Interfaces; 8 | 9 | namespace Billbee.Api.Client.EndPoint 10 | { 11 | /// 12 | public class CloudStoragesEndPoint : ICloudStoragesEndPoint 13 | { 14 | private readonly IBillbeeRestClient _restClient; 15 | 16 | internal CloudStoragesEndPoint(IBillbeeRestClient restClient) 17 | { 18 | _restClient = restClient; 19 | } 20 | 21 | [ApiMapping("/api/v1/cloudstorages", HttpOperation.Get)] 22 | public ApiResult> GetCloudStorageList() 23 | { 24 | return _restClient.Get>>($"/cloudstorages"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/CustomerAddressesEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.Specialized; 4 | using Billbee.Api.Client.Endpoint.Interfaces; 5 | using Billbee.Api.Client.Model; 6 | 7 | namespace Billbee.Api.Client.EndPoint 8 | { 9 | /// 10 | public class CustomerAddressesEndPoint : ICustomerAddressesEndPoint 11 | { 12 | private readonly IBillbeeRestClient _restClient; 13 | 14 | internal CustomerAddressesEndPoint(IBillbeeRestClient restClient) 15 | { 16 | _restClient = restClient; 17 | } 18 | 19 | [ApiMapping("/api/v1/customer-addresses", HttpOperation.Get)] 20 | public ApiPagedResult> GetCustomerAddresses(int page, int pageSize) 21 | { 22 | var parameters = new NameValueCollection 23 | { 24 | { "page", page.ToString() }, 25 | { "pageSize", pageSize.ToString() } 26 | }; 27 | 28 | return _restClient.Get>>("/customer-addresses", parameters); 29 | } 30 | 31 | [ApiMapping("/api/v1/customer-addresses/{id}", HttpOperation.Get)] 32 | public ApiResult GetCustomerAddress(long customerAddressId) 33 | { 34 | return _restClient.Get>($"/customer-addresses/{customerAddressId}"); 35 | } 36 | 37 | [ApiMapping("/api/v1/customer-addresses", HttpOperation.Post)] 38 | public ApiResult AddCustomerAddress(CustomerAddress customerAddress) 39 | { 40 | return _restClient.Post>("/customer-addresses", customerAddress); 41 | } 42 | 43 | [ApiMapping("/api/v1/customer-addresses/{id}", HttpOperation.Put)] 44 | public ApiResult UpdateCustomerAddress(CustomerAddress customerAddress) 45 | { 46 | if(customerAddress.Id == null || customerAddress.Id <= 0) 47 | { 48 | throw new InvalidValueException("Id must not be null."); 49 | } 50 | 51 | return _restClient.Put>($"/customer-addresses/{customerAddress.Id.Value}", customerAddress); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/CustomerEndPoint.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Model; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Collections.Specialized; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Billbee.Api.Client.Endpoint.Interfaces; 9 | 10 | namespace Billbee.Api.Client.EndPoint 11 | { 12 | /// 13 | public class CustomerEndPoint: ICustomerEndPoint 14 | { 15 | private readonly IBillbeeRestClient _restClient; 16 | 17 | internal CustomerEndPoint(IBillbeeRestClient restClient) 18 | { 19 | _restClient = restClient; 20 | } 21 | 22 | [ApiMapping("/api/v1/customers", HttpOperation.Get)] 23 | public ApiPagedResult> GetCustomerList(int page, int pageSize) 24 | { 25 | NameValueCollection parameters = new NameValueCollection(); 26 | parameters.Add("page", page.ToString()); 27 | parameters.Add("pageSize", pageSize.ToString()); 28 | 29 | return _restClient.Get>>($"/customers", parameters); 30 | } 31 | 32 | [ApiMapping("/api/v1/customers", HttpOperation.Post)] 33 | public ApiResult AddCustomer(CustomerForCreation customer) 34 | { 35 | return _restClient.Post>($"/customers", customer); 36 | } 37 | 38 | [ApiMapping("/api/v1/customers/{id}", HttpOperation.Get)] 39 | public ApiResult GetCustomer(long id) 40 | { 41 | return _restClient.Get>($"/customers/{id}"); 42 | } 43 | 44 | [ApiMapping("/api/v1/customers/{id}", HttpOperation.Put)] 45 | public ApiResult UpdateCustomer(Customer customer) 46 | { 47 | if (customer.Id == null) 48 | { 49 | throw new InvalidValueException("Id must not be null."); 50 | } 51 | return _restClient.Put>($"/customers/{customer.Id}", customer); 52 | 53 | } 54 | 55 | [ApiMapping("/api/v1/customers/{id}/orders", HttpOperation.Get)] 56 | public ApiPagedResult> GetOrdersForCustomer(long id, int page, int pageSize) 57 | { 58 | NameValueCollection parameters = new NameValueCollection(); 59 | parameters.Add("page", page.ToString()); 60 | parameters.Add("pageSize", pageSize.ToString()); 61 | return _restClient.Get>>($"/customers/{id}/orders", parameters); 62 | } 63 | 64 | [ApiMapping("/api/v1/customers/{id}/addresses", HttpOperation.Get)] 65 | public ApiPagedResult> GetAddressesForCustomer(long id, int page, int pageSize) 66 | { 67 | NameValueCollection parameters = new NameValueCollection(); 68 | parameters.Add("page", page.ToString()); 69 | parameters.Add("pageSize", pageSize.ToString()); 70 | return _restClient.Get>>($"/customers/{id}/addresses", parameters); 71 | } 72 | 73 | [ApiMapping("/api/v1/customers/{id}/addresses", HttpOperation.Post)] 74 | public ApiResult AddAddressToCustomer(CustomerAddress customerAddress) 75 | { 76 | return _restClient.Post>($"/customers/{customerAddress.CustomerId}/addresses", customerAddress); 77 | } 78 | 79 | [ApiMapping("/api/v1/customers/addresses/{id}", HttpOperation.Get)] 80 | public ApiResult GetCustomerAddress(long customerAddressId) 81 | { 82 | return _restClient.Get>($"/customers/addresses/{customerAddressId}"); 83 | } 84 | 85 | [ApiMapping("/api/v1/customers/addresses/{id}", HttpOperation.Put)] 86 | public ApiResult UpdateCustomerAddress(CustomerAddress customerAddress) 87 | { 88 | return _restClient.Put>($"/customers/addresses/{customerAddress.Id}", customerAddress); 89 | } 90 | 91 | [ApiMapping("/api/v1/customers/addresses/{id}", HttpOperation.Patch)] 92 | public ApiResult PatchCustomerAddress(long customerAddressId, Dictionary fieldsToPatch) 93 | { 94 | return _restClient.Patch>($"/customers/addresses/{customerAddressId}", null, fieldsToPatch); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/EnumEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Billbee.Api.Client.Endpoint.Interfaces; 3 | using Billbee.Api.Client.Model; 4 | 5 | namespace Billbee.Api.Client.EndPoint 6 | { 7 | public class EnumEndPoint : IEnumEndPoint 8 | { 9 | private readonly IBillbeeRestClient _restClient; 10 | 11 | internal EnumEndPoint(IBillbeeRestClient restClient) 12 | { 13 | _restClient = restClient; 14 | } 15 | 16 | [ApiMapping("/api/v1/enums/paymenttypes", HttpOperation.Get)] 17 | public List GetPaymentTypes() 18 | { 19 | return _restClient.Get>("/enums/paymenttypes"); 20 | } 21 | 22 | [ApiMapping("/api/v1/enums/shippingcarriers", HttpOperation.Get)] 23 | public List GetShippingCarriers() 24 | { 25 | return _restClient.Get>("/enums/shippingcarriers"); 26 | } 27 | 28 | [ApiMapping("/api/v1/enums/shipmenttypes", HttpOperation.Get)] 29 | public List GetShipmentTypes() 30 | { 31 | return _restClient.Get>("/enums/shipmenttypes"); 32 | } 33 | 34 | [ApiMapping("/api/v1/enums/orderstates", HttpOperation.Get)] 35 | public List GetOrderStates() 36 | { 37 | return _restClient.Get>("/enums/orderstates"); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/EventEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.Specialized; 4 | using Billbee.Api.Client.Endpoint.Interfaces; 5 | using Billbee.Api.Client.Enums; 6 | using Billbee.Api.Client.Model; 7 | 8 | namespace Billbee.Api.Client.EndPoint 9 | { 10 | /// 11 | public class EventEndPoint : IEventEndPoint 12 | { 13 | private readonly IBillbeeRestClient _restClient; 14 | 15 | internal EventEndPoint(IBillbeeRestClient restClient) 16 | { 17 | _restClient = restClient; 18 | } 19 | 20 | [ApiMapping("/api/v1/events", HttpOperation.Get)] 21 | public ApiPagedResult> GetEvents( 22 | DateTime? minDate = null, 23 | DateTime? maxDate = null, 24 | int page = 1, 25 | int pageSize = 50, 26 | List typeIds = null, 27 | long? orderId = null) 28 | { 29 | NameValueCollection parameters = new NameValueCollection(); 30 | 31 | if (minDate.HasValue) 32 | { 33 | parameters.Add("minDate", minDate.Value.ToString("yyyy-MM-dd HH:mm")); 34 | } 35 | 36 | if (maxDate.HasValue) 37 | { 38 | parameters.Add("maxDate", maxDate.Value.ToString("yyyy-MM-dd")); 39 | } 40 | 41 | parameters.Add("page", page.ToString()); 42 | parameters.Add("pageSize", pageSize.ToString()); 43 | 44 | 45 | if (orderId != null) 46 | { 47 | parameters.Add("orderId", orderId.ToString()); 48 | } 49 | 50 | int index = 0; 51 | if (typeIds != null) 52 | { 53 | foreach (var typeId in typeIds) 54 | { 55 | parameters.Add($"typeId[{index}]", ((int) typeId).ToString()); 56 | index++; 57 | } 58 | } 59 | 60 | return _restClient.Get>>("/events", parameters); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/Interfaces/IAutomaticProvisionEndPoint.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Model; 2 | 3 | namespace Billbee.Api.Client.Endpoint.Interfaces 4 | { 5 | /// 6 | /// EndPoint to access functions for auto provisioning 7 | /// 8 | public interface IAutomaticProvisionEndPoint 9 | { 10 | /// 11 | /// Creates a new user account in billbee 12 | /// 13 | /// The definition of the account, that shoule be created 14 | /// The password, user-id and one time loging url. 15 | ApiResult CreateAccount(Account createAccountContainer); 16 | 17 | /// 18 | /// Calls the terms and coditions of use for billbee 19 | /// 20 | /// The urls of all needed information. 21 | ApiResult TermsInfo(); 22 | } 23 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/Interfaces/ICloudStoragesEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Billbee.Api.Client.Model; 3 | 4 | namespace Billbee.Api.Client.Endpoint.Interfaces 5 | { 6 | /// 7 | /// EndPoint to access all cloud storage relevant methods. 8 | /// 9 | public interface ICloudStoragesEndPoint 10 | { 11 | /// 12 | /// Requests a list of all available cloud storages of the user 13 | /// 14 | /// List of cloud storages. 15 | ApiResult> GetCloudStorageList(); 16 | } 17 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/Interfaces/ICustomerAddressesEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Billbee.Api.Client.Model; 3 | 4 | namespace Billbee.Api.Client.Endpoint.Interfaces 5 | { 6 | /// 7 | /// Endpoint to access customer addresses 8 | /// 9 | public interface ICustomerAddressesEndPoint 10 | { 11 | /// 12 | /// Queries a list of customers addresses 13 | /// 14 | /// page number 15 | /// page size 16 | /// List of customers on the given page. 17 | ApiPagedResult> GetCustomerAddresses(int page, int pageSize); 18 | 19 | /// 20 | /// Gets a single customer address by its id 21 | /// customer address id 22 | /// 23 | ApiResult GetCustomerAddress(long customerAddressId); 24 | 25 | /// 26 | /// Creates a new customer address 27 | /// customer address model 28 | /// 29 | ApiResult AddCustomerAddress(CustomerAddress customerAddress); 30 | 31 | /// 32 | /// Updates a new customer address 33 | /// 34 | /// customer address model 35 | ApiResult UpdateCustomerAddress(CustomerAddress customerAddress); 36 | } 37 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/Interfaces/ICustomerEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Billbee.Api.Client.Model; 3 | 4 | namespace Billbee.Api.Client.Endpoint.Interfaces 5 | { 6 | /// 7 | /// Endpoint to access customer base data 8 | /// 9 | public interface ICustomerEndPoint 10 | { 11 | /// 12 | /// Queries a list of customers 13 | /// 14 | /// page number 15 | /// page size 16 | /// List of customers on the given page. 17 | ApiPagedResult> GetCustomerList(int page, int pageSize); 18 | 19 | /// 20 | /// Adds a new customer 21 | /// 22 | /// The customer object to add 23 | /// The customer object after adding to the account. 24 | ApiResult AddCustomer(CustomerForCreation customer); 25 | 26 | /// 27 | /// Queires the customer identified by the given id 28 | /// 29 | /// Id of the customer 30 | /// Customer object. 31 | ApiResult GetCustomer(long id); 32 | 33 | /// 34 | /// Updates a customer 35 | /// 36 | /// Updated customer object 37 | /// The customer object after update. 38 | ApiResult UpdateCustomer(Customer customer); 39 | 40 | /// 41 | /// Queries orders for a specific customer 42 | /// 43 | /// Id of the customer 44 | /// Page number 45 | /// Count of entries per page 46 | /// Resultset of the queried page of orders. 47 | ApiPagedResult> GetOrdersForCustomer(long id, int page, int pageSize); 48 | 49 | /// 50 | /// Queries addresses for a specific user 51 | /// 52 | /// Id of the customer 53 | /// Page number 54 | /// Count of entries per page 55 | /// Resultset of the queried page of addresses. 56 | ApiPagedResult> GetAddressesForCustomer(long id, int page, int pageSize); 57 | 58 | /// 59 | /// Create new address for a specific customer 60 | /// 61 | /// The new customerAddress 62 | /// The created customerAddress 63 | ApiResult AddAddressToCustomer(CustomerAddress customerAddress); 64 | 65 | /// 66 | /// Gets a specific customer addresses 67 | /// 68 | /// Id of the customer address 69 | /// The specific customer address 70 | ApiResult GetCustomerAddress(long customerAddressId); 71 | 72 | /// 73 | /// Updates all fields of an address 74 | /// 75 | /// The customer address 76 | /// The updated customer address 77 | ApiResult UpdateCustomerAddress(CustomerAddress customerAddress); 78 | 79 | /// 80 | /// Updates one or more fields of an address 81 | /// 82 | /// The id of the customer address to be updated 83 | /// /// Dictionary which uses the field name as key and the new value as value. 84 | /// The updated customer address 85 | ApiResult PatchCustomerAddress(long customerAddressId, Dictionary fieldsToPatch); 86 | } 87 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/Interfaces/IEnumEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Billbee.Api.Client.Model; 3 | 4 | namespace Billbee.Api.Client.Endpoint.Interfaces 5 | { 6 | public interface IEnumEndPoint 7 | { 8 | /// 9 | /// Gets a list of all payment types 10 | /// 11 | /// The list of all payment types 12 | List GetPaymentTypes(); 13 | 14 | /// 15 | /// Gets a list of all shipping carriers 16 | /// 17 | /// The list of all shipping carriers 18 | List GetShippingCarriers(); 19 | 20 | /// 21 | /// Gets a list of all shipment types 22 | /// 23 | /// The list of all shipment types 24 | List GetShipmentTypes(); 25 | 26 | /// 27 | /// Gets a list of all order states 28 | /// 29 | /// The list of all order states 30 | List GetOrderStates(); 31 | } 32 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/Interfaces/IEventEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Billbee.Api.Client.Enums; 4 | using Billbee.Api.Client.Model; 5 | 6 | namespace Billbee.Api.Client.Endpoint.Interfaces 7 | { 8 | /// 9 | /// EndPoint to access event related functions 10 | /// 11 | public interface IEventEndPoint 12 | { 13 | /// 14 | /// Calls a list of events for the selected account. 15 | /// 16 | /// Date to select only newer events 17 | /// Date to select only older events 18 | /// The page, selected 19 | /// The events per page 20 | /// Defines, which types if events should be listet 21 | /// If given, only events of this order will be supplied. 22 | /// List of the events, matching the search criteria. 23 | ApiPagedResult> GetEvents( 24 | DateTime? minDate = null, 25 | DateTime? maxDate = null, 26 | int page = 1, 27 | int pageSize = 50, 28 | List typeIds = null, 29 | long? orderId = null); 30 | } 31 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/Interfaces/ISearchEndPoint.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Model; 2 | 3 | namespace Billbee.Api.Client.Endpoint.Interfaces 4 | { 5 | /// 6 | /// Endpoint to search in orders, customers and products 7 | /// 8 | public interface ISearchEndPoint 9 | { 10 | /// 11 | /// Executes the given search 12 | /// 13 | /// search parameters 14 | /// The result of the search 15 | SearchResult SearchTerm(Search search); 16 | } 17 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/Interfaces/IShipmentEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Billbee.Api.Client.Model; 4 | using Billbee.Api.Client.Model.Rechnungsdruck.WebApp.Model.Api; 5 | 6 | namespace Billbee.Api.Client.Endpoint.Interfaces 7 | { 8 | /// 9 | /// EndPoint for generation of shipments 10 | /// 11 | public interface IShipmentEndPoint 12 | { 13 | /// 14 | /// Get a list of all shipments optionally filtered by date. 15 | /// 16 | /// Specifies the page to request. 17 | /// Specifies the pageSize. Defaults to 50, max value is 250 18 | /// Specifies the oldest shipment date to include in the response 19 | /// Specifies the newest shipment date to include in the response 20 | /// Get shipments for this order only. 21 | /// Get Shipments with a shipment greater or equal than this id. New shipments have a greater id than older shipments. 22 | /// Get Shippings for the specified shipping provider only. 23 | /// A list of shipments. 24 | ApiPagedResult> GetShipments(int page = 1, int pageSize = 50, DateTime? createdAtMin = null, 25 | DateTime? createdAtMax = null, long? orderId = null, long? minimumShipmentId = null, 26 | long? shippingProviderId = null); 27 | 28 | /// 29 | /// Requests a list of all available shipping providers and their products. 30 | /// 31 | /// List of shipping providers. 32 | List GetShippingProvider(); 33 | 34 | /// 35 | /// Creates a new shipment. 36 | /// 37 | /// The shipment specification, that should be created. 38 | /// The result of the shipment 39 | ApiResult PostShipment(PostShipment shipment); 40 | 41 | ApiResult ShipOrderWithLabel(ShipmentWithLabel shipmentRequest); 42 | 43 | /// 44 | /// Delivers a list of all registered shipping carriers 45 | /// 46 | /// List of available shipping carriers 47 | List GetShippingCarriers(); 48 | } 49 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/Interfaces/IWebhookEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Billbee.Api.Client.Model; 3 | 4 | namespace Billbee.Api.Client.Endpoint.Interfaces 5 | { 6 | /// 7 | /// Endpoint to register and deregister webhooks 8 | /// 9 | public interface IWebhookEndPoint 10 | { 11 | /// 12 | /// Deletes all existing WebHook registrations 13 | /// 14 | void DeleteAllWebhooks(); 15 | 16 | /// 17 | /// Deletes one webhook, identified by the given id. 18 | /// 19 | /// Id of the webhook to delete. 20 | void DeleteWebhook(string id); 21 | 22 | /// 23 | /// Gets all registered webhooks for this account 24 | /// 25 | /// List of all registered webhooks. 26 | List GetWebhooks(); 27 | 28 | /// 29 | /// Gets the webhook with the corresponding id 30 | /// 31 | /// id of the given webhook 32 | /// The webhook itself, if the given id could be found. 33 | Webhook GetWebhook(string id); 34 | 35 | /// 36 | /// Updates the information of a webhook 37 | /// 38 | /// The complete information of the hook, that should be updated. The webhook to update is identified by the Id parameter. 39 | void UpdateWebhook(Webhook webhook); 40 | 41 | /// 42 | /// Queries a list of all usable filters for webhook registration. 43 | /// 44 | /// Dictionary of all registered and usable filter. 45 | List GetFilters(); 46 | 47 | /// 48 | /// Registers a new webhook with the given information 49 | /// 50 | /// The details of the webhook to register. The property Id must be null. 51 | /// The registered webhook 52 | Webhook CreateWebhook(Webhook webhook); 53 | } 54 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/SearchEndPoint.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Model; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Billbee.Api.Client.Endpoint.Interfaces; 8 | 9 | namespace Billbee.Api.Client.EndPoint 10 | { 11 | /// 12 | public class SearchEndPoint : ISearchEndPoint 13 | { 14 | private readonly IBillbeeRestClient _restClient; 15 | 16 | internal SearchEndPoint(IBillbeeRestClient restClient) 17 | { 18 | _restClient = restClient; 19 | } 20 | 21 | [ApiMapping("/api/v1/search", HttpOperation.Post)] 22 | public SearchResult SearchTerm(Search search) 23 | { 24 | return _restClient.Post($"/search", search ); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/ShipmentEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.Specialized; 4 | using System.Net; 5 | using Billbee.Api.Client.Endpoint.Interfaces; 6 | using Billbee.Api.Client.Model; 7 | using Billbee.Api.Client.Model.Rechnungsdruck.WebApp.Model.Api; 8 | 9 | namespace Billbee.Api.Client.EndPoint 10 | { 11 | /// 12 | public class ShipmentEndPoint : IShipmentEndPoint 13 | { 14 | private readonly IBillbeeRestClient _restClient; 15 | 16 | internal ShipmentEndPoint(IBillbeeRestClient restClient) 17 | { 18 | _restClient = restClient; 19 | } 20 | 21 | [ApiMapping("/api/v1/shipment/shipments", HttpOperation.Get)] 22 | public ApiPagedResult> GetShipments(int page = 1, int pageSize = 50, DateTime? createdAtMin = null, DateTime? createdAtMax = null, long? orderId = null, long? minimumShipmentId = null, long? shippingProviderId = null) 23 | { 24 | NameValueCollection parameters = new NameValueCollection(); 25 | parameters.Add("page", page.ToString()); 26 | parameters.Add("pageSize", pageSize.ToString()); 27 | if (createdAtMin != null) 28 | { 29 | parameters.Add("createdAtMin", createdAtMin.Value.ToString("yyyy-MM-dd")); 30 | } 31 | if (createdAtMax != null) 32 | { 33 | parameters.Add("createdAtMax", createdAtMax.Value.ToString("yyyy-MM-dd")); 34 | } 35 | if (orderId != null) 36 | { 37 | parameters.Add("orderId", orderId.Value.ToString()); 38 | } 39 | if (minimumShipmentId != null) 40 | { 41 | parameters.Add("minimumShipmentId", minimumShipmentId.Value.ToString()); 42 | } 43 | if (shippingProviderId != null) 44 | { 45 | parameters.Add("shippingProviderId", shippingProviderId.Value.ToString()); 46 | } 47 | 48 | return _restClient.Get>>($"/shipment/shipments", parameters); 49 | } 50 | 51 | [ApiMapping("/api/v1/shipment/shippingproviders", HttpOperation.Get)] 52 | public List GetShippingProvider() 53 | { 54 | return _restClient.Get>("/shipment/shippingproviders"); 55 | } 56 | 57 | [ApiMapping("/api/v1/shipment/shipment", HttpOperation.Post)] 58 | public ApiResult PostShipment(PostShipment shipment) 59 | { 60 | return _restClient.Post>("/shipment/shipment", shipment); 61 | } 62 | 63 | [ApiMapping("/api/v1/shipment/shipwithlabel", HttpOperation.Post)] 64 | public ApiResult ShipOrderWithLabel(ShipmentWithLabel shipmentRequest) 65 | { 66 | return _restClient.Post>("/shipment/shipwithlabel", shipmentRequest); 67 | } 68 | 69 | [ApiMapping("/api/v1/shipment/shippingcarriers", HttpOperation.Get)] 70 | public List GetShippingCarriers() 71 | { 72 | return _restClient.Get>("/shipment/shippingcarriers"); 73 | } 74 | 75 | [ApiMapping("/api/v1/shipment/ping", HttpOperation.Get)] 76 | internal bool Ping() 77 | { 78 | var result = _restClient.Get("/shipment/ping"); 79 | switch (result) 80 | { 81 | case HttpStatusCode.OK: 82 | case HttpStatusCode.Accepted: 83 | case HttpStatusCode.Created: 84 | return true; 85 | default: 86 | return false; 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Endpoint/WebhookEndPoint.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Model; 2 | using System.Collections.Generic; 3 | using Billbee.Api.Client.Endpoint.Interfaces; 4 | 5 | namespace Billbee.Api.Client.EndPoint 6 | { 7 | /// 8 | public class WebhookEndPoint : IWebhookEndPoint 9 | { 10 | private readonly IBillbeeRestClient _restClient; 11 | 12 | internal WebhookEndPoint(IBillbeeRestClient restClient) 13 | { 14 | _restClient = restClient; 15 | } 16 | 17 | [ApiMapping("/api/v1/webhooks", HttpOperation.Delete)] 18 | public void DeleteAllWebhooks() 19 | { 20 | _restClient.Delete("/webhooks"); 21 | } 22 | 23 | [ApiMapping("/api/v1/webhooks/{id}", HttpOperation.Delete)] 24 | public void DeleteWebhook(string id) 25 | { 26 | if (string.IsNullOrWhiteSpace(id)) 27 | { 28 | throw new InvalidValueException($"Property Id was not set."); 29 | } 30 | 31 | _restClient.Delete($"/webhooks/{id}"); 32 | } 33 | 34 | [ApiMapping("/api/v1/webhooks", HttpOperation.Get)] 35 | public List GetWebhooks() 36 | { 37 | return _restClient.Get>("/webhooks"); 38 | } 39 | 40 | [ApiMapping("/api/v1/webhooks/{id}", HttpOperation.Get)] 41 | public Webhook GetWebhook(string id) 42 | { 43 | if (string.IsNullOrWhiteSpace(id)) 44 | { 45 | throw new InvalidValueException($"Property Id was not set."); 46 | } 47 | 48 | return _restClient.Get($"/webhooks/{id}"); 49 | } 50 | 51 | [ApiMapping("/api/v1/webhooks/{id}", HttpOperation.Put)] 52 | public void UpdateWebhook(Webhook webhook) 53 | { 54 | if (string.IsNullOrWhiteSpace(webhook.Id )) 55 | { 56 | throw new InvalidValueException($"Property Id was not set."); 57 | } 58 | 59 | _restClient.Put($"/webhooks/{webhook.Id}", webhook); 60 | } 61 | 62 | [ApiMapping("/api/v1/webhooks/filters", HttpOperation.Get)] 63 | public List GetFilters() 64 | { 65 | return _restClient.Get>("/webhooks/filters"); 66 | } 67 | 68 | [ApiMapping("/api/v1/webhooks", HttpOperation.Post)] 69 | public Webhook CreateWebhook(Webhook webhook) 70 | { 71 | if (webhook.Id != null) 72 | { 73 | throw new InvalidValueException($"Property Id was set to '{webhook.Id}', but it must be null."); 74 | } 75 | 76 | if ( string.IsNullOrWhiteSpace(webhook.Secret) || webhook.Secret.Length < 32 || webhook.Secret.Length > 64) 77 | { 78 | throw new InvalidValueException($"Property secret is malformed. It must meet the following criteria: Not null or whitespaces only, between 32 and 64 charackters long."); 79 | } 80 | 81 | return _restClient.Post("/webhooks", webhook); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Enums/ErrorHandlingEnum.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Enums 2 | { 3 | /// 4 | /// Defines how server side errors should be handled on client. 5 | /// 6 | public enum ErrorHandlingEnum 7 | { 8 | /// 9 | /// Throws an exception, if a server side error occurs while processing a request 10 | /// 11 | ThrowException, 12 | 13 | /// 14 | /// Returns an object, that contains further error information, if a server error occurs while processing a request 15 | /// 16 | ReturnErrorContent 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Enums/EventTypeEnum.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Enums 2 | { 3 | /// 4 | /// Possible event types 5 | /// 6 | public enum EventTypeEnum 7 | { 8 | OrderImported, 9 | BillPrinted, 10 | LabelPrinted, 11 | AccountCreated, 12 | AccountDeleted, 13 | OrderDeleted, 14 | OrderDetailDeleted, 15 | OrderDetailAdded, 16 | AccountSynced, 17 | OrderStateSynced, 18 | OrderExported, 19 | DeliveryNotePrinted, 20 | OrderShipped, 21 | OrderPaid, 22 | UserAssignedToOrder, 23 | OrderStateChanged, 24 | CustomersJoined, 25 | EMailChanged, 26 | ShipmentCreated, 27 | OrderCommitPrinted, 28 | OrderForwarded, 29 | AccountSyncError, 30 | CustomerInvoiceDownload, 31 | CustomerNotified, 32 | OrderCanceled, 33 | ShipmentStatus, 34 | CustomerFileDownload, 35 | PaymentImported, 36 | RuleExecuted, 37 | CreatedByApi, 38 | OfferPrinted, 39 | EmailSent, 40 | EmailFailed, 41 | OrderForwardFailed, 42 | OrderDataForwardFailed, 43 | SendFileToCloudDeviceFailed, 44 | LogIn, 45 | LogOut, 46 | BookService, 47 | CancelService, 48 | Impersonated, 49 | StockSynced, 50 | StockSyncFailed, 51 | UploadedFile, 52 | PaymentBatchRead, 53 | PaymentBatchFailed, 54 | UserAcountPayDetailsChanged, 55 | Translate, 56 | ProductUploaded, 57 | OrderExportedToBookkeeping, 58 | OrderExportToBookkeepingFailed, 59 | PaymentExportedToBookkeeping, 60 | PaymentExportToBookkeepingFailed, 61 | AccountPaymentTypeChanged, 62 | AccountTestPhaseChanged, 63 | ApiUsage, 64 | ProductUploadFailed, 65 | RecalculatedStockMin, 66 | RecalculatedStockDesired, 67 | ShipmentFailed, 68 | CustomerFileDownloadDaWanda, 69 | OrderDetailModified, 70 | OrderModified, 71 | OrderStateTransfered, 72 | OrderStateTransferFailed, 73 | PaymentCreated 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Enums/OrderStateEnum.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Enums 2 | { 3 | public enum OrderStateEnum 4 | { 5 | /// 6 | /// Ordered 7 | /// 8 | Bestellt = 1, 9 | 10 | /// 11 | /// Confirmed 12 | /// 13 | Bestaetigt = 2, 14 | 15 | /// 16 | /// Payment Received 17 | /// 18 | Zahlung_erhalten = 3, 19 | 20 | /// 21 | /// sent 22 | /// 23 | Versendet = 4, 24 | 25 | /// 26 | /// complaints 27 | /// 28 | Reklamation = 5, 29 | 30 | /// 31 | /// deleted 32 | /// 33 | Geloescht = 6, 34 | 35 | /// 36 | /// completed 37 | /// 38 | Abgeschlossen = 7, 39 | 40 | /// 41 | /// cancelled 42 | /// 43 | Storniert = 8, 44 | 45 | /// 46 | /// archived 47 | /// 48 | Archiviert = 9, 49 | 50 | /// 51 | /// rated 52 | /// 53 | Rated = 10, 54 | 55 | /// 56 | /// warning 57 | /// 58 | Mahnung = 11, 59 | 60 | /// 61 | /// warning2 62 | /// 63 | Mahnung2 = 12, 64 | 65 | /// 66 | /// packed 67 | /// 68 | Gepackt = 13, 69 | 70 | /// 71 | /// Offered 72 | /// 73 | Angeboten = 14, 74 | 75 | /// 76 | /// reminder 77 | /// 78 | Zahlungserinnerung = 15, 79 | 80 | /// 81 | /// In sending process 82 | /// 83 | Im_Fulfillment = 16 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Enums/PaymentTypeEnum.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Enums 2 | { 3 | public enum PaymentTypeEnum 4 | { 5 | Bankueberweisung = 1, 6 | Nachnahme = 2, 7 | PayPal = 3, 8 | Barzahlung = 4, 9 | Gutschein = 6, 10 | Sofortüberweisung = 19, 11 | /// 12 | /// etsy 13 | /// 14 | MoneyOrder = 20, // etsy 15 | /// 16 | /// etsy ck 17 | /// 18 | Check = 21, // etsy ck 19 | Andere = 22, 20 | Lastschrift = 23, 21 | Moneybookers = 24, 22 | KLARNA_Invoice = 25, 23 | Rechnung = 26, 24 | Moneybookers_Kreditkarte = 27, 25 | Moneybookers_Lastschrift = 28, 26 | BILLPAY_Rechnung = 29, 27 | BILLPAY_Lastschrift = 30, 28 | Kreditkarte = 31, 29 | Maestro = 32, 30 | iDEAL = 33, 31 | EPS = 34, 32 | P24 = 35, 33 | ClickAndBuy = 36, 34 | GiroPay = 37, 35 | Novalnet_Lastschrift = 38, 36 | KLARNA_PartPayment = 39, 37 | iPayment_CC = 40, 38 | Billsafe = 41, 39 | Testbestellung = 42, 40 | WireCard_Kreditkarte = 43, 41 | AmazonPayments = 44, 42 | Secupay_Kreditkarte = 45, 43 | Secupay_Lastschrift = 46, 44 | WireCard_Lastschrift = 47, 45 | EC = 48, 46 | Paymill_Kreditkarte = 49, 47 | Novalnet_Kreditkarte = 50, 48 | Novalnet_Rechnung = 51, 49 | Novalnet_PayPal = 52, 50 | Paymill = 53, 51 | Rechnung_PayPal = 54, 52 | Selekkt = 55, 53 | Avocadostore = 56, 54 | DirectCheckout = 57, 55 | Rakuten = 58, 56 | Vorkasse = 59, 57 | Kommissionsabrechnung = 60, 58 | Amazon_Marketplace = 61, 59 | Amazon_Payments_Advanced = 62, 60 | Stripe = 63, 61 | BILLPAY_PayLater = 64, 62 | PostFinance = 65, 63 | iZettle = 66, 64 | SumUp = 67, 65 | payleven = 68, 66 | atalanda = 69, 67 | Saferpay_Kreditkarte = 70, 68 | WireCard_PayPal = 71, 69 | Micropayment = 72, 70 | Ratenkauf = 73, 71 | Wayfair = 74, // baranski 72 | MangoPay_PayPal = 75, 73 | MangoPay_Sofortueberweisung = 76, 74 | MangoPay_Kreditkarte = 77, 75 | MangoPay_iDeal = 78, 76 | PayPal_Express = 79, 77 | PayPal_Lastschrift = 80, 78 | PayPal_Kreditkarte = 81, 79 | Wish = 82, 80 | Bancontact_Mister_Cash = 83, 81 | Belfius_Direct_Net = 84, 82 | KBC_CBC_Betaalknop = 85, 83 | Novalnet_Przelewy24 = 86, 84 | Novalnet_Vorkasse = 87, 85 | Novalnet_Instantbank = 88, 86 | Novalnet_IDEAL = 89, 87 | Novalnet_EPS = 90, 88 | Novalnet_GiroPay = 91, 89 | Novalnet_Barzahlen = 92, 90 | Real = 93, 91 | Fruugo = 94, 92 | Cdiscount = 95, 93 | PayDirekt = 96, 94 | EtsyPayments = 97, 95 | KLARNA = 98, 96 | limango = 99, 97 | SantanderRatenkauf = 100, 98 | SantanderRechnungskauf = 101, 99 | Cashpresso = 102, 100 | Tipser = 103, 101 | Ebay = 104, 102 | Mollie = 105, 103 | MollieInvoice = 106, 104 | MollieCreditCard = 107, 105 | MollieSofort = 108, 106 | MollieGiroPay = 109, 107 | MollieMaestro = 110, 108 | MollieKlarnaPayLater = 111, 109 | MolliePayPal = 112, 110 | ApplePay = 113, 111 | Braintree = 114, 112 | BraintreeCreditCard = 115, 113 | BraintreePayPal = 116, 114 | MollieIdeal = 117, 115 | Scalapay = 118, 116 | OttoPayments = 119, 117 | IdealoDirektkaufPayments = 120, 118 | EasyCredit = 121, 119 | MollieApplePay = 122, 120 | MollieEPS = 123, 121 | CrefoPayPrepaid = 124, 122 | MollieBancontact = 125, 123 | MolliePrzelewy24 = 126, 124 | MollieKlarnaRatenkauf = 127, 125 | MollieKlarnaSliceit = 128, 126 | GooglePay = 129, 127 | MollieKlarnaPayNow = 130, 128 | MultiSafepay = 131, 129 | Ratepay_Rechnung = 132, 130 | HoodPay = 133, 131 | Quickpay = 134, 132 | PayPal_PayLater = 135, 133 | Kaufland = 136, 134 | MollieBankUeberweisung = 137, 135 | Lena = 138 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Enums/ProductIdType.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Enums 2 | { 3 | public enum ProductIdType 4 | { 5 | id, 6 | sku, 7 | ean 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Enums/ReportTemplates.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Enums 2 | { 3 | public enum ReportTemplates 4 | { 5 | Invoice, 6 | Label, 7 | DeliveryNote, 8 | OrderCommit, 9 | Offer, 10 | CancellationInvoice 11 | } 12 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Enums/ShipmentTypeEnum.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Enums 2 | { 3 | public enum ShipmentTypeEnum 4 | { 5 | Shipment, 6 | Retoure 7 | } 8 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Enums/ShippingCarrierEnum.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Enums 2 | { 3 | public enum ShippingCarrierEnum 4 | { 5 | other, 6 | dhlExpress, 7 | dhl, 8 | hermes, 9 | dpd, 10 | ups, 11 | gls, 12 | dpag, 13 | OePost, 14 | fedex, 15 | generalOvernight, 16 | tnt, 17 | liefery, 18 | iloxx, 19 | parcel_one, 20 | cargo_international, 21 | pin_mail, 22 | usPostalService, 23 | amazon_logistics, 24 | } 25 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Enums/VatModeEnum.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Enums 2 | { 3 | public enum VatModeEnum : byte 4 | { 5 | DisplayVat = 0, 6 | NoVatKleinunternehmer = 1, 7 | NoVatInnergemeinschaftlicheLieferung = 2, 8 | NoVatAusfuhrDrittland = 3, 9 | NoVatDifferenzbesteuerung = 4, 10 | LastEnumEntry = 5 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Billbee.Api.Client/IApiClient.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.EndPoint; 2 | using Billbee.Api.Client.Endpoint.Interfaces; 3 | 4 | namespace Billbee.Api.Client 5 | { 6 | /// 7 | /// Client for the Billbee API 8 | /// see https://app.billbee.io/swagger/ui/index or https://www.billbee.de/api/ for further information 9 | /// 10 | public interface IApiClient 11 | { 12 | /// 13 | /// Configuration, used to connect to the API . 14 | /// 15 | ApiConfiguration Configuration { get; } 16 | 17 | /// 18 | /// EndPoint to access events 19 | /// 20 | IEventEndPoint Events { get; } 21 | 22 | /// 23 | /// EndPoint to access order independent shipments 24 | /// 25 | IShipmentEndPoint Shipment { get; } 26 | 27 | /// 28 | /// EndPoint to access webhooks 29 | /// 30 | IWebhookEndPoint Webhooks { get; } 31 | 32 | /// 33 | /// EndPoint to access Products 34 | /// 35 | IProductEndPoint Products { get; } 36 | 37 | /// 38 | /// EndPoint to allow automatic user creation 39 | /// 40 | IAutomaticProvisionEndPoint AutomaticProvision { get; } 41 | 42 | /// 43 | /// EndPoint to access customer base data 44 | /// 45 | ICustomerEndPoint Customer { get; } 46 | 47 | /// 48 | /// EndPoint to access customer addresses 49 | /// 50 | ICustomerAddressesEndPoint CustomerAddresses { get; } 51 | 52 | /// 53 | /// EndPoint for searches in customers, orders and products 54 | /// 55 | ISearchEndPoint Search { get; } 56 | 57 | /// 58 | /// EndPoint to access orders 59 | /// 60 | IOrderEndPoint Orders { get; } 61 | 62 | /// 63 | /// EndPoint to access cloud storages 64 | /// 65 | ICloudStoragesEndPoint CloudStorages { get; } 66 | 67 | /// 68 | /// EndPoint to access enum values 69 | /// 70 | IEnumEndPoint Enums { get; } 71 | 72 | /// 73 | /// Validates, that access to the api is possible with the given configuration 74 | /// 75 | /// 76 | bool TestConfiguration(); 77 | } 78 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/IBillbeeRestClient.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.Specialized; 3 | using System.Net; 4 | using System.Threading.Tasks; 5 | using RestSharp; 6 | 7 | namespace Billbee.Api.Client 8 | { 9 | public class FileParam 10 | { 11 | public string Name { get; set; } 12 | public string FileName { get; set; } 13 | public byte[] Data { get; set; } 14 | public string ContentType { get; set; } 15 | } 16 | 17 | public interface IBillbeeRestClient 18 | { 19 | // get 20 | HttpStatusCode Get(string resource); 21 | T Get( 22 | string resource, 23 | NameValueCollection parameter = null) where T : new(); 24 | 25 | // put 26 | string Put(string resource, NameValueCollection parameter = null); 27 | string Put(string resource, dynamic data, NameValueCollection parameter = null); 28 | T Put(string resource, NameValueCollection parameter = null) where T : new(); 29 | T Put(string resource, dynamic data, NameValueCollection parameter = null) where T : new(); 30 | Task PutAsync(string resource, NameValueCollection parameter = null); 31 | Task PutAsync(string resource, dynamic data); 32 | Task PutAsync(string resource, dynamic data) where T : new(); 33 | 34 | // patch 35 | string Patch(string resource, NameValueCollection parameter = null, dynamic data = null); 36 | T Patch(string resource, NameValueCollection parameter = null, dynamic data = null) where T : new(); 37 | 38 | // post 39 | Task PostAsync( 40 | string resource, 41 | NameValueCollection parameter = null, 42 | List files = null, 43 | ParameterType paramType = ParameterType.QueryString, 44 | string acceptHeaderValue = "application/json"); 45 | Task PostAsync(string resource, dynamic data); 46 | Task PostAsync( 47 | string resource, 48 | dynamic data, 49 | NameValueCollection parameter = null, 50 | ParameterType paramType = ParameterType.QueryString) where T : new(); 51 | T Post( 52 | string resource, 53 | NameValueCollection parameter = null, 54 | List files = null, 55 | ParameterType paramType = ParameterType.QueryString); 56 | string Post(string resource, dynamic data); 57 | T Post(string resource, dynamic data, NameValueCollection parameters = null) where T : new(); 58 | 59 | // delete 60 | void Delete( 61 | string resource, 62 | NameValueCollection parameter = null, 63 | ParameterType paramType = ParameterType.QueryString); 64 | } 65 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/ILogger.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client 2 | { 3 | public enum LogSeverity 4 | { 5 | Info, 6 | Warning, 7 | Error 8 | } 9 | 10 | public interface ILogger 11 | { 12 | void LogMsg(string message, LogSeverity severity); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Billbee.Api.Client/InvalidValueException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client 8 | { 9 | /// 10 | /// Exception thrown, when an parametervalue was not correct or malformed. 11 | /// 12 | public class InvalidValueException: Exception 13 | { 14 | public InvalidValueException(string message): base(message) 15 | { 16 | 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Account.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Enums; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | /// 6 | /// Accountinformation for creation of a new account 7 | /// 8 | public class Account 9 | { 10 | public override string ToString() 11 | { 12 | return $"EMail {EMail} Name {Address?.Name} Country {Address?.Country} Terms {AcceptTerms}"; 13 | } 14 | 15 | /// 16 | /// The Email address of the user to create 17 | /// 18 | public string EMail { get; set; } 19 | 20 | public string Password { get; set; } 21 | 22 | /// 23 | /// Set to true, if the user has accepted the Billbee terms & conditions 24 | /// 25 | public bool AcceptTerms { get; set; } 26 | 27 | /// 28 | /// Represents the invoice address of a Billbee user 29 | /// 30 | public class UserAddress 31 | { 32 | public string Company { get; set; } 33 | public string Name { get; set; } 34 | public string Address1 { get; set; } 35 | public string Address2 { get; set; } 36 | public string Zip { get; set; } 37 | public string City { get; set; } 38 | 39 | /// 40 | /// The ISO2 country code of the users country 41 | /// 42 | public string Country { get; set; } 43 | 44 | public string VatId { get; set; } 45 | } 46 | 47 | /// 48 | /// Gets or sets the invoice address of the Billbee user 49 | /// 50 | public UserAddress Address { get; set; } 51 | 52 | /// 53 | /// Gets or sets if the user is interested in the Billbee newsletter 54 | /// 55 | public bool Newsletter { get; set; } 56 | 57 | /// 58 | /// Specifies an billbee affiliate code to attach to the user 59 | /// 60 | public string AffiliateCouponCode { get; set; } 61 | 62 | /// 63 | /// Optionally specify the vat1 (normal) rate of the user 64 | /// 65 | public decimal? Vat1Rate { get; set; } 66 | 67 | /// 68 | /// Optionally specify the vat2 (reduced) rate of the user 69 | /// 70 | public decimal? Vat2Rate { get; set; } 71 | 72 | /// 73 | /// Optionally specify the default vat mode of the user 74 | /// 75 | /// 0: Show vat, 1: Kleinunternehmer 76 | public VatModeEnum? DefaultVatMode { get; set; } 77 | 78 | /// 79 | /// Optionally specify the default currency of the user 80 | /// 81 | public string DefaultCurrrency { get; set; } 82 | 83 | /// 84 | /// Optionally specify the default vat index of the user 85 | /// 86 | /// 1: normal vat, 2: reduced vat 87 | public byte? DefaultVatIndex { get; set; } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Address.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | /// 4 | /// Basic address for usage in orders 5 | /// 6 | public class Address 7 | { 8 | /// 9 | /// Internal id of this address 10 | /// 11 | public long BillbeeId { get; set; } 12 | 13 | public string City { get; set; } 14 | public string Street { get; set; } 15 | public string Company { get; set; } 16 | public string Line2 { get; set; } 17 | public string Zip { get; set; } 18 | public string State { get; set; } 19 | 20 | /// 21 | /// Name of the country 22 | /// 23 | public string Country { get; set; } 24 | 25 | /// 26 | /// The ISO 2 code of the country 27 | /// 28 | public string CountryISO2 { get; set; } 29 | 30 | public string FirstName { get; set; } 31 | public string LastName { get; set; } 32 | 33 | /// 34 | /// Phone number of an addressee, used for notification purposes. 35 | /// 36 | public string Phone { get; set; } 37 | 38 | /// 39 | /// E-mail address of an addressee, used for notification purposes. 40 | /// 41 | public string Email { get; set; } 42 | 43 | public string HouseNumber { get; set; } 44 | 45 | public string NameAddition { get; set; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ApiResult.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | /// 4 | /// Single entry result set for api requests 5 | /// 6 | /// Type of content as part of the result 7 | public class ApiResult 8 | { 9 | public enum ErrorCodeEnum 10 | { 11 | NoError = 0, 12 | ApiNotActivated, 13 | OrderNotFound, 14 | InvoiceNotCreated, 15 | CantCreateInvoice, 16 | OrderCanceled, 17 | OrderDeleted, 18 | OrderNotPaid, 19 | InternalError, 20 | OrderExists, 21 | WrongShopId, 22 | InvalidData, 23 | CreateUser_DuplicateEmail, 24 | CreateUser_InvalidEmail, 25 | CreateUser_UserRejected, 26 | CreateUser_TermsNotAccepted, 27 | NoPaidAccount, 28 | APIServiceNotBooked, 29 | CantCreateDeliveryNote 30 | } 31 | 32 | /// 33 | /// Shows, if a request was successful or not. 34 | /// 35 | public bool Success => string.IsNullOrWhiteSpace(ErrorMessage) && ErrorCode == ErrorCodeEnum.NoError; 36 | 37 | /// 38 | /// If a request failed, a detailed message can be found here. 39 | /// 40 | public string ErrorMessage { get; set; } 41 | 42 | /// 43 | /// If a request failed, the failure cause can be found here < 44 | /// 45 | public ErrorCodeEnum ErrorCode { get; set; } 46 | 47 | /// 48 | /// Response content to a request. 49 | /// 50 | public T Data { get; set; } 51 | } 52 | 53 | /// 54 | /// Multi entry result set for api requests, with paging behaviour 55 | /// 56 | /// Type of content as part of the result typically of type IEnumerable. 57 | public class ApiPagedResult : ApiResult 58 | { 59 | /// 60 | /// Information about the paging 61 | /// 62 | public class PagingInformation 63 | { 64 | /// 65 | /// Currently delivered page 66 | /// 67 | public int Page { get; set; } 68 | 69 | /// 70 | /// Total count of pages available with the given 71 | /// 72 | public int TotalPages { get; set; } 73 | 74 | /// 75 | /// Total count of available datasets. 76 | /// 77 | public int TotalRows { get; set; } 78 | 79 | /// 80 | /// Defines how many entries each page shoul contain 81 | /// 82 | public int PageSize { get; set; } 83 | } 84 | 85 | /// 86 | /// Shows the relation of the delivered content in terms of content paging. 87 | /// 88 | public PagingInformation Paging { get; set; } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ArticleCategory.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | /// 4 | /// Information about a category of an article 5 | /// 6 | public class ArticleCategory 7 | { 8 | /// 9 | /// The name of the category 10 | /// 11 | public string Name { get; set; } 12 | 13 | /// 14 | /// The internal id of the category 15 | /// 16 | public long? Id { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ArticleCustomFieldDefinition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public enum ApiArticleCustomFieldType 10 | { 11 | TextField, 12 | Textarea, 13 | NumberInput, 14 | SelectInput, 15 | } 16 | 17 | public class ArticleCustomFieldDefinition 18 | { 19 | public long? Id; 20 | 21 | public string Name; 22 | 23 | public object Configuration; 24 | 25 | public ApiArticleCustomFieldType? Type; 26 | 27 | public bool IsNullable; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ArticleImage.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | /// 4 | /// Image information for an article image 5 | /// 6 | public class ArticleImage 7 | { 8 | /// 9 | /// The url, this image is located 10 | /// 11 | public string Url { get; set; } 12 | 13 | /// 14 | /// The id of this image 15 | /// 16 | public long Id { get; set; } 17 | 18 | /// 19 | /// Path of external thumbnail, will be ignored, if posting to billbee. 20 | /// 21 | public string ThumbPathExt { get; set; } 22 | 23 | /// 24 | /// Url of the thumbail, will be ignored, if posting to billbee. 25 | /// 26 | public string ThumbUrl { get; set; } 27 | 28 | /// 29 | /// If more than one image is given, the position defines the order. 30 | /// 31 | public byte? Position { get; set; } 32 | 33 | /// 34 | /// Defines, wether this is default image, or not. 35 | /// 36 | public bool? IsDefault { get; set; } 37 | 38 | /// 39 | /// The id of the article, this image belongs to. 40 | /// 41 | public long ArticleId { get; set; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ArticleSource.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | /// 6 | /// Defines the sources in external systems, to which this article is attached to 7 | /// 8 | public class ArticleSource 9 | { 10 | /// 11 | /// Name of the source 12 | /// 13 | public string Source { get; set; } 14 | 15 | /// 16 | /// The id on the source 17 | /// 18 | public string SourceId { get; set; } 19 | 20 | /// 21 | /// The internal id of this article source definition 22 | /// 23 | public long Id { get; set; } 24 | 25 | /// 26 | /// Name of the api account, this source belongs to 27 | /// 28 | public string ApiAccountName { get; set; } 29 | 30 | /// 31 | /// Id of the api account, this source belongs to 32 | /// 33 | public long? ApiAccountId { get; set; } 34 | 35 | public decimal? ExportFactor { get; set; } 36 | 37 | public bool? StockSyncInactive { get; set; } 38 | public decimal? StockSyncMin { get; set; } 39 | public decimal? StockSyncMax { get; set; } 40 | public decimal? UnitsPerItem { get; set; } 41 | 42 | public JObject Custom { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/AtticleCustomFieldValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class AtticleCustomFieldValue 10 | { 11 | public long? Id; 12 | 13 | public long? DefinitionId; 14 | 15 | public ArticleCustomFieldDefinition Definition; 16 | 17 | public long? ArticleId; 18 | 19 | public object Value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/CloudStorage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class CloudStorage 10 | { 11 | public long Id { get; set; } 12 | public string Name { get; set; } 13 | public string Type { get; set; } 14 | public bool UsedAsPrinter { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Comment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | /// 6 | /// Comment for usage with orders 7 | /// 8 | public class Comment 9 | { 10 | /// 11 | /// If true, this comment was send from the customer, otherwise it was send from the shop owner 12 | /// 13 | public bool FromCustomer { get; set; } 14 | 15 | /// 16 | /// The comment itself 17 | /// 18 | public string Text { get; set; } 19 | 20 | /// 21 | /// The name of the sender 22 | /// 23 | public string Name { get; set; } 24 | 25 | /// 26 | /// The date, when this commment was published 27 | /// 28 | public DateTime Created { get; set; } 29 | 30 | /// 31 | /// The internal id of this comment 32 | /// 33 | public long Id { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/CreateUserResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | /// 6 | /// Result of a create user request 7 | /// 8 | public class CreateUserResult 9 | { 10 | /// 11 | /// Password, that was given for the user. This can't be recovered afterwards. 12 | /// 13 | public string Password { get; set; } 14 | 15 | /// 16 | /// Internal id this user was given 17 | /// 18 | public Guid UserId { get; set; } 19 | 20 | /// 21 | /// Url to allow the user an one time login, without password 22 | /// 23 | public string OneTimeLoginUrl { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/CurrentStock.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | /// 4 | /// Information abaout the current stock of an article 5 | /// 6 | public class CurrentStockInfo 7 | { 8 | /// 9 | /// SKU of the article 10 | /// 11 | public string SKU { get; set; } 12 | 13 | /// 14 | /// Amount, that is currently available from the stock. 15 | /// 16 | public decimal? CurrentStock { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class Customer 10 | { 11 | public long? Id { get; set; } 12 | public string Name { get; set; } 13 | public string Email { get; set; } 14 | public string Tel1 { get; set; } 15 | public string Tel2 { get; set; } 16 | public int? Number { get; set; } 17 | public long? PriceGroupId { get; set; } 18 | public int? LanguageId { get; set; } 19 | public string VatId { get; set; } 20 | 21 | /// 22 | /// If set, the type of the customer can be set. 0 = Endcustomer, 1 = Businesscustomer 23 | /// 24 | public byte? Type { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/CustomerAddress.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class CustomerAddress 4 | { 5 | public long? Id { get; set; } 6 | /// 7 | /// 1 = Invoiceaddress 8 | /// 2 = Shippingaddress 9 | /// 10 | public int AddressType { get; set; } 11 | public long? CustomerId { get; set; } 12 | public string Company { get; set; } 13 | public string FirstName { get; set; } 14 | public string LastName { get; set; } 15 | public string Name2 { get; set; } 16 | public string Street { get; set; } 17 | public string Housenumber { get; set; } 18 | public string Zip { get; set; } 19 | public string City { get; set; } 20 | public string State { get; set; } 21 | public string CountryCode { get; set; } 22 | public string Email { get; set; } 23 | public string Tel1 { get; set; } 24 | public string Tel2 { get; set; } 25 | public string Fax { get; set; } 26 | public string FullAddr { get; } 27 | public string AddressAddition { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/CustomerForCreation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class CustomerForCreation : Customer 10 | { 11 | public CustomerAddress Address { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/CustomerSearchResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class CustomerSearchResult 10 | { 11 | public long Id { get; set; } 12 | public string Name { get; set; } 13 | public string Addresses { get; set; } 14 | public string Number { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/DeletedImages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class DeletedImages 10 | { 11 | public List Deleted { get; set; } 12 | public List NotFound { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/DeliveryNote.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | /// 6 | /// Contains information of a delivery note. 7 | /// 8 | public class DeliveryNote 9 | { 10 | /// 11 | /// User specific number of the order, that is used for this delivery note 12 | /// 13 | public string OrderNumber { get; set; } 14 | 15 | /// 16 | /// Number of this delivery note 17 | /// 18 | public string DeliveryNoteNumber { get; set; } 19 | 20 | /// 21 | /// If requested, this field contains the delivery note as PDF file 22 | /// 23 | public byte[] PDFData { get; set; } 24 | 25 | /// 26 | /// Date, on which the delivery note was issued 27 | /// 28 | public DateTime? DeliveryNoteDate { get; set; } 29 | 30 | /// 31 | /// Url to donwload the delivery note, when not self contained inside < 32 | /// 33 | public string PdfDownloadUrl { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/EnumEntry.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class EnumEntry 4 | { 5 | public int Id { get; set; } 6 | public string Name { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Event.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | public class Event 6 | { 7 | /// 8 | /// Timestamp, when the even was created 9 | /// 10 | public DateTime Created { get; set; } 11 | 12 | /// 13 | /// Id of the event type 14 | /// 15 | public int TypeId { get; set; } 16 | 17 | /// 18 | /// Readable text representation of event type 19 | /// 20 | public string TypeText { get; set; } 21 | 22 | /// 23 | /// Internal id of this event 24 | /// 25 | public long Id { get; set; } 26 | 27 | /// 28 | /// Internal id of the employee, that initiated this event, if applicable 29 | /// 30 | public long? EmployeeId { get; set; } 31 | 32 | /// 33 | /// Name of the employee, that initiated this event, if applicable 34 | /// 35 | public string EmployeeName { get; set; } 36 | 37 | /// 38 | /// Internal id of the order, this event is based on, if applicable 39 | /// 40 | public long? OrderId { get; set; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/GetReservedAmountResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class GetReservedAmountResult 10 | { 11 | /// 12 | /// The reserve (not fulfilled) qty of the article 13 | /// 14 | public decimal ReservedAmount { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Invoice.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | /// 6 | /// Short hand information for an invoice, including the invoice as PDF- Document. 7 | /// 8 | public class Invoice 9 | { 10 | /// 11 | /// The number of the corresponding order 12 | /// 13 | public string OrderNumber { get; set; } 14 | 15 | /// 16 | /// Number that is printed as invoice number on the invoice 17 | /// 18 | public string InvoiceNumber { get; set; } 19 | 20 | /// 21 | /// Contains the PDF representation of the invoice, if it was requested. 22 | /// 23 | public byte[] PDFData { get; set; } 24 | 25 | /// 26 | /// Date of the invoice 27 | /// 28 | public DateTime? InvoiceDate { get; set; } 29 | 30 | /// 31 | /// Total gross value of this invoice 32 | /// 33 | public decimal TotalGross { get; set; } 34 | 35 | /// 36 | /// Total net value of this invoice 37 | /// 38 | public decimal TotalNet { get; set; } 39 | 40 | /// 41 | /// If the pdf file was not attached as byte[], it can be downloaded from this url 42 | /// 43 | public string PdfDownloadUrl { get; set; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/InvoiceDetail.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Billbee.Api.Client.Enums; 4 | 5 | namespace Billbee.Api.Client.Model 6 | { 7 | /// 8 | /// Detail information for an invoice 9 | /// 10 | public class InvoiceDetail 11 | { 12 | /// 13 | /// Number that is printed as invoice number on the invoice 14 | /// 15 | public string InvoiceNumber { get; set; } 16 | 17 | /// 18 | /// Defines, wether this is an invoice or a creditnote 19 | /// 20 | public string Type { get; set; } 21 | 22 | /// 23 | /// Invoice address last name 24 | /// 25 | public string LastName { get; set; } 26 | 27 | /// 28 | /// Invoice address first name 29 | /// 30 | public string FirstName { get; set; } 31 | 32 | /// 33 | /// Invoice address company 34 | /// 35 | public string Company { get; set; } 36 | 37 | /// 38 | /// Customer number of the addressed customer 39 | /// 40 | public int CustomerNumber { get; set; } 41 | 42 | /// 43 | /// If applicable, the debtor number of the customer 44 | /// 45 | public int DebtorNumber { get; set; } 46 | 47 | /// 48 | /// Date of the invoice 49 | /// 50 | public DateTime InvoiceDate { get; set; } 51 | 52 | /// 53 | /// Total net value of this invoice 54 | /// 55 | public decimal TotalNet { get; set; } 56 | 57 | /// 58 | /// Definition of the currency this invoice ist based upon 59 | /// 60 | public string Currency { get; set; } 61 | 62 | /// 63 | /// Total gross value of this invoice 64 | /// 65 | public decimal TotalGross { get; set; } 66 | 67 | /// 68 | /// Type id of payment, the order was or is planned to be payed 69 | /// 70 | public byte? PaymentTypeId { get; set; } 71 | 72 | /// 73 | /// The number of the corresponding order 74 | /// 75 | public string OrderNumber { get; set; } 76 | 77 | /// 78 | /// If applicable, the id of the payment transaction 79 | /// 80 | public string TransactionId { get; set; } 81 | 82 | /// 83 | /// Contact e-mail address of the customer 84 | /// 85 | public string Email { get; set; } 86 | 87 | /// 88 | /// The name of the shop, the original order came from 89 | /// 90 | public string ShopName { get; set; } 91 | 92 | /// 93 | /// All positions, that belong to this invoice < 94 | /// 95 | public List Positions { get; set; } 96 | 97 | /// 98 | /// Date date, when this order was payed. If null, the order has not been payed for yet. 99 | /// 100 | public DateTime? PayDate { get; set; } 101 | 102 | /// 103 | /// The vat mode, that is applicable for this invoice 104 | /// 105 | public VatModeEnum VatMode { get; set; } 106 | 107 | /// 108 | /// The unique internal id of this invoice 109 | /// 110 | public long BillbeeId { get; set; } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/InvoicePosition.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | /// 4 | /// Detail information about one position in an invoice 5 | /// 6 | public class InvoicePosition 7 | { 8 | /// 9 | /// Rank of this position in the order 10 | /// 11 | public int Position { get; set; } 12 | 13 | /// 14 | /// The amount, of the given article in this position 15 | /// 16 | public decimal Amount { get; set; } 17 | 18 | /// 19 | /// The net value of the article 20 | /// 21 | public decimal NetValue { get; set; } 22 | 23 | /// 24 | /// The net value of all articles of this position 25 | /// 26 | public decimal TotalNetValue { get; set; } 27 | 28 | /// 29 | /// The gross value of this article 30 | /// 31 | public decimal GrossValue { get; set; } 32 | 33 | /// 34 | /// The gross value of all articles in this position 35 | /// 36 | public decimal TotalGrossValue { get; set; } 37 | 38 | /// 39 | /// The vat rate, that is used for this position 40 | /// 41 | public decimal? VatRate { get; set; } 42 | 43 | /// 44 | /// Internal id of the referenced article 45 | /// 46 | public long? ArticleBillbeeId { get; set; } 47 | 48 | /// 49 | /// The sku of the article of this position 50 | /// 51 | public string Sku { get; set; } 52 | 53 | /// 54 | /// The title to be shown in the invoice of this position 55 | /// 56 | public string Title { get; set; } 57 | 58 | /// 59 | /// The unique internal id of this position 60 | /// 61 | public long BillbeeId { get; set; } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/LayoutTemplate.cs: -------------------------------------------------------------------------------- 1 | using Billbee.Api.Client.Enums; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | public class LayoutTemplate 6 | { 7 | public long Id { get; set; } 8 | public string Name { get; set; } 9 | public ReportTemplates Type { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/MultiLanguageString.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | /// 4 | /// Container to hold a language specific translation 5 | /// 6 | public class MultiLanguageString 7 | { 8 | /// 9 | /// Text representation in the given language 10 | /// 11 | public string Text { get; set; } 12 | 13 | /// 14 | /// ISO language code, that defines the language, the content in < written in. 15 | /// 16 | public string LanguageCode { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/OrderItem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | public class OrderItem 6 | { 7 | /// 8 | /// Id der Einzeltransaktion. Wird nur von Ebay benötigt, um zusammengefasste Bestellungen zu erkennen OR Id of the individual transaction. Only required by Ebay to detect aggregated orders 9 | /// 10 | public string TransactionId { get; set; } 11 | 12 | public OrderItemProduct Product { get; set; } 13 | public decimal Quantity { get; set; } 14 | public decimal TotalPrice { get; set; } 15 | public decimal TaxAmount { get; set; } 16 | public byte? TaxIndex { get; set; } 17 | 18 | /// 19 | /// Sets the discount in percent 20 | /// 21 | public decimal Discount { get; set; } 22 | 23 | public List Attributes { get; set; } 24 | public bool GetPriceFromArticleIfAny { get; set; } 25 | 26 | /// 27 | /// Legt fest, ob es sich bei dieser Position um einen Gutschein handelt, der als umsatzsteuerfreie Zahlung interpretiert wird OR Determines if it is a coupon, which is interpreted as tax-free payment 28 | /// 29 | public bool IsCoupon { get; set; } 30 | 31 | public string ShippingProfileId { get; set; } 32 | 33 | public override string ToString() 34 | { 35 | return $"Q:{Quantity} TP:{TotalPrice} Tax:{TaxIndex} Discount:{Discount}"; 36 | } 37 | 38 | /// 39 | /// If true, the import of this order won't adjust the stock level at billbee. 40 | /// 41 | /// This is used for amazon refunds 42 | public bool DontAdjustStock { get; set; } 43 | 44 | /// 45 | /// Internal Id of billbee 46 | /// 47 | public long? BillbeeId { get; set; } 48 | 49 | public bool IsDiscount { get; set; } 50 | 51 | /// Is just used for the billbee api 52 | public decimal UnrebatedTotalPrice { get; set; } 53 | 54 | /// Contains the used serial number 55 | public string SerialNumber { get; set; } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/OrderItemAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class OrderItemAttribute 4 | { 5 | public string Id { get; set; } 6 | public string Name { get; set; } 7 | public string Value { get; set; } 8 | public decimal Price { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/OrderItemProduct.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | public class OrderItemProduct 6 | { 7 | /// 8 | /// This is for migration scenarios when the internal id of a product changes 9 | /// I.E. Etsy when switching to the new inventory management, the ids for variants will change. 10 | /// 11 | public string OldId { get; set; } 12 | 13 | public string Id { get; set; } 14 | public string Title { get; set; } 15 | 16 | /// 17 | /// Weight of one item in gram 18 | /// 19 | public int? Weight { get; set; } 20 | 21 | public string SKU { get; set; } 22 | 23 | public string SkuOrId 24 | { 25 | get { return string.IsNullOrEmpty(SKU) ? Id : SKU; } 26 | } 27 | 28 | public bool? IsDigital { get; set; } 29 | 30 | public List Images { get; set; } 31 | 32 | public string EAN { get; set; } 33 | 34 | /// 35 | /// Optional platform specific Data as serialized JSON Object for the product 36 | /// 37 | public string PlatformData { get; set; } 38 | 39 | public string TARICCode { get; set; } 40 | public string CountryOfOrigin { get; set; } 41 | public long? BillbeeId { get; set; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/OrderPayment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | public class OrderPayment 6 | { 7 | public long BillbeeId { get; set; } 8 | public string TransactionId { get; set; } 9 | public DateTime PayDate { get; set; } 10 | public short? PaymentType { get; set; } 11 | public string SourceTechnology { get; set; } 12 | public string SourceText { get; set; } 13 | public decimal PayValue { get; set; } 14 | public string Purpose { get; set; } 15 | public string Name { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/OrderProductImage.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | /// 4 | /// Information about a product image 5 | /// 6 | public class OrderProductImage 7 | { 8 | /// 9 | /// Url where this image is located 10 | /// 11 | public string Url { get; set; } 12 | 13 | /// 14 | /// Defines, wether this image should be used as default image, or not. 15 | /// 16 | public bool IsDefaultImage { get; set; } 17 | 18 | /// 19 | /// If more than one image was supplied, the position defines the order 20 | /// 21 | public byte? Position { get; set; } 22 | 23 | /// 24 | /// The if of the image in the external system, the corresponding order was received from 25 | /// 26 | public string ExternalId { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/OrderResult.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class OrderResult 4 | { 5 | public long? Id { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/OrderSearchResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class OrderSearchResult 10 | { 11 | public long Id { get; set; } 12 | public string ExternalReference { get; set; } 13 | public string BuyerName { get; set; } 14 | public string InvoiceNumber { get; set; } 15 | public string CustomerName { get; set; } 16 | public string ArticleTexts { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/OrderShipment.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | /// 4 | /// Information to add a shipment information from an external system to billbee 5 | /// 6 | public class OrderShipment 7 | { 8 | /// 9 | /// The id, the shipment got from the provider 10 | /// 11 | public string ShippingId { get; set; } 12 | 13 | /// 14 | /// The id of the order, this shipment should be attached to 15 | /// 16 | public long OrderId { get; set; } 17 | 18 | /// 19 | /// A note, that should be attached to the shipment 20 | /// 21 | public string Comment { get; set; } 22 | 23 | /// 24 | /// If applicable, that internal id of the provider, the shipment was send with. 25 | /// 26 | public long? ShippingProviderId { get; set; } 27 | 28 | /// 29 | /// If applicable, the internal id of the shipping product, the shipment uses 30 | /// 31 | public long? ShippingProviderProductId { get; set; } 32 | 33 | /// 34 | /// If applicable, the id of a shipping carrier that should be assigend to the shipment 35 | /// Will override the carrier from the shipment product. 36 | /// 37 | public byte? CarrierId { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/OrderShippingId.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | /// 6 | /// Shows shipping ids, that are attached to an order. 7 | /// 8 | public class OrderShippingId 9 | { 10 | /// 11 | /// Id if the shipment 12 | /// 13 | public string ShippingId { get; set; } 14 | 15 | /// 16 | /// The name of the shipping provider 17 | /// 18 | public string Shipper { get; set; } 19 | 20 | /// 21 | /// The date, this shipment was created 22 | /// 23 | public DateTime? Created { get; set; } 24 | 25 | /// 26 | /// The Tracking url 27 | /// 28 | public string TrackingUrl { get; set; } 29 | 30 | /// 31 | /// The id of the used shipping provider 32 | /// 33 | public long? ShippingProviderId { get; set; } 34 | 35 | /// 36 | /// The id of the used shipping provider product 37 | /// 38 | public long? ShippingProviderProductId { get; set; } 39 | 40 | /// 41 | /// The carrier used to ship the parcel with 42 | /// 43 | public byte? ShippingCarrier { get; set; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/OrderUser.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class OrderUser 4 | { 5 | public string Platform { get; set; } 6 | public string BillbeeShopName { get; set; } 7 | public long? BillbeeShopId { get; set; } 8 | public string Id { get; set; } 9 | public string Nick { get; set; } 10 | public string FirstName { get; set; } 11 | public string LastName { get; set; } 12 | 13 | public string FullName 14 | { 15 | get { return string.Format("{0} {1}", FirstName, LastName).Trim(); } 16 | } 17 | 18 | public string Email { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ParsePlaceholdersQuery.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class ParsePlaceholdersQuery 4 | { 5 | /// 6 | /// The text to parse and replace the placeholders in. 7 | /// 8 | public string TextToParse { get; set; } 9 | 10 | /// 11 | /// If true, the string will be handled as html. 12 | /// 13 | public bool IsHtml { get; set; } = false; 14 | 15 | /// 16 | /// The ISO 639-1 code of the target language. Using default if not set. 17 | /// 18 | public string Language { get; set; } = null; 19 | 20 | /// 21 | /// If true, then the placeholder values are trimmed after usage. 22 | /// 23 | public bool Trim { get; set; } = false; 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ParsePlaceholdersResult.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class ParsePlaceholdersResult 4 | { 5 | public string Result { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Billbee.Api.Client.Model 6 | { 7 | /// 8 | /// Defines a product/ article in billbee 9 | /// 10 | public class Product 11 | { 12 | /// 13 | /// Text to display in the invoice 14 | /// 15 | public List InvoiceText { get; set; } 16 | 17 | /// 18 | /// Name of the manufacturer, if given 19 | /// 20 | public string Manufacturer { get; set; } 21 | 22 | /// 23 | /// Internal if of this product 24 | /// 25 | public long? Id { get; set; } 26 | 27 | /// 28 | /// Name of the product 29 | /// 30 | public List Title { get; set; } 31 | 32 | /// 33 | /// Description of the product 34 | /// 35 | public List Description { get; set; } 36 | 37 | /// 38 | /// Short description of the product, to show in summaries 39 | /// 40 | public List ShortDescription { get; set; } 41 | 42 | /// 43 | /// Basic attributes, to define this product 44 | /// 45 | public List BasicAttributes { get; set; } 46 | 47 | /// 48 | /// Images of this product 49 | /// 50 | public List Images { get; set; } 51 | 52 | /// 53 | /// Index of the correct vat rate, to attach to this product. 54 | /// 55 | public byte VatIndex { get; set; } 56 | 57 | /// 58 | /// Gross price of this product 59 | /// 60 | public decimal Price { get; set; } 61 | 62 | /// 63 | /// If applicable, the price, to pay, when buying 64 | /// 65 | public decimal? CostPrice { get; set; } 66 | 67 | public decimal Vat1Rate { get; set; } 68 | public decimal Vat2Rate { get; set; } 69 | 70 | /// 71 | /// Defines, how big the amount of stock of this article should be 72 | /// 73 | public decimal? StockDesired { get; set; } 74 | 75 | /// 76 | /// Show, how big the current stock of this article is. 77 | /// 78 | public decimal? StockCurrent { get; set; } 79 | 80 | /// 81 | /// Defines, when to alert, because of low stock 82 | /// 83 | public decimal? StockWarning { get; set; } 84 | 85 | public string SKU { get; set; } 86 | public string EAN { get; set; } 87 | 88 | /// 89 | /// A list of materials, this products consists of 90 | /// 91 | public List Materials { get; set; } 92 | 93 | /// 94 | /// List if tags, that are marking this product 95 | /// 96 | public List Tags { get; set; } 97 | 98 | /// 99 | /// Sources, this article is attached to 100 | /// 101 | public List Sources { get; set; } 102 | 103 | /// 104 | /// The gross weight of this article 105 | /// 106 | public int? Weight { get; set; } 107 | 108 | /// 109 | /// The new weight of this article 110 | /// 111 | public int? WeightNet { get; set; } 112 | /// 113 | /// The stock code, where this article is stored 114 | /// 115 | public string StockCode { get; set; } 116 | 117 | public decimal? StockReduceItemsPerSale { get; set; } 118 | public List Stocks { get; set; } 119 | public ArticleCategory Category1 { get; set; } 120 | public ArticleCategory Category2 { get; set; } 121 | public ArticleCategory Category3 { get; set; } 122 | public byte Type { get; set; } 123 | public short? Unit { get; set; } 124 | public decimal? UnitsPerItem { get; set; } 125 | public decimal? SoldAmount { get; set; } 126 | public decimal? SoldSumGross { get; set; } 127 | public decimal? SoldSumNet { get; set; } 128 | public decimal? SoldSumNetLast30Days { get; set; } 129 | public decimal? SoldSumGrossLast30Days { get; set; } 130 | public decimal? SoldAmountLast30Days { get; set; } 131 | 132 | /// 133 | /// If this article is bundled with a specific shipping product 134 | /// 135 | public long? ShippingProductId { get; set; } 136 | 137 | public bool IsDigital { get; set; } 138 | public bool IsCustomizable { get; set; } 139 | public byte? DeliveryTime { get; set; } 140 | public byte? Recipient { get; set; } 141 | public byte? Occasion { get; set; } 142 | public string CountryOfOrigin { get; set; } 143 | 144 | [Obsolete("Use ExportDescriptionMultiLanguage instead.")] 145 | public string ExportDescription { get; set; } 146 | public List ExportDescriptionMultiLanguage { get; set; } = new List(); 147 | 148 | public string TaricNumber { get; set; } 149 | 150 | public List CustomFields { get; set; } = new List(); 151 | 152 | public bool? IsDeactivated { get; set; } 153 | 154 | public List BillOfMaterial { get; set; } 155 | public byte? Condition { get; set; } 156 | public decimal? WidthCm { get; set; } 157 | public decimal? LengthCm { get; set; } 158 | public decimal? HeightCm { get; set; } 159 | 160 | [JsonProperty("LowStock")] 161 | public bool IsLowStock { get; set; } 162 | } 163 | 164 | public class BomSubArticleApiModel 165 | { 166 | public decimal Amount { get; set; } 167 | public long? ArticleId { get; set; } 168 | public string SKU { get; set; } 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ProductSearchResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class ProductSearchResult 10 | { 11 | public long Id { get; set; } 12 | public string ShortText { get; set; } 13 | public string SKU { get; set; } 14 | public string Tags { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Search.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class Search 10 | { 11 | /// 12 | /// List of types, to search in should be "order", "product" and/or "customer" 13 | /// 14 | public List Type { get; set; } 15 | 16 | /// 17 | /// string to search for 18 | /// 19 | public string Term { get; set; } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/SearchResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class SearchResult 10 | { 11 | public List Products { get; set; } 12 | public List Orders { get; set; } 13 | public List Customers { get; set; } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/SendMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | 10 | public enum ConfirmationMessageSendMode 11 | { 12 | None = 0, 13 | Email = 1, 14 | Api = 2, 15 | EmailThenApi = 3, 16 | ExternalEmail = 4 17 | } 18 | 19 | /// 20 | /// Container to store information for a message, that can be send via an order. 21 | /// 22 | public class SendMessage 23 | { 24 | /// 25 | /// Defines, how the message is send 26 | /// 27 | public ConfirmationMessageSendMode SendMode = ConfirmationMessageSendMode.EmailThenApi; 28 | 29 | /// 30 | /// The Subject of the message 31 | /// 32 | public List Subject = new List(); 33 | 34 | /// 35 | /// The body of the message 36 | /// 37 | public List Body = new List(); 38 | 39 | /// 40 | /// An alternative recipient email address 41 | /// 42 | public string AlternativeMail = null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Shipment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Billbee.Api.Client.Enums; 3 | 4 | namespace Billbee.Api.Client.Model 5 | { 6 | /// 7 | /// Represents a single shipment. 8 | /// 9 | public class Shipment 10 | { 11 | /// 12 | /// The billbee internal id of the shipment 13 | /// 14 | public long BillbeeId { get; set; } 15 | 16 | /// The id of this shipment 17 | public string ShippingId { get; set; } 18 | 19 | /// The name of the shipping provider 20 | public string Shipper { get; set; } 21 | 22 | /// The creation date 23 | public DateTime? Created { get; set; } 24 | 25 | /// 26 | /// The url to track this shipment 27 | /// 28 | public string TrackingUrl { get; set; } 29 | 30 | /// 31 | /// The id of the used shipping provider 32 | /// 33 | public long? ShippingProviderId { get; set; } 34 | 35 | /// 36 | /// The id of the used shipping provider product 37 | /// 38 | public long? ShippingProviderProductId { get; set; } 39 | 40 | /// 41 | /// The carrier used to ship the parcel with 42 | /// 43 | public ShippingCarrierEnum? ShippingCarrier { get; set; } 44 | 45 | /// 46 | /// Shipment Type, 0 if Shipment, 1 if Retoure 47 | /// 48 | public ShipmentTypeEnum? ShipmentType { get; set; } 49 | } 50 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ShipmentAddress.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class ShipmentAddress 4 | { 5 | public string Company { get; set; } 6 | public string FirstName { get; set; } 7 | public string LastName { get; set; } 8 | public string Name2 { get; set; } 9 | public string Street { get; set; } 10 | public string Housenumber { get; set; } 11 | public string Zip { get; set; } 12 | public string City { get; set; } 13 | 14 | /// 15 | /// The ISO 2 code of the country 16 | /// 17 | public string CountryCode { get; set; } 18 | 19 | /// 20 | /// The ISO 3 code of the country 21 | /// 22 | public string CountryCodeISO3 { get; set; } 23 | 24 | public string Email { get; set; } 25 | public string Telephone { get; set; } 26 | public string AddressAddition { get; set; } 27 | public bool IsExportCountry { get; set; } 28 | public string State { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ShipmentDimensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | /// 10 | /// Defines the dimnesion of an package, that should be used for shipping an order. 11 | /// 12 | public class ShipmentDimensions 13 | { 14 | /// 15 | /// Length of the package in cm 16 | /// 17 | public decimal length { get; set; } 18 | /// 19 | /// Width of the package in cm 20 | /// 21 | public decimal width { get; set; } 22 | /// 23 | /// Height of the package in cm 24 | /// 25 | public decimal height { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ShipmentPost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Billbee.Api.Client.Enums; 4 | 5 | namespace Billbee.Api.Client.Model 6 | { 7 | namespace Rechnungsdruck.WebApp.Model.Api 8 | { 9 | /// 10 | /// Conainer, to create a shipment without context to a billbee order. 11 | /// 12 | public class PostShipment 13 | { 14 | /// 15 | /// Name of the shipping provider, to use 16 | /// 17 | public string ProviderName { get; set; } 18 | 19 | /// 20 | /// Product code of the shipping provider for the product, to use as shipment method 21 | /// 22 | public string ProductCode { get; set; } 23 | 24 | /// 25 | /// Name of the cloud printer, to send the labels to 26 | /// 27 | public string PrinterName { get; set; } 28 | 29 | /// 30 | /// The id of a connected Cloudprinter to sent the export docs to 31 | /// 32 | public long? PrinterIdForExportDocs { get; set; } 33 | 34 | /// 35 | /// List of services, to attach to the shipping product 36 | /// 37 | public List Services { get; set; } 38 | 39 | /// 40 | /// Address of the adressee 41 | /// 42 | public ShipmentAddress ReceiverAddress { get; set; } 43 | 44 | /// 45 | /// Reference number for this parcel 46 | /// 47 | public string ClientReference { get; set; } 48 | 49 | /// 50 | /// Number of the customer, this parcel should be send to. 51 | /// 52 | public string CustomerNumber { get; set; } 53 | 54 | /// 55 | /// gross weight of the parcel 56 | /// 57 | public decimal? WeightInGram { get; set; } 58 | 59 | /// 60 | /// Total gross value of the parcel 61 | /// 62 | public decimal OrderSum { get; set; } 63 | 64 | /// 65 | /// Currency code, of the currency, the order was made in. < 66 | /// 67 | public string OrderCurrencyCode { get; set; } 68 | 69 | /// 70 | /// For export parcels, the content has to be defined 71 | /// 72 | public string Content { get; set; } 73 | 74 | /// 75 | /// Date and time of shipment 76 | /// 77 | public DateTime? ShipDate { get; set; } 78 | 79 | /// 80 | /// The Id of the carrier, the parcel will be send with 81 | /// 82 | public byte shippingCarrier { get; set; } 83 | 84 | /// 85 | /// The value of the shipments content (net) 86 | /// 87 | public decimal TotalNet { get; set; } 88 | 89 | public ShipmentDimensions Dimension { get; set; } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ShipmentResult.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class ShipmentResult 4 | { 5 | /// 6 | /// Id of the created shipment 7 | /// 8 | public string ShippingId { get; set; } 9 | 10 | /// 11 | /// Byte array containing the label of the created shipment in PDF format 12 | /// 13 | public byte[] LabelData { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ShipmentWithLabel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | /// 10 | /// Request object, to ship an order in billbee 11 | /// 12 | public class ShipmentWithLabel 13 | { 14 | /// 15 | /// Billbee internal id of the order, that should be shipped. 16 | /// 17 | public long OrderId { get; set; } 18 | /// 19 | /// Billbee internal id of the provider, that should be used for shipping 20 | /// 21 | public long ProviderId { get; set; } 22 | /// 23 | /// Billbee internal id of the product, that should be used for shipping 24 | /// 25 | public long ProductId { get; set; } 26 | /// 27 | /// Optional. If set to true, the state of the given order is set to send, after creation of label. Default value is true. 28 | /// 29 | public bool? ChangeStateToSend { get; set; } 30 | /// 31 | /// Optional. Name of a cloud drive or printer, that should be used to automatically store the label after creation. 32 | /// 33 | public string PrinterName { get; set; } 34 | /// 35 | /// Optional. Total weight of the parcel in gram 36 | /// 37 | public int? WeightInGram { get; set; } 38 | /// 39 | /// Optional. Date when the parcel should be send. 40 | /// 41 | public DateTime? ShipDate { get; set; } 42 | /// 43 | /// Optional. If given, this reference will be added to the parcel process as individual reference. 44 | /// 45 | public string ClientReference { get; set; } 46 | /// 47 | /// Optional. The dimension of the package. 48 | /// 49 | public ShipmentDimensions Dimension { get; set; } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ShipmentWithLabelResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class ShipmentWithLabelResult 10 | { 11 | /// 12 | /// Id of the order, that was shipped 13 | /// 14 | public long OrderId { get; set; } 15 | /// 16 | /// Reference number of the carrier or provider 17 | /// 18 | public string OrderReference { get; set; } 19 | /// 20 | /// Order or tracking number of the carrier or provider 21 | /// 22 | public string ShippingId { get; set; } 23 | /// 24 | /// URL to track the shipment 25 | /// 26 | public string TrackingUrl { get; set; } 27 | /// 28 | /// If applicable, the pdf data of the label as base 64 encoded data. 29 | /// 30 | public byte[] LabelDataPdf { get; set; } 31 | /// 32 | /// If applicable, the pdf data of the export documents as base 64 encoded data. 33 | /// 34 | public byte[] ExportDocsPdf { get; set; } 35 | 36 | /// 37 | /// Text representation of the used carrier 38 | /// 39 | public string Carrier { get; set; } 40 | 41 | /// 42 | /// The datetime, defining, when the order should be send 43 | /// 44 | public DateTime ShippingDate { get; set; } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ShippingCarrier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class ShippingCarrier 10 | { 11 | public byte Id { get; set; } 12 | public string Name { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ShippingProduct.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class ShippingProduct 4 | { 5 | /// 6 | /// Id of this shipping product 7 | /// 8 | public long id { get; set; } 9 | 10 | /// 11 | /// Human readable name of this shippingproduct 12 | /// 13 | public string displayName { get; set; } 14 | 15 | /// 16 | /// Provider specific product name 17 | /// 18 | public string productName { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/ShippingProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | public class ShippingProvider 6 | { 7 | /// 8 | /// internal id of this provider 9 | /// 10 | public long id { get; set; } 11 | 12 | /// 13 | /// Name of this provider 14 | /// 15 | public string name { get; set; } 16 | 17 | /// 18 | /// Available products 19 | /// 20 | public List products { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Stock.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class Stock 4 | { 5 | public long Id { get; set; } 6 | public string Name { get; set; } 7 | public string Description { get; set; } 8 | public bool IsDefault { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/StockArticle.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class StockArticle 4 | { 5 | public string Name { get; set; } 6 | public long StockId { get; set; } 7 | public decimal? StockCurrent { get; set; } 8 | public decimal? StockWarning { get; set; } 9 | public string StockCode { get; set; } 10 | public decimal? UnfulfilledAmount { get; set; } 11 | public decimal? StockDesired { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/TermsResult.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class TermsResult 4 | { 5 | public string LinkToTermsWebPage { get; set; } 6 | public string LinkToPrivacyWebPage { get; set; } 7 | public string LinkToTermsHtmlContent { get; set; } 8 | public string LinkToPrivacyHtmlContent { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/TriggerEventContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class TriggerEventContainer 10 | { 11 | /// Name of the event 12 | public string Name { get; set; } 13 | 14 | /// The delay in minutes until the rule is executed 15 | public uint DelayInMinutes { get; set; } = 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/UpdateStock.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class UpdateStock 4 | { 5 | /// 6 | /// The SKU of the product to update 7 | /// 8 | public string Sku { get; set; } 9 | /// 10 | /// Optional the stock id if the feature multi stock is activated 11 | /// 12 | public long? StockId { get; set; } 13 | /// 14 | /// Optional a reason text for the stock update 15 | /// 16 | public string Reason { get; set; } 17 | /// 18 | /// This parameter is currently ignored 19 | /// 20 | public decimal? OldQuantity { get; set; } 21 | /// 22 | /// The new absolute stock quantity for the product you want to set 23 | /// 24 | public decimal? NewQuantity { get; set; } 25 | /// 26 | /// This parameter is currently ignored 27 | /// 28 | public decimal DeltaQuantity { get; set; } 29 | 30 | /// 31 | /// Automatically reduce the NewQuantity by the currently not fulfilled amount 32 | /// 33 | /// 34 | /// If set to true, the NewQuantity is automatically reduced bei the reserved (not fulfilled) amount of the given article 35 | /// 36 | public bool AutosubtractReservedAmount { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/UpdateStockCode.cs: -------------------------------------------------------------------------------- 1 | namespace Billbee.Api.Client.Model 2 | { 3 | public class UpdateStockCode 4 | { 5 | public string Sku { get; set; } 6 | public long? StockId { get; set; } 7 | public string StockCode { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/Webhook.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Billbee.Api.Client.Model 4 | { 5 | public class Webhook 6 | { 7 | public string Id { get; set; } 8 | public string WebHookUri { get; set; } 9 | public string Secret { get; set; } 10 | public string Description { get; set; } 11 | public bool IsPaused { get; set; } 12 | public List Filters { get; set; } 13 | public Dictionary Headers { get; set; } 14 | public Dictionary Properties { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Billbee.Api.Client/Model/WebhookFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Billbee.Api.Client.Model 8 | { 9 | public class WebhookFilter 10 | { 11 | public string Name { get; set; } 12 | public string Description { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Billbee.Api.Client/favicon_32.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/billbeeio/billbee-csharp-sdk/3f13b92940d8bdd04cb119c85b9620f94f2864d9/Billbee.Api.Client/favicon_32.ico -------------------------------------------------------------------------------- /Billbee.Api.Client/forUnitTests.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | [assembly:InternalsVisibleTo("Billbee.Api.Client.Test")] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Billbee GmbH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Logo](https://app.billbee.io/static/billbee/img/logo.png)](https://www.billbee.io) 2 | 3 | # Billbee API 4 | With this package you can implement the official Billbee API in your C# application. 5 | 6 | ## Prerequisites 7 | - For accessing the Billbee API you need an API Key. 8 | To get an API key, send a mail to [support@billbee.de](mailto:support@billbee.de) and send us a short note about what you are building. 9 | - The API module must be activated in the account ([https://app.billbee.io/app_v2/settings/api/general](https://app.billbee.io/app_v2/settings/api/general)) 10 | 11 | ## Install 12 | Download this package and decompress the solution to a place of your choice. 13 | If you don't want to compile by yourself, feel free, to use our NuGet package. 14 | ```Bash 15 | PM> Install-Package Billbee.Api.Client -Version 2.4.2 16 | ``` 17 | 18 | ## Official API Documentation 19 | [https://app.billbee.io/swagger/ui/index](https://app.billbee.io/swagger/ui/index) 20 | 21 | ## Usage 22 | 23 | Simply open the solution in your Visual Studio or other C# IDE. 24 | 25 | Then open the Billbee.Api.Client.Demo project and take a look at the examples in Program.cs 26 | 27 | ## Demo 28 | 29 | ### Initialization 30 | 31 | ```csharp 32 | // Creating an individual logger, that implements ILogger 33 | ILogger logger = new Logger(); 34 | 35 | // Creating new instance of ApiClient 36 | ApiClient client = new ApiClient(logger: logger); 37 | 38 | // Enter your api key here. If you don't have an api key. Please contact support@billbee.de with a description on what you would like to do, to get one. 39 | client.Configuration.ApiKey = ""; 40 | // Enter the username of your main account here. 41 | client.Configuration.Username = ""; 42 | // Enter the password of your api here. 43 | client.Configuration.Password = ""; 44 | 45 | // Test the configuration 46 | if (client.TestConfiguration()) 47 | { 48 | logger.LogMsg("Api test successful", LogSeverity.Info); 49 | } 50 | else 51 | { 52 | logger.LogMsg("Api test failed. Please control your configuration", LogSeverity.Error); 53 | } 54 | ``` 55 | 56 | ### Demo Calls 57 | ```csharp 58 | // Getting events for this account 59 | var events = client.Events.GetEvents(); 60 | 61 | // Getting my shipping providers 62 | var shippingProvider = client.Shipment.GetShippingProvider(); 63 | 64 | // Doing some stock manipulations 65 | Console.WriteLine("Please enter one SKU of an article to update it's stock. Be aware, that these changes are permanent, so better use a demo article. Leave blank to skip."); 66 | var sku = Console.ReadLine(); 67 | if (!string.IsNullOrWhiteSpace(sku)) 68 | { 69 | var updateStockCodeResult = client.Products.UpdateStockCode(new Billbee.Api.Client.Model.UpdateStockCode { Sku = sku, StockCode = "Testlager" }); 70 | var updateStockResult = client.Products.UpdateStock(new Billbee.Api.Client.Model.UpdateStock { Sku = sku, NewQuantity = 15, Reason = "Change due to api tests." }); 71 | var updateStockMultipleResult = client.Products.UpdateStockMultiple(new List { new Billbee.Api.Client.Model.UpdateStock { Sku = sku, NewQuantity = 15 }, new Billbee.Api.Client.Model.UpdateStock { Sku = "4712", NewQuantity = 23 } }); 72 | } 73 | 74 | // Requesting the urls of the terms and conditions for the usage of billbee. 75 | var termsAndConditions = client.AutomaticProvision.TermsInfo(); 76 | 77 | // Getting a list of all orders with order state 'confirmed' 78 | var orders = client.Orders.GetOrderList(page: 1, pageSize: 20, orderStateId: new List { 2 }); 79 | // var x = client.Orders.GetInvoiceList(); 80 | 81 | // Example to create a new order. Please create a complete order object for usage. 82 | // var createOrderResult = client.Orders.PostNewOrder(new Billbee.Api.Client.Model.Order() { }); 83 | 84 | Console.WriteLine("Please enter one order number for further test manipulations. Be aware, that these changes are permanent. Please use an demo order. Leave blank to skip."); 85 | var orderId = Console.ReadLine(); 86 | int orderIdInt; 87 | if (!string.IsNullOrWhiteSpace(orderId) && int.TryParse(orderId, out orderIdInt)) 88 | { 89 | // Remove all old tags and add the given ones. 90 | var updateTagsResult = client.Orders.UpdateTags(new List() { "Test C", "Test D" }, orderIdInt); 91 | 92 | // Add new tags. 93 | var addTagsResult = client.Orders.AddTags(new List() { "Test A", "Test B" }, orderIdInt); 94 | 95 | // Add a shipment to an order. Please fill in the following and uncomment. the last line. 96 | string shippingId = "0815"; 97 | int providerId = 0; 98 | int productId = 0; 99 | // client.Orders.AddShipment(new OrderShipment { Comment = "Test", OrderId = orderIdInt, ShippingId = shippingId, ShippingProviderId = providerId, ShippingProviderProductId = productId }); 100 | 101 | // Getting documents 102 | var deliveryNoteResult = client.Orders.CreateDeliveryNote(orderIdInt, true); 103 | var invoiceResult = client.Orders.CreateInvoice(orderIdInt, true); 104 | } 105 | ``` 106 | 107 | ## Contributing 108 | Feel free to fork the repository and create pull-requests 109 | --------------------------------------------------------------------------------