Download the PHP package konsulting/justgiving-api-sdk without Composer

On this page you can find all versions of the php package konsulting/justgiving-api-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package justgiving-api-sdk

JustGiving API SDK

Build Status Code Coverage Scrutinizer Code Quality

A PHP SDK for communicating with the JustGiving API. Based on the original SDK by JustGiving and contributors.

Installation

Install via composer:

Quick start

See the JustGiving API documentation for more information.

Usage

Setup

The client requires an authentication object with your JustGiving API credentials. The available classes are:

You may also pass in a PSR-18 HTTP client as the second parameter. If this is not provided (or set to null), a default Guzzle client will be used.

The API base URL and version are set automatically, but may be overridden by passing an associative array with keys root_domain and api_version as the third argument.

For example:

Querying the API

The SDK defines a separate client class for each resource as define by the API documentation, and each of those classes contain methods that correspond to API actions. To get a resource class, call the name of the resource as a property on the $client we built up earlier, for example $client->account or $client->charity. The relevant method is then called on top of that.

Method aliases

The actual methods on the class are named in camelCase and are often shortened from the original API action for brevity. However, there are aliases defined for every resource class so that the API action names may be used to interact with the SDK.

For example, both of these examples will work to get the status of a donation:

Models

Some API actions (e.g. creating or updating resources) require a set of data grouped together in an object. To achieve this, a model class has been defined for each separate occasion when this is necessary, for example Team or JoinTeamRequest. These model classes all extend the parent Model class, which adds some useful functionality.

Data can be added to a model in several ways: it can be passed to the constructor as an array, passed to the fill() method as an array, or each property can be set individually. The fill() method may be used multiple times to set different properties, and will only override existing properties if they are explicitly passed in as an array item.

Custom API requests

The client allows custom requests via the request() method. This takes the HTTP method, the endpoint URI and any request options (e.g. headers). You may also override client options, for example the API version. These overrides will only apply for a single request.

For example, to perform a request to the beta campaign endpoint:

If the endpoint requires a payload, JSON may be passed in as an HTTP option. A more complete example:

Working with responses

The SDK returns an instance of JustGivingApiSdk\Support\Response from each request. This implements the PSR-7 ResponseInterface and so allows access to the full HTTP response received by the client.

Response body

The raw response body can be accessed via

However, the API returns JSON and so this method can prove to be an inefficient way of working with data. If body is accessed as a property on the response, the decoded JSON body is returned.

From here, the response data is represented by arrays or objects of type StdClass which contain the data we want to use.

The response class also allows body properties to be called directly on itself, i.e. the following is also valid:

Errors

The API provides two formats of error message(s): the first is a general error message relating to the whole request (e.g. That email address is already in use), and the second is a list of error messages that relate to problems with specific parts of the request or data, with an identifier and description (e.g. ID: FirstNameNotSpecified, description The FirstName field is required.).

In the API documentation, the former is referred to as being the errorMessage property, and the latter refers to errors contained in Error objects (with properties Error.id and Error.desc).

Errors can be accessed via the errors property of the response object, which presents any errors present in a unified array format of $identifier => $description. If there is a general error, it is given the identifier General and added to the array like any other error. The reason phrase given with the response (accessible via the getReasonPhrase() method) is added to the errors array and given the identifier ReasonPhrase.

For example:

Now, say we correctly created that account and went to create a new account with the same email:

Response helper methods

There are a couple of helper methods on the response to make some API calls and validation easier:


All versions of justgiving-api-sdk with dependencies

PHP Build Version
Package Version
Requires guzzlehttp/guzzle Version ^7.0.1
illuminate/support Version ^5.4 | ^6.0 | ^7.0 | ^8.0
nesbot/carbon Version ^1.22 | ^2.0
psr/http-client Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package konsulting/justgiving-api-sdk contains the following files

Loading the files please wait ....