1 unstable release

new 0.0.1 Feb 23, 2025

#11 in #user-token

MIT license

255KB
6.5K SLoC

Meegle SDK

Crates.io Documentation License: MIT codecov

A powerful and user-friendly Rust SDK for interacting with the Meegle OpenAPI. This SDK provides a comprehensive set of tools for managing work items, workflows, and project resources.

中文文档

Features

  • Full API coverage with type-safe interfaces
  • Async/await support
  • Comprehensive error handling
  • Easy-to-use builder patterns
  • Rich documentation and examples
  • Automatic token management
  • File upload/download support
  • Cross-platform compatibility

Installation

Add this to your Cargo.toml:

[dependencies]
meegle-sdk = "0.0.1"

Quick Start

use meegle_sdk::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize client with plugin credentials
    let client = Client::builder()
        .plugin_id("your-plugin-id")
        .plugin_secret("your-plugin-secret")
        .build()?;

    // Or initialize with user token
    let client = Client::new("your-api-token");
    
    // Use the client to interact with the API
    let projects = client
        .list_projects(ListProjectRequest::default(), AuthType::User { 
            token: "your-token".to_string() 
        })
        .await?;
    
    Ok(())
}

Available APIs

The SDK provides the following API modules:

Work Item Management

  • Work Item Operations
    • Create, update, delete work items
    • Search work items in project
    • Cross-project work item search
    • Get work item details
    • Batch update work items
    • Get work item metadata
  • Work Item Type Configuration
    • Get work item types in project
    • Get/Update work item type config
  • Work Item Relations
    • Create/Update/Delete work item relations
    • Get relation list
  • Work Item Fields
    • List fields
    • Create/Update custom fields
  • Subtask Management
    • Create/Update/Delete subtasks
    • Complete/Rollback subtasks
    • Get subtask details
    • Cross-project subtask search
  • File Attachments
    • Upload/Download files
    • Upload rich text images
    • Delete attachments
  • Comments
    • Add/Update/Delete comments
    • Get comment list

Workflow Management

  • Workflow Templates
    • Get template list and details
    • Create/Update/Delete templates
  • Workflow State Management
    • Change state
    • Get workflow details
    • Get WBS workflow info
  • Node Operations
    • Update node information
    • Complete/Rollback nodes
  • Process Role Configuration
    • Get role configuration details

Project Management

  • Project Operations
    • List accessible projects
    • Get project details
  • Project Relations
    • Get relation rules
    • Get related instances
    • Batch bind/unbind relations
  • Business Line Management
    • Get business line details
  • View Management
    • Get view list and configurations
    • Create/Update/Delete views
    • Get fixed/panoramic view items

User Management

  • User Groups
    • Get group members
    • Create custom groups
    • Update group members
  • Role Management
    • Get role configurations
  • Authentication
    • Plugin-based auth
    • User token auth

Additional Features

  • Work Hour Tracking
    • Get work hour records
    • Create/Update/Delete work hours
  • Measurement and Analytics
    • Get measurement chart details
  • Review Process Management
    • Batch query review opinions
    • Update review opinions
    • Get conclusion options
  • Chat Integration
    • Real-time communication features

Detailed API Documentation

Work Item API

// Create a work item
client.create_work_item(project_key, request, auth).await?;

// Update a work item
client.update_work_item(project_key, work_item_type_key, work_item_id, request, auth).await?;

// Delete a work item
client.delete_work_item(project_key, work_item_type_key, work_item_id, auth).await?;

// Search work items
client.filter_work_items_in_project(project_key, request, auth).await?;

// Get work item details
client.get_work_item_details(project_key, work_item_type_key, request, auth).await?;

Workflow API

// Get workflow details
client.get_workflow_detail(project_key, work_item_type_key, work_item_id, request, auth).await?;

// Update node information
client.update_node(project_key, work_item_type_key, work_item_id, node_id, request, auth).await?;

// Change state
client.change_state(project_key, work_item_type_key, work_item_id, request, auth).await?;

File API

// Upload a file
client.upload_file(request, auth).await?;

// Download a work item file
client.download_work_item_file(request, auth).await?;

// Delete a file
client.delete_file(request, auth).await?;

Project API

// List projects
client.list_projects(request, auth).await?;

// Get project details
client.get_projects_detail(request, auth).await?;

// Get business line details
client.get_business_list(request, auth).await?;

For more detailed examples and API documentation, please visit our API Documentation.

Configuration

The SDK can be configured through environment variables or direct configuration:

let client = Client::builder()
    .base_url("https://your-api-endpoint.com")
    .timeout(Duration::from_secs(30))
    .build()?;

Error Handling

The SDK provides comprehensive error handling:

use meegle_sdk::error::ApiError;

match client.get_work_item_details(project_key, work_item_type_key, request, auth).await {
    Ok(details) => println!("Work item details: {:?}", details),
    Err(ApiError::RequestError(e)) => eprintln!("Request error: {}", e),
    Err(ApiError::ResponseError(e)) => eprintln!("Response error: {}", e),
    Err(e) => eprintln!("Other error: {}", e),
}

Contributing

We welcome contributions! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

Acknowledgments

Thanks to all the developers who have contributed to this project!

Dependencies

~8–20MB
~297K SLoC