https://github.com/permitio/permit-ruby
https://github.com/permitio/permit-ruby
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/permitio/permit-ruby
- Owner: permitio
- License: apache-2.0
- Created: 2023-01-31T13:10:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-09T11:11:10.000Z (over 1 year ago)
- Last Synced: 2025-05-11T07:12:30.987Z (about 1 year ago)
- Language: Ruby
- Size: 1.16 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# Permit.io Ruby SDK
Instructions for installing Ruby SDK for interacting with Permit.io.
## Overview
This guide will walk you through the steps of installing the Permit.io Ruby SDK and integrating it into your code.
## Installation
Install the SDK using the following command:
```shell
gem install permit-sdk
```
Put the package under your project folder and add the following in import:
```ruby
require "permit-sdk"
```
## Usage
### Init the SDK
To init the SDK, you need to create a new Permit client with the API key you got from the Permit.io dashboard.
First we will create a new Config object so we can pass it to the Permit client.
Second, we will create a new Permit client with the Config object we created.
```ruby
require "permit-sdk"
permit = Permit.new('token')
```
### Check for permissions
To check permissions using our `Permit.check()` method.
Follow the example below:
```ruby
require 'permit-sdk'
permit = Permit.new("TOKEN")
user = { id: "user@mail.io", first_name: "User", last_name: "Doe", email: "user@mail.io" }
permitted = permit.check(user.id, "create", "Blog_Post")
if permitted
# permit user to create blog post
else
# deny user to create blog post
end
```
### Sync users
To sync users to the Permit.io API, using the `Permit.sync_user()` method.
Follow the example below:
```ruby
require 'permit-sdk'
permit = Permit.new("TOKEN")
user = permit.sync_user({ key: "new_user_key", email: "user@mail.com", first_name: "User", last_name: "Doe" })
```