Skip to content

Commit

Permalink
Merge pull request #4 from magicbell/gen-improvements
Browse files Browse the repository at this point in the history
chore: Improve doc and code generation + ci workflows
  • Loading branch information
stigi authored Dec 17, 2024
2 parents b5a4836 + b698e5f commit 9481416
Show file tree
Hide file tree
Showing 419 changed files with 7,308 additions and 2,152 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-paws-marry.md
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
5 changes: 5 additions & 0 deletions .changeset/sixty-flowers-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"magicbell-swift-client": patch
---

Adds release discussion workflow
5 changes: 3 additions & 2 deletions .github/workflows/regen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ jobs:

- name: Build SourceDocs
run: |
git clone https://github.com/stigi/SourceDocs.git --branch xcode16 /tmp/sourcedocs
git clone https://github.com/magicbell/SourceDocs.git --branch magicbell /tmp/sourcedocs
pushd /tmp/sourcedocs
make
make build
cp .build/release/sourcedocs /usr/local/bin
popd
- name: Regen `magicbell-java-client`
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/release-discussion.yml
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 }}
129 changes: 129 additions & 0 deletions README.md
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.
4 changes: 2 additions & 2 deletions Sources/MagicBellClientExample/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import OpenAPIURLSession
let token =
"eyJhbGciOiJSUzI1NiIsImtpZCI6InRyYW5zaWVudCIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2FwaS5tYWdpY2JlbGwuY29tIiwiZXhwIjoxNzM2OTg4NjI3LCJpYXQiOjE3MzQzOTY2MjcsImp0aSI6IjAxOTNkMjE4LTQ4ZmMtNzBhOS04NjEyLTFiMDQ5MGQyMzAxMiIsIlJvbGUiOiJVU0VSIiwiVXNlcktleSI6eyJJRCI6ImNhMGFmOTUyLTU3OGItNDUyNC1iZmQ4LTE0OTc0ZTYzMTE2MyIsIkV4dGVybmFsSUQiOiIiLCJFbWFpbCI6InVsbHJpY2hAbWFnaWNiZWxsLmlvIn0sIlByb2plY3RLZXkiOnsiSUQiOjgzNTcsIk5hbWUiOiJBbmRyb2lkIFNESyIsIkFQSUtleSI6ImNhOTUzNGNiMDAyOTk0NjhhOWM4ODU2ZThiNDFjOWQxNjQzMDEyOWQiLCJXb3Jrc3BhY2VJRCI6MTEyMX19.B7weG_TcmZCiOXElOxCrZBQ4g0tnAq5sZmO0znfm96VuyKpZq1kQZ2bOsK7R7sf2WpeeBuAe1fdtrM-qpYVxJWLs5frDf_TULO8SEZywpN1FvpPKyZeDwY3NCM4vfe-Us8l2h5rRWg1vyzl1zglKNqeKKWaUhsLyzBpwhiYtcVQ"

let fakeDevieToken =
let fakeDeviceToken =
"111051c0ade3a85236dc8aa7f704098230980046e0a06d0ea9af01d749a5def2"

@main
Expand All @@ -23,7 +23,7 @@ struct MainApp {
body: .json(
.init(
app_id: "com.example.app",
device_token: fakeDevieToken,
device_token: fakeDeviceToken,
installation_id: .development)))
let postResponse = try await client.save_mobile_push_apns_token(input)

Expand Down
Loading

0 comments on commit 9481416

Please sign in to comment.