Releases: poboll/cai-api-sdk
✨ feat: Extend cai-api-sdk with new parameter models for diverse API requests
Cai API SDK开发者工具包
介绍
此版本引入了一系列新功能,扩展了 cai-api-sdk 的功能,为开发人员提供了更强大的工具,以有效地与各种 API 交互。此更新包括设计用于处理广泛 API 请求的新参数模型,提高了 SDK 的灵活性和易用性。
主要特性
- 为星座洞察、IP 信息检索、详细姓名数据、随机壁纸生成、天气预报和浪漫语句提供新的参数模型。
- 通过引入自定义
ApiException
和更新ErrorCode
枚举来增强错误处理能力。 - 增加了 API 请求配置的多样性,以支持各种开发者需求和用例。
功能增强
- HoroscopeParams: 允许根据星座和具体时间获取星座洞察。
- IpInfoParams: 启用详细的 IP 信息检索。
- NameParams: 便于收集基于姓名的详细数据。
- RandomWallpaperParams 和 PoisonousChickenSoupParams: 分别提供访问随机壁纸和幽默、激励性语录的功能。
- WeatherParams: 支持基于 IP、城市和类型的详细天气预报。
- LoveParams: 简化的参数集,用于获取浪漫语句。
使用说明
将更新的 cai-api-sdk 集成到您的项目中,以利用新的参数模型和增强的功能:
<dependency>
<groupId>com.caiths</groupId>
<artifactId>cai-api-sdk</artifactId>
<version>0.0.2</version>
</dependency>
Cai API SDK Developer Kit
Introduction
This release introduces a suite of new features that expand the capabilities of the cai-api-sdk, providing developers with enhanced tools to interact with diverse APIs effectively. The update includes new parameter models designed to handle a wide array of API requests, improving the SDK’s flexibility and ease of use.
Key Features
- New parameter models for horoscope insights, IP information retrieval, detailed name data, random wallpaper generation, weather forecasting, and romantic phrases.
- Enhanced error handling with the introduction of custom
ApiException
and updatedErrorCode
enumerations. - Increased versatility in API request configurations to support a variety of developer needs and use cases.
Enhancements
- HoroscopeParams: Allows fetching of horoscope insights based on zodiac signs and specific times.
- IpInfoParams: Enables detailed IP information retrieval.
- NameParams: Facilitates gathering of detailed name-based data.
- RandomWallpaperParams and PoisonousChickenSoupParams: Provides access to random wallpapers and humorous, motivational quotes respectively.
- WeatherParams: Supports detailed weather forecasting based on IP, city, and type.
- LoveParams: Simplified parameter set for fetching romantic phrases.
Usage Instructions
Integrate the updated cai-api-sdk into your project to leverage the new parameter models and enhanced functionalities:
<dependency>
<groupId>com.caiths</groupId>
<artifactId>cai-api-sdk</artifactId>
<version>0.0.2</version>
</dependency>
✨chore: Cai API SDK开发者工具包初始化
Cai API SDK开发者工具包
介绍
这是 cai-api-sdk
项目的首个版本 v0.0.1
,该 SDK 提供了与第三方 API 的简化集成,支持通过 API 调用执行签名验证和用户信息处理。
主要特性包括:
- 基于 Spring Boot 自动配置,快速集成 API 客户端
- 提供基于 Hutool 加密库的 SHA-256 签名生成功能
- 实现了基础的用户实体类用于 API 调用中的身份标识
- 支持自定义
accessKey
和secretKey
通过配置文件注入
主要变更
- 初始化项目结构,包含
CaiApiClient
、SignUtil
工具类、User
实体类。 - 提供基础的 API 客户端集成与用户验证功能。
- 自动生成的 JavaDoc 注释,支持文档生成。
用法
-
添加 Maven 依赖
您可以通过 Maven 将
cai-api-sdk
添加到您的项目中。在pom.xml
中引入如下依赖:<dependency> <groupId>com.caiths</groupId> <artifactId>cai-api-sdk</artifactId> <version>0.0.1</version> </dependency>
-
Spring Boot 自动配置
cai-api-sdk
基于 Spring Boot 自动配置,您只需在配置文件中提供accessKey
和secretKey
即可完成 API 客户端的初始化。以下是配置示例:# application.properties caiapi.client.accessKey=your-access-key caiapi.client.secretKey=your-secret-key
-
签名工具的使用
SignUtil
提供了便捷的接口签名生成功能,您可以通过以下方式生成签名:import com.caiths.caiapisdk.utils.SignUtil; public class Example { public static void main(String[] args) { String body = "exampleBody"; String secretKey = "yourSecretKey"; String signature = SignUtil.genSign(body, secretKey); System.out.println("Generated Signature: " + signature); } }
-
API 客户端的使用
CaiApiClient
会自动加载 Spring 配置,您可以在任意需要使用 API 的类中直接注入并调用:import com.caiths.caiapisdk.client.CaiApiClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class ApiService { @Autowired private CaiApiClient caiApiClient; public void callApi() { // 使用 CaiApiClient 进行 API 调用 String response = caiApiClient.getNameByGet("exampleName"); System.out.println("API Response: " + response); } }
其他信息
该版本标志着 cai-api-sdk
项目的首次发布,后续版本将进一步扩展功能,欢迎反馈和贡献。
Initial Release of Cai API SDK
Introduction
This is the first version v0.0.1
of the cai-api-sdk
project. The SDK simplifies integration with third-party APIs and supports operations such as signature verification and user information handling via API calls.
Key Features:
- Spring Boot auto-configuration for quick integration of the API client
- Provides a SHA-256 signature generation feature using the Hutool encryption library
- Basic user entity class for identity representation in API calls
- Supports injecting
accessKey
andsecretKey
from configuration files
Changes
- Initialized project structure, including
CaiApiClient
,SignUtil
, andUser
classes. - Provides basic API client integration and user authentication functionality.
- Added automatic JavaDoc annotations for documentation generation.
Usage
-
Add Maven Dependency
You can include
cai-api-sdk
in your project by adding the following Maven dependency to yourpom.xml
:<dependency> <groupId>com.caiths</groupId> <artifactId>cai-api-sdk</artifactId> <version>0.0.1</version> </dependency>
-
Spring Boot Auto-Configuration
The
cai-api-sdk
is auto-configured with Spring Boot. You just need to provide theaccessKey
andsecretKey
in the configuration file to initialize the API client. Here's a configuration example:# application.properties caiapi.client.accessKey=your-access-key caiapi.client.secretKey=your-secret-key
-
Using the Signature Utility
The
SignUtil
provides an easy way to generate a signature. You can use the following code to generate a signature:import com.caiths.caiapisdk.utils.SignUtil; public class Example { public static void main(String[] args) { String body = "exampleBody"; String secretKey = "yourSecretKey"; String signature = SignUtil.genSign(body, secretKey); System.out.println("Generated Signature: " + signature); } }
-
Using the API Client
The
CaiApiClient
will automatically load the Spring configuration, allowing you to inject and use it wherever needed:import com.caiths.caiapisdk.client.CaiApiClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class ApiService { @Autowired private CaiApiClient caiApiClient; public void callApi() { // Use CaiApiClient to call API String response = caiApiClient.getNameByGet("exampleName"); System.out.println("API Response: " + response); } }
Additional Information
This version marks the first release of the cai-api-sdk
project. Future versions will expand on functionality, and contributions are welcome.