skylab/studio

There is no license information available for the latest version (0.0.2) of this package.

studio.skylabtech.ai PHP client

0.0.2 2024-04-25 20:18 UTC

This package is auto-updated.

Last update: 2024-05-01 17:20:10 UTC


README

studio.skylabtech.ai

Installation

composer require skylab/studio

Example usage

Ensure that autoload is configured properly in composer.json

{
  "autoload": {
    "psr-4": {
      "Skylab\\Studio\\": "src/"
    }
  }
}
require './vendor/autoload.php';
use Skylab\Studio\SkylabStudio;

$api = new SkylabStudio('your-api-key');

// CREATE PROFILE
$profilePayload = [
  'name' => 'profile name',
  'enable_crop' => false,
  'enable_retouch' => true
];

$profile = $api->createProfile($profilePayload);

// CREATE JOB
$jobPayload = [
  'name' => 'job name',
  'profile_id' => $profile['id']
];

$job = $api->createJob($jobPayload);

// UPLOAD JOB PHOTO(S)
$filePath = '/path/to/photo';
$api->uploadJobPhoto($filePath, $job['id']);

// QUEUE JOB
$payload = [ 'callback_url' => 'YOUR_CALLBACK_ENDPOINT' ];
$api->queueJob($job['id'], $payload);

// NOTE: Once the job is queued, it will transition to processed and then completed
// We will send a response to the specified callback_url with the output photo download urls

Jobs

List all Jobs

List the last 30 jobs.

$api->listJobs();

Create a Job

$payload = [
  'name' => 'your unique job name',
  'profile_id' => 123
]

$api->createJob($payload);

For all payload options, consult the API documentation.

Get a Job

$api->getJob($jobId);

Get Job by Name

$api->getJobByName($name);

Update a Job

$payload = [
  'name' => 'your updated job name',
  'profile_id' => 123
]

$api->updateJob($jobId, $payload);

For all payload options, consult the API documentation.

Queue Job

$payload = [ 'callback_url' => 'YOUR_CALLBACK_ENDPOINT' ]

$api->queueJob($jobId, $payload);

Jobs in Front

$api->getJobsInFront($jobId);

Delete a Job

$api->deleteJob($jobId);

Cancel a Job

$api->cancelJob($jobId);

Profiles

List all Profiles

$api->listProfiles();

Create a Profile

$api->createProfile([
  'name' => 'My Profile'
]);

For all payload options, consult the API documentation.

Get a Profile

$api->getProfile($profileId);

Update profile

$payload = [
  'name' => 'My updated profile name',
];

$api->updateProfile($profileId, $payload);

For all payload options, consult the API documentation.

Photos

Upload Job Photo

This function handles validating a photo, creating a photo object and uploading it to your job/profile's s3 bucket. If the bucket upload process fails, it retries 3 times and if failures persist, the photo object is deleted.

$api->uploadJobPhoto($photoPath, $jobId);

Returns: { photo: { photoObject }, uploadResponse: bucketUploadResponseStatus }

If upload fails, the photo object is deleted for you. If upload succeeds and you later decide you no longer want to include that image, use delete_photo to remove it.

Get a Photo

$api->getPhoto($photoId);

Delete a Photo

$api->deletePhoto($photoId);

Troubleshooting

General Troubleshooting

  • Enable debug mode
  • Capture the response data and check your logs — often this will have the exact error

Enable Debug Mode

Debug mode prints out the underlying request information as well as the data payload that gets sent to Skylab. You will most likely find this information in your logs. To enable it, simply put true as a parameter when instantiating the API object.

$api = new SkylabStudio("your-api-key", true);

Response Ranges

SkylabTech's API typically sends responses back in these ranges:

  • 2xx – Successful Request
  • 4xx – Failed Request (Client error)
  • 5xx – Failed Request (Server error)

If you're receiving an error in the 400 response range follow these steps:

  • Double check the data and ID's getting passed to Skylab
  • Ensure your API key is correct
  • Log and check the body of the response