Skip to content

Commit

Permalink
chore: rename package import (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulkr authored Aug 23, 2024
1 parent 0c7e7cc commit 01f1c18
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using [Composer](https://getcomposer.org/).
With composer:

```bash
composer require integration-os/authkit-php
composer require integrationos/authkit-php
```

## Creating a token endpoint
Expand All @@ -22,15 +22,15 @@ curl or Postman by making a POST request to http://yourserver.com/endpoint.php.

require "vendor/autoload.php";

use IntegrationOS\AuthKit\AuthKit;
use IntegrationOS\AuthKitToken\AuthKitToken;

$authkit = new AuthKit("sk_live_12345");
$response = $authkit->create([
"group" => "meaningful-id", // a meaningful identifier (i.e., organizationId)
"label" => "Friendly Label", // a human-friendly label (i.e., organizationName)
$authKitToken = new AuthKitToken("sk_live_12345");
$token = $authKitToken->create([
"group" => "org_123", // a meaningful identifier (i.e., organizationId)
"label" => "Acme", // a human-friendly label (i.e., organizationName)
]);

echo json_encode($response);
echo json_encode($token);
```

Or if you're using Laravel, you can define a route like below:
Expand All @@ -39,24 +39,24 @@ Or if you're using Laravel, you can define a route like below:
<?php

use Illuminate\Support\Facades\Route;
use IntegrationOS\AuthKit\AuthKit;
use IntegrationOS\AuthKitToken\AuthKitToken;

Route::get('/create-embed-token', function () {
$authkit = new AuthKit("sk_live_12345");
Route::get('/authkit-token', function () {
$authKitToken = new AuthKitToken("sk_live_12345");

$response = $authkit->create([
"group" => "meaningful-id", // a meaningful identifier (i.e., organizationId)
"label" => "Friendly Label", // a human-friendly label (i.e., organizationName)
$token = $authKitToken->create([
"group" => "org_123", // a meaningful identifier (i.e., organizationId)
"label" => "Acme", // a human-friendly label (i.e., organizationName)
]);

return $response;
return $token;
});
```

You'll want to switch out the API Key for your own, which will later tell your frontend which integrations you'd like to
make available to your users.

You'll also want to populate the `Group` and `Label` fields depending on how you want to organize and query your users'
You'll also want to populate the `group` and `label` fields depending on how you want to organize and query your users'
connected accounts. The Group is especially important as it's used to generate the
unique [Connection Key](https://docs.integrationos.com/docs/setup) for the user once they successfully connect an
account.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "integrationos/authkit-php",
"version": "1.2.0",
"version": "1.2.1",
"type": "library",
"autoload": {
"psr-4": {
"IntegrationOS\\AuthKit\\": "src/"
"IntegrationOS\\AuthKitToken\\": "src/"
}
},
"authors": [
Expand Down
12 changes: 3 additions & 9 deletions src/AuthKit.php → src/AuthKitToken.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace IntegrationOS\AuthKit;
namespace IntegrationOS\AuthKitToken;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;

class AuthKit
class AuthKitToken
{
private string $secret;
private array $configs;
Expand All @@ -22,16 +22,10 @@ private function getUrl(string $type): string
{
$services_url = $this->configs["base_url"] ?? "https://api.integrationos.com";

$api_url = str_contains($services_url, "localhost")
? "http://localhost:3005"
: (str_contains($services_url, "development")
? "https://development-api.integrationos.com"
: "https://api.integrationos.com");

return match ($type) {
"get_settings" => "$services_url/internal/v1/settings/get",
"create_event_link" => "$services_url/internal/v1/event-links/create",
"get_connection_definitions" => "$api_url/v1/public/connection-definitions?limit=100",
"get_connection_definitions" => "$services_url/v1/public/connection-definitions?limit=100",
"create_embed_token" => "$services_url/internal/v1/embed-tokens/create",
"get_session_id" => "$services_url/v1/public/generate-id/session_id",
};
Expand Down

0 comments on commit 01f1c18

Please sign in to comment.