Dinaup .NET Client Library Documentation
Welcome to the comprehensive guide on using the Dinaup .NET Client Library. This documentation is designed to help developers integrate and interact with the Dinaup API seamlessly using the provided .NET client library.
Table of Contents
Introduction
Dinaup is a flexible SaaS platform where each company maintains its own data, documents, reports, and structures. The platform utilizes sections (similar to database tables) to store data, dynamic documents (scripts generating plain text documents like HTML, JSON, etc.), and reports (configurable queries akin to PostgreSQL views).
To facilitate interaction with the Dinaup API, we provide a .NET Core client library called DinaupClient. This client is generic and can handle any model or structure auto-generated in MyDinaup, a company-specific library defining models and constants.
Installation
The DinaupClient library is available as a NuGet package hosted on GitHub Packages. To install it, follow these steps:
Add the GitHub Package source to your NuGet sources:
nuget sources Add -Name "GitHub-Dinaup" -Source "https://nuget.pkg.github.com/DinaupSoftware/index.json" -Username YOUR_GITHUB_USERNAME -Password YOUR_GITHUB_TOKENEnsure your GitHub token has the
read:packages
scope.Install the package in your project:
Install-Package Dinaup -Version x.x.xReplace
x.x.x
with the latest version.
Getting Started
Initialization
To start using the DinaupClient, you need to initialize it with the following parameters:
Endpoint: The API endpoint URL.
API Key: Your public API key.
API Secret: Your secret API key.
Default User ID: (Optional) The user ID for default sessions.
Here's how you can initialize the client:
Session Management
DinaupClient requires sessions to perform operations that depend on user context. Sessions can be for the system user or specific users.
Default Session
After initializing the client, you can update the default session:
User Sessions
To create a session for a specific user:
Core Functionalities
Data Operations
Dinaup allows you to perform CRUD (Create, Read, Update, Delete) operations on dynamic sections. Each company has its own set of sections defined in MyDinaup, which provides the models and constants.
Adding Records
To add a new record to a section:
Using WriteOperation Directly (recommended)
var data = new Dictionary<string, string> { { MyDinaup.SectionsD.SeccionDePruebasAPID.SeccionDePruebasAPIES.TextoPrincipal, "Sample Text" }, // Add other fields }; var writeOperation = new WriteOperation(string.Empty, data); var sectionId = MyDinaup.SectionsD.SeccionDePruebasAPID._SectionIDGUID; var result = dinaupClient.RunWriteOperation(dinaupClient.DefaultSession, sectionId, writeOperation, false); result.EnsureSucess();Using Models (not recommended)
// Create an instance of the model var newRecord = new MyDinaup.SectionsD.SeccionDePruebasAPID.SeccionDePruebasAPIC { TextoPrincipal = "Sample Text", // Set other fields as needed }; // Run the write operation var result = dinaupClient.RunWriteOperation(dinaupClient.DefaultSession, newRecord, false); result.EnsureSucess();
Editing Records
To edit an existing record:
Retrieve the record you want to edit:
var recordId = Guid.Parse("RECORD_GUID"); var data = new Dictionary<string, string> { { MyDinaup.SectionsD.SeccionDePruebasAPID.SeccionDePruebasAPIES.TextoPrincipal, "Sample Text" }, // Add other fields }; var writeOperation = new WriteOperation(recordId, data); var sectionId = MyDinaup.SectionsD.SeccionDePruebasAPID._SectionIDGUID; var result = dinaupClient.RunWriteOperation(dinaupClient.DefaultSession, sectionId, writeOperation, false); result.EnsureSucess();
Bulk Operations
You can perform bulk operations by providing a list of WriteOperation
instances:
Direct vs. Virtualized Writing
Direct Writing: Faster but doesn't execute scripts or events.
Virtualized Writing: Executes scripts and events, automatically recalculates data if required (e.g., calculating totals in a sale).
Specify the writing mode in the RunWriteOperation
method:
File Management
Uploading Files
You can upload files up to 700MB.
Uploading from Bytes
Uploading from URL
Signing URLs
To generate a signed URL for a private file:
Email Sending
To send an email:
Annotations
Annotations allow you to attach notes, files, and participate in chats related to records.
Adding an Annotation
Retrieving Annotations
Advanced Features
Working with Dynamic Documents
Dynamic documents are scripts that generate plain text documents (HTML, JSON, XML, etc.).
Executing a Dynamic Document
Using MyDinaup Models
Using Reports
Reports are configurable queries similar to database views.
Executing a Report
Applying Filters
Ordering Results
Error Handling and Debugging
When performing operations, it's essential to handle exceptions and check for errors.
Handling Exceptions
Checking Operation Results
Best Practices
Initialize the Client Properly: Always call
Ini()
after creating an instance ofDinaupClientC
.Check Connections: Verify
IsConnected
before performing operations.Manage Sessions Carefully: Ensure sessions are updated and valid.
Handle Exceptions: Wrap operations in try-catch blocks and handle exceptions gracefully.
Use Models from MyDinaup: Utilize the auto-generated models for your company's sections to simplify data handling.
Limit Bulk Operations: When performing bulk operations, avoid exceeding limits (e.g., avoid sending too many records at once).
Secure API Keys: Never expose your API keys in code repositories or logs.
Conclusion
The Dinaup .NET Client Library provides a robust and flexible way to interact with the Dinaup API, allowing you to manage data, files, emails, and more within your applications. By leveraging the auto-generated models from MyDinaup, you can streamline your development process and focus on building features that add value to your business.
Further Resources
Dinaup GitHub Repository: DinaupSoftware/Dinaup
NuGet Package: Available via GitHub Packages (soon on NuGet.org)
API Documentation: (Provide a link to the official API documentation if available)
Support: Contact Dinaup support for assistance or further information.
Note: This documentation is based on the provided unit tests and examples. For specific use cases or advanced scenarios, refer to the official API documentation or contact support.