boundstate/petfinder-php

Petfinder API client

v1.1.0 2022-02-28 20:03 UTC

This package is auto-updated.

Last update: 2024-04-29 00:47:17 UTC


README

CircleCI packagist version Coverage Status

A simple wrapper for the Petfinder API, written in PHP.

Uses Petfinder API v2.

Features

  • Uses HTTPlug
  • Supports Async requests
  • Well tested

Requirements

Install

In addition to the Petfinder package, you'll need an HTTPlug client that support async requests. We recommend using php-http/guzzle6-adapter, but you are free to use whatever one works for you.

composer require petfinder-com/petfinder-php php-http/guzzle6-adapter

Usage

Basic usage

$client = new \Petfinder\Client('my-api-key', 'my-api-secret');

$client->animal->search(['type' => 'Dog']);

Using async requests

$client = new \Petfinder\Client('my-api-key', 'my-api-secret');

$client->organization->searchAsync()->then(function (\Petfinder\Result $result) {
    // Do something with $result
})->catch(function (\Petfinder\Exception\ProblemDetailsException $exception) {
    // Do something with $exception
});

Using a custom Httplug client

$builder = new \Petfinder\Http\Builder($myHttpClient);
$client = new \Petfinder\Client('my-api-key', 'my-api-secret', $builder);