-
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.
- Loading branch information
Showing
1 changed file
with
39 additions
and
2 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,2 +1,39 @@ | ||
# rc-kit | ||
Vapor tool kit for RevenueCat | ||
# RCKit | ||
RCKit is a simple tool kit to add basic RevenueCat support to your Vapor server. | ||
|
||
It currently only supports the [V1 API](https://www.revenuecat.com/reference/subscribers) for getting or creating a subscriber and webhooks. | ||
|
||
PRs welcome :) | ||
|
||
#### Config | ||
|
||
```swift | ||
import RCKit | ||
|
||
public func configure(_ app: Application) throws { | ||
app.revenueCat.configuration = .init(token: "<Your RevenueCat Token>") | ||
} | ||
|
||
``` | ||
|
||
#### Get or Create Subscriber | ||
|
||
```swift | ||
|
||
struct YourEntitlements: Content { | ||
let pro: RCEntitlement? | ||
} | ||
|
||
let subscriber: RCSubscriber<YourEntitlements> = try await req.application.revenueCat.getSubscriber("<userID>") | ||
... | ||
|
||
``` | ||
|
||
#### Webhook | ||
|
||
```swift | ||
func post(_ req: Request) async throws -> HTTPStatus { | ||
let eventBody: RCEventBody = try req.content.decode(RCEventBody.self) | ||
... | ||
} | ||
``` |