-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
423 additions
and
801 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,104 @@ | ||
# Go FastOTP | ||
# Weavy Chat GO Lang SDK | ||
|
||
FastOTP is a Go library for interacting with the FastOTP API to generate one-time passwords (OTPs) easily. | ||
This library provides a Go client for interacting with the Weavy Chat API. It allows you to create applications, manage users, issue access tokens, and perform various operations within the Weavy Chat ecosystem. | ||
|
||
## Installation | ||
|
||
To install the library, use `go get`: | ||
|
||
```bash | ||
go get -u github.com/CeoFred/[email protected] | ||
go get github.com/CeoFred/weavychat | ||
``` | ||
|
||
## Usage | ||
|
||
### Basic Example | ||
```go | ||
import "github.com/CeoFred/weavychat" | ||
``` | ||
|
||
## Documentation | ||
This library currently supports the following Weavy Chat API methods: | ||
|
||
`NewWeavyServer`: Creates a new WeavyServer instance. | ||
`NewApp`: Creates a new app. | ||
`GetApp`: Retrieves an existing app. | ||
`NewUser`: Creates a new user. | ||
`AddUserToApp`: Adds users to an app. | ||
`RemoveUserFromApp`: Removes users from an app. | ||
`AppInit`: Initializes an app. | ||
`GetAccessToken`: Issues an access token for a user. | ||
|
||
## Authentication | ||
|
||
You need to provide the server URL and API key to authenticate with the Weavy Chat API. | ||
|
||
```go | ||
weavyServer := weavychat.NewWeavyServer("your-weavy-server-url", "your-api-key") | ||
``` | ||
|
||
## Creating Applications | ||
|
||
You can create applications using the `NewApp` method: | ||
|
||
```go | ||
appRequest := &weavychat.AppRequest{ | ||
ID: 1, | ||
Type: weavychat.AppType("your-app-type"), | ||
UID: "your-uid", | ||
DisplayName: "Your App", | ||
Metadata: weavychat.Metadata{}, | ||
Tags: []string{"tag1", "tag2"}, | ||
} | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/CeoFred/fast-otp" | ||
) | ||
|
||
func main() { | ||
// Replace "your_api_key" with your actual FastOTP API key | ||
apiKey := "your_api_key" | ||
|
||
// Create an instance of FastOtp | ||
client := fastotp.NewFastOTP(apiKey) | ||
|
||
// Create context for library functions | ||
ctx := context.Background() | ||
|
||
// Define OTP generation payload | ||
payload := fastotp.GenerateOTPPayload{ | ||
Delivery: OtpDelivery{ | ||
"email": "[email protected]", | ||
}, | ||
Identifier: "user123", | ||
TokenLength: 6, | ||
Type: "numeric", | ||
Validity: 120, | ||
} | ||
|
||
// Generate OTP | ||
otp, err := client.GenerateOTP(ctx, payload) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
fmt.Printf("Generated OTP: %s\n", otp) | ||
|
||
// Validate OTP | ||
otp, err = client.ValidateOTP( | ||
ctx, | ||
ValidateOTPPayload{ | ||
Identifier: "user123", | ||
Token: "123456", | ||
} | ||
) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
fmt.Printf("Otp validation status: %s\n", otp.Status) | ||
app, err := weavyServer.NewApp(context.Background(), appRequest) | ||
if err != nil { | ||
// Handle error | ||
} | ||
``` | ||
|
||
## API Documentation | ||
## Managing Users | ||
|
||
For detailed information about the FastOTP API and available endpoints, refer to the [official API documentation](https://api.fastotp.co/docs). | ||
You can create new users using the `NewUser` method: | ||
|
||
## Configuration | ||
```go | ||
user := &weavychat.User{ | ||
UID: "user-uid", | ||
Email: "[email protected]", | ||
GivenName: "John", | ||
MiddleName: "Doe", | ||
Name: "John Doe", | ||
FamilyName: "Doe", | ||
Nickname: "JD", | ||
PhoneNumber: "+1234567890", | ||
Comment: "A new user", | ||
Picture: "user-avatar-url", | ||
Directory: "directory-id", | ||
Metadata: weavychat.Metadata{}, | ||
Tags: []string{"tag1", "tag2"}, | ||
IsSuspended: false, | ||
} | ||
|
||
- `APIKey`: Your FastOTP API key. | ||
newUser, err := weavyServer.NewUser(context.Background(), user) | ||
if err != nil { | ||
// Handle error | ||
} | ||
``` | ||
|
||
## Contributing | ||
## Access Tokens | ||
|
||
If you'd like to contribute to this project, please follow the guidelines in [CONTRIBUTING.md](CONTRIBUTING.md). | ||
You can issue access tokens for users: | ||
|
||
## License | ||
```go | ||
accessToken, err := weavyServer.GetAccessToken(context.Background(), "user-uid", 3600) | ||
if err != nil { | ||
// Handle error | ||
} | ||
``` | ||
|
||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. | ||
## Contributing | ||
|
||
Contributions are welcome! If you find any issues or have suggestions for improvement, please create an issue or a pull request on GitHub. | ||
|
||
## Acknowledgments | ||
## License | ||
|
||
- Thanks to the FastOTP team for providing the awesome OTP generation service. | ||
This library is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.