Skip to content

Commit c132a3f

Browse files
Merge pull request #1 from openapi/upkeep
chore: init quality maintenance
2 parents c771d8f + ae8371f commit c132a3f

15 files changed

Lines changed: 568 additions & 35 deletions

.github/REPOINFO.txt

Whitespace-only changes.

.github/assets/repo-header-a3.png

113 KB
Loading

.github/assets/repo-header-a3.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Image Description Sheet
2+
-----------------------
3+
4+
File Name: repo-header-a3.png
5+
Format: PNG
6+
Dimensions: 830 x 173 pixels
7+
8+
Short Description:
9+
A banner image featuring the word "Rust" on the left, Rust code snippet in the background,
10+
and the Openapi logo on the right.
11+
12+
Purpose:
13+
This image is intended to be used as a header/banner for documentation or repository README.
14+
It visually associates Rust programming language with the Openapi SDK/client,
15+
giving a professional and modern look to the project materials.

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# IDE files
2+
.idea/
3+
.vscode/
4+
15
# Generated by Cargo
26
# will have compiled files and executables
37
debug/
@@ -13,4 +17,6 @@ Cargo.lock
1317
# MSVC Windows builds of rustc generate these, which store debugging information
1418
*.pdb
1519

16-
main.rs
20+
# Project files
21+
main.rs
22+
.env

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
[package]
2-
name = "openapi_client"
3-
version = "0.1.0"
2+
name = "openapi-sdk"
3+
version = "0.1.1"
4+
authors = ["Michael Cuffaro (@maiku1008)", "Openapi® <hello@openapi.com>"]
45
edition = "2021"
6+
description = "A fully-featured and blazing-fast Rust API client to interact with Openapi®"
7+
license = "MIT"
8+
categories = ["api-bindings", "web-programming", "asynchronous", "authentication", "development-tools"]
9+
documentation = "https://console.openapi.com/"
10+
homepage = "https://openapi.com/"
11+
keywords = ["openapi", "sdk", "client"]
12+
readme = "docs/crates-io.md"
13+
repository = "https://github.com/openapi/openapi-rust-sdk"
514

615
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
716

@@ -11,4 +20,4 @@ serde = { version = "1.0", features = ["derive"] }
1120
base64 = "0.13.0"
1221
http = "0.2.9"
1322
tokio = {version="1.28.1", features = ["rt", "macros"]}
14-
serde_json = "1.0"
23+
serde_json = "1.0"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Openapi S.r.l.
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.

Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!make
2+
3+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
4+
# #
5+
# ____ _ #
6+
# / __ \____ ___ ____ ____ _____ (_) ® #
7+
# / / / / __ \/ _ \/ __ \/ __ `/ __ \/ / #
8+
# / /_/ / /_/ / __/ / / / /_/ / /_/ / / #
9+
# \____/ .___/\___/_/ /_/\__,_/ .___/_/ #
10+
# /_/ /_/ #
11+
# #
12+
# The Largest Certified API Marketplace #
13+
# Accelerate Digital Transformation • Simplify Processes • Lead Industry #
14+
# #
15+
# ═══════════════════════════════════════════════════════════════════════ #
16+
# #
17+
# Project: openapi-rust-sdk #
18+
# Version: 0.1.0 #
19+
# Author: Michael Cuffaro (@maiku1008) #
20+
# Copyright: (c) 2025 Openapi®. All rights reserved. #
21+
# License: MIT #
22+
# Maintainer: Francesco Bianco #
23+
# Contact: https://openapi.com/ #
24+
# Repository: [Repository URL] #
25+
# Documentation: [Docs URL] #
26+
# #
27+
# ═══════════════════════════════════════════════════════════════════════ #
28+
# #
29+
# "Truth lies at the source of the stream." #
30+
# — English Proverb #
31+
# #
32+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
33+
34+
35+
## ====================
36+
## Development Commands
37+
## ====================
38+
39+
dev-push:
40+
@git config credential.helper 'cache --timeout=3600'
41+
@git add .
42+
@git commit -m "$$(read -p 'Commit message: ' msg; echo $$msg)" || true
43+
@git push
44+
45+
dev-version:
46+
@grep '^version' Cargo.toml | head -n1 | cut -d '"' -f2
47+
48+
## ==================
49+
## Packaging Commands
50+
## ==================
51+
52+
publish:
53+
@git add .
54+
@git commit -m "Update release $$(make -s dev-version)" || true
55+
@git push
56+
@cargo login
57+
@cargo publish

