Terminal
Set up
Set the SDK up
Publish the config, write the site’s URL, API key and signing secret to.env, and check the site:
Terminal
composer require, and again whenever you want to point the app at a
new key with the key in .env.
It publishes config/fetchski-attract.php, asks for the site’s slug, URL, API key and the key’s
signing secret (leave it empty for a token-only key), writes FETCHSKI_ATTRACT_SITE, _URL,
_API_KEY and _SIGNING_SECRET to .env (and empty ones to .env.example, when the app has one),
then runs the check. With no secret, a FETCHSKI_ATTRACT_SIGNING_SECRET left in
.env by an earlier key is removed.
In a script
Key in the database
--database it publishes the config and the attract_api_keys migration, sets
FETCHSKI_ATTRACT_SITES_FROM=database, asks before running the migrations, then
stores the key. The key never goes to .env
(Key in the database).
Store or replace the key
Store the site’s API key and signing secret in theattract_api_keys table, encrypted, or replace
the ones stored there:
Terminal
Replaced the API key for acme…). Before asking anything it checks the table exists and that the SDK reads keys from it, and
says what to run when not.
In a script
Rotate the key
Swap a stored site’s API key and signing secret for new ones, keeping its row and URL:Terminal
One of several sites
In a script
Terminal
Forget the key
Delete a site’s key from theattract_api_keys table, asking first:
Terminal
One of several sites
In a script
Work with the methods
List the methods
List every method the SDK offers, with its key, HTTP route and purpose:Terminal
One accessor
As JSON
Call a method
Call one method on the real site and print its answer as JSON:Terminal
name=value: numbers and true / false are cast, lists and objects are JSON, the
rest is taken as written. A write asks first. The full guide, with every argument type and worked examples, is
Call any method from the terminal.
Drafts too
A write, without asking
Write an Action
Write an Action for one method, and its test:Terminal
app/Actions/Attract/GetBlog.php, an invokable Action that makes the one call, and its
test in tests/Feature/Actions/Attract/ (Pest when the app has Pest). With no method it lets you
search them all.
Search for the method
Into a module
modules/Blog/Actions/Attract/ and its
Tests/Feature/Actions/Attract/. With FETCHSKI_ATTRACT_MODULE set, that is where every Action goes,
with no option. The module’s folder must exist.
Check a site
Check the setup
Check the config, that the site answers, that the key is accepted, and the clock:Terminal
Another site
Sweep every read
Call every read the site offers and report each as ok, refused or broken:Terminal
Publish what you want to change
The config
The attract_api_keys migration
The stubs
stubs/ (the Action and its tests); the Action command uses your copies from then
on.