-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from magicbell/gen-improvements
chore: Improve doc and code generation + ci workflows
- Loading branch information
Showing
419 changed files
with
7,308 additions
and
2,152 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"magicbell-swift-client": patch | ||
--- | ||
|
||
Adjusts generations scripts for documentation and code |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"magicbell-swift-client": patch | ||
--- | ||
|
||
Adds release discussion workflow |
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Release To Discussions | ||
|
||
on: | ||
release: | ||
types: [created, edited, deleted] | ||
|
||
concurrency: release-discussion-action | ||
|
||
jobs: | ||
publish-release-notes: | ||
name: Publish Release Notes | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: publish discussion | ||
uses: magicbell/release-discussion-action@main | ||
with: | ||
repo: magicbell/community | ||
category: changelog | ||
cycle: week | ||
release-prefix: magicbell-swift-clilent | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.BELLA_ACTION_TOKEN }} |
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 |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# MagicBellClient Swift SDK 0.1.0 | ||
|
||
Welcome to the MagicBellClient SDK documentation. This guide will help you get started with integrating and using the MagicBellClient SDK in your project. | ||
|
||
## About the API | ||
|
||
OpenAPI 3.0.3 Specification for MagicBell API. | ||
|
||
## Table of Contents | ||
|
||
- [MagicBellClient Swift SDK 0.1.0](#magicbellclient-swift-sdk-010) | ||
- [About the API](#about-the-api) | ||
- [Table of Contents](#table-of-contents) | ||
- [Setup \& Configuration](#setup--configuration) | ||
- [Supported Language Versions](#supported-language-versions) | ||
- [Installation](#installation) | ||
- [CocoaPods](#cocoapods) | ||
- [Swift Package Manager](#swift-package-manager) | ||
- [Authentication](#authentication) | ||
- [Access Token Authentication](#access-token-authentication) | ||
- [Setting the Access Token](#setting-the-access-token) | ||
- [Sample Usage](#sample-usage) | ||
- [License](#license) | ||
|
||
# Setup & Configuration | ||
|
||
## Supported Language Versions | ||
|
||
This SDK is compatible with the following versions: | ||
|
||
- iOS 13.0+, macOS 15.0+, tvOS 13.0+, watchOS 6.0+, visionOS 1.0+ | ||
- Swift 6.0+ | ||
- Xcode 16+ | ||
|
||
## Installation | ||
|
||
|
||
|
||
### CocoaPods | ||
|
||
If you use [CocoaPods](https://cocoapods.org), place the following within your `Podfile`: | ||
|
||
```ruby | ||
pod 'MagicBellClient', '>=0.1.0' | ||
``` | ||
|
||
**IMPORTANT**: Make sure you specify `use_frameworks!` in your `Podfile`. | ||
|
||
Then, run `pod install`. | ||
|
||
### Swift Package Manager | ||
|
||
To install MagicBell using [Swift Package Manager](https://www.swift.org/package-manager/), add the dependency as follows to your project: | ||
|
||
```swift | ||
dependencies: [ | ||
.package(url: "https://github.com/magicbell/magicbell-swift-client", .upToNextMajor(from: "0.1.0")) | ||
] | ||
``` | ||
|
||
## Authentication | ||
|
||
### Access Token Authentication | ||
|
||
The MagicBell API uses an Access Token for authentication. | ||
|
||
This token must be provided to authenticate your requests to the API. | ||
|
||
#### Setting the Access Token | ||
|
||
When you initialize the SDK, you can set the access token via the `AuthenticationMiddleware`: | ||
|
||
```swift | ||
let authMiddleware = AuthenticationMiddleware(jwtToken: token) | ||
|
||
let client = MagicBellClient.Client( | ||
serverURL: try Servers.Server1.url(), | ||
configuration: .init(dateTranscoder: .iso8601WithFractionalSeconds), | ||
transport: URLSessionTransport(), | ||
middlewares: [authMiddleware]) | ||
``` | ||
|
||
If you need to set or update the access token after initializing the SDK you can create a new Client instance. | ||
|
||
# Sample Usage | ||
|
||
Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint: | ||
|
||
```swift | ||
import Foundation | ||
import MagicBellClient | ||
import OpenAPIURLSession | ||
|
||
let token = "YOUR_ACCESS_TOKEN" | ||
|
||
@main | ||
struct MainApp { | ||
static func main() async throws { | ||
|
||
let client = MagicBellClient.Client( | ||
serverURL: try Servers.Server1.url(), | ||
configuration: .init(dateTranscoder: .iso8601WithFractionalSeconds), | ||
transport: URLSessionTransport(), | ||
middlewares: [AuthenticationMiddleware(jwtToken: token)]) | ||
|
||
let response = try await client.get_mobile_push_apns_tokens(.init()) | ||
|
||
switch response { | ||
case .ok(let okResponse): | ||
let json = try okResponse.body.json | ||
let tokens = json.data | ||
|
||
print("Found \(tokens?.count ?? 0) tokens") | ||
tokens?.forEach({ token in | ||
print("- token: \(token.data.device_token)") | ||
}) | ||
|
||
case .undocumented(let statusCode, _): | ||
print("Undocumented status code: \(statusCode)") | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## License | ||
|
||
This SDK is licensed under the MIT License. | ||
|
||
See the [LICENSE](LICENSE) file for more details. |
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
Oops, something went wrong.