README.md

Lines changed: 117 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,58 @@
1+
<div align="center">
2+
<a href="https://openapi.com/">
3+
<img alt="Openapi SDK for Rust" src=".github/assets/repo-header-a3.png" >
4+
</a>
15

2-
# OpenApi IT Rust Client
6+
<h1>Openapi® client for Rust</h1>
7+
<h4>The perfect starting point to integrate <a href="https://openapi.com/">Openapi®</a> within your Rust project</h4>
38

4-
This client is used to interact with the API found at [openapi.it](https://openapi.it/)
9+
[![Build Status](https://img.shields.io/github/actions/workflow/status/<username>/<repo>/rust.yml?branch=main)](https://github.com/<username>/<repo>/actions)
10+
[![Crates.io](https://img.shields.io/crates/v/<crate_name>.svg)](https://crates.io/crates/<crate_name>)
11+
[![Docs.rs](https://img.shields.io/docsrs/<crate_name>)](https://docs.rs/<crate_name>)
12+
[![License](https://img.shields.io/github/license/<username>/<repo>)](LICENSE)
13+
[![Rust Version](https://img.shields.io/badge/rust-1.80+-orange.svg)](https://www.rust-lang.org/)
14+
</div>
15+
16+
## Overview
17+
18+
This client provides an idiomatic Rust interface to the APIs available at [Openapi](https://openapi.com).
19+
It simplifies integration with the Openapi Marketplace, offering typed requests, async support, and built-in error handling.
20+
With this SDK you can quickly connect to hundreds of certified APIs and accelerate your digital transformation projects.
521

622
## Pre-requisites
723

8-
Before using the OpenApi IT Rust Client, you will need an account at [openapi.it](https://openapi.it/) and an API key to the sandbox and/or production environment
24+
Before using the Openapi Rust Client, you will need an account at [Openapi](https://console.openapi.com/) and an API key to the sandbox and/or production environment
25+
26+
## What you can do
27+
28+
With the Openapi Rust Client, you can easily interact with a variety of services in the Openapi Marketplace. For example, you can:
29+
30+
- 📩 **Send SMS messages** with delivery reports and custom sender IDs
31+
- 💸 **Process bills and payments** in real time via API
32+
- 🧾 **Send electronic invoices** securely to the Italian Revenue Agency
33+
- 📄 **Generate PDFs** from HTML content, including JavaScript rendering
34+
- ✉️ **Manage certified emails** and legal communications via Italian Legalmail
35+
36+
For a complete list of all available services, check out the [Openapi Marketplace](https://console.openapi.com/) 🌐
937

1038
## Installation
1139

12-
You can add the OpenApi IT Rust Client to your project with the following command:
40+
You can add the Openapi Rust Client to your project with the following command:
1341

1442
```bash
15-
cargo add openapiit-cli-rust
43+
cargo add openapi-sdk
1644
```
1745

1846
## Usage
1947

20-
```rust
21-
use std::collections::HashMap;
48+
The client has two main operational modes:
49+
50+
### 1. Token Generation (OAuth Client)
51+
52+
Use the `OauthClient` to generate access tokens for API access:
2253

23-
use openapi_client::{Client, OauthClient};
54+
```rust
55+
use openapi_sdk::OauthClient;
2456
use serde::{Deserialize, Serialize};
2557

2658
#[derive(Debug, Serialize, Deserialize)]
@@ -30,9 +62,8 @@ struct TokenResponse {
3062

3163
#[tokio::main]
3264
async fn main() -> Result<(), Box<dyn std::error::Error>> {
33-
// Initialize the oauthclient
34-
let oauth_client =
35-
OauthClient::new("<your_username>", "<your_apikey>", true).unwrap();
65+
// Initialize the OAuth client
66+
let oauth_client = OauthClient::new("<your_username>", "<your_apikey>", true)?;
3667

3768
// Create a token for a list of scopes
3869
let scopes = vec![
@@ -44,18 +75,36 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
4475

4576
// The string response can be parsed into a custom object
4677
let resp: TokenResponse = serde_json::from_str(&result)?;
47-
let token = resp.token;
78+
println!("Generated token: {}", resp.token);
79+
80+
// Delete the token when done
81+
let _result = oauth_client.delete_token(resp.token).await?;
82+
83+
Ok(())
84+
}
85+
```
86+
87+
### 2. API Calls (Using Access Tokens)
88+
89+
Use the `Client` to make API calls with your access tokens:
90+
91+
```rust
92+
use openapi_sdk::Client;
93+
use serde::Serialize;
94+
use std::collections::HashMap;
4895

49-
// Initialize the client
50-
let client = Client::new(token.clone()).unwrap();
96+
#[tokio::main]
97+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
98+
// Initialize the client with your access token
99+
let client = Client::new("<your_access_token>".to_string())?;
51100

52-
// Make a request with Params
101+
// Make a request with parameters
53102
let mut params = HashMap::new();
54103
params.insert("denominazione", "altravia");
55104
params.insert("provincia", "RM");
56105
params.insert("codice_ateco", "6201");
57106

58-
let _result = client
107+
let result = client
59108
.request::<serde_json::Value>(
60109
"GET",
61110
"https://test.imprese.openapi.it/advance",
@@ -64,7 +113,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
64113
)
65114
.await?;
66115

67-
// Make a request with a payload, a nested json
116+
println!("API Response: {}", result);
117+
118+
// Make a request with a JSON payload
68119
#[derive(Serialize)]
69120
struct Query {
70121
country_code: String,
@@ -79,9 +130,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
79130
let query = Query {
80131
country_code: "IT".to_string(),
81132
};
82-
let payload = Payload { limit: 0, query };
133+
let payload = Payload { limit: 10, query };
83134

84-
let _result = client
135+
let result = client
85136
.request(
86137
"POST",
87138
"https://test.postontarget.com/fields/country",
@@ -90,28 +141,66 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
90141
)
91142
.await?;
92143

93-
// Delete the token
94-
let _result = oauth_client.delete_token(token).await?;
144+
println!("POST Response: {}", result);
95145

96146
Ok(())
97147
}
98148
```
99149

150+
## Examples
151+
152+
You can find complete examples in the `examples/` directory:
153+
154+
- `examples/token_generation.rs` - Token generation example
155+
- `examples/api_calls.rs` - API calls example
156+
157+
Run examples with:
158+
```bash
159+
cargo run --example token_generation
160+
cargo run --example api_calls
161+
```
162+
163+
## Testing
164+
165+
Run tests with:
166+
```bash
167+
cargo test
168+
```
169+
100170
## Contributing
101171

102-
Contributions are always welcome!
172+
Contributions are always welcome! Whether you want to report bugs, suggest new features, improve documentation, or contribute code, your help is appreciated.
173+
174+
See [docs/contributing.md](docs/contributing.md) for detailed instructions on how to get started. Please make sure to follow this project's [docs/code-of-conduct.md](docs/code-of-conduct.md) to help maintain a welcoming and collaborative environment.
103175

104-
See `contributing.md` for ways to get started.
176+
## Authors
177+
178+
Meet the project authors:
179+
180+
- Michael Cuffaro ([@maiku1008](https://www.github.com/maiku1008))
181+
- Openapi Team ([@openapi-it](https://github.com/openapi-it))
105182

106-
Please adhere to this project's `code of conduct`.
183+
## Partners
107184

185+
Meet our partners using Openapi or contributing to this SDK:
186+
187+
- [Blank](https://www.blank.app/)
188+
- [Credit Safe](https://www.creditsafe.com/)
189+
- [Deliveroo](https://deliveroo.it/)
190+
- [Gruppo MOL](https://molgroupitaly.it/it/)
191+
- [Jakala](https://www.jakala.com/)
192+
- [Octotelematics](https://www.octotelematics.com/)
193+
- [OTOQI](https://otoqi.com/)
194+
- [PWC](https://www.pwc.com/)
195+
- [QOMODO S.R.L.](https://www.qomodo.me/)
196+
- [SOUNDREEF S.P.A.](https://www.soundreef.com/)
108197

109198
## License
110199

111-
[MIT](https://choosealicense.com/licenses/mit/)
200+
This project is licensed under the [MIT License](LICENSE).
112201

202+
The MIT License is a permissive open-source license that allows you to freely use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, provided that the original copyright notice and this permission notice are included in all copies or substantial portions of the software.
113203

114-
## Authors
204+
In short, you are free to use this SDK in your personal, academic, or commercial projects, with minimal restrictions. The project is provided "as-is", without any warranty of any kind, either expressed or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement.
115205

116-
- [@maiku1008](https://www.github.com/maiku1008)
117-
- [@openapi-it](https://github.com/openapi-it)
206+
For more details, see the full license text at the [MIT License page](https://choosealicense.com/licenses/mit/).

0 commit comments

Comments
 (0)