2017 © Pedro Peláez
 

library alegra-php

Alegra PHP Library

image

loduis/alegra-php

Alegra PHP Library

  • Saturday, October 21, 2017
  • by loduis
  • Repository
  • 1 Watchers
  • 3 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 32 Versions
  • 0 % Grown

The README.md

Alegra PHP bindings

You can sign up for a Alegra account at http://www.alegra.com/., (*1)

Requirements

PHP 5.6.11 and later., (*2)

Composer

You can install the bindings via Composer. Run the following command:, (*3)

composer require "loduis/alegra-php:@dev"

To use the bindings, use Composer's autoload:, (*4)

require_once('vendor/autoload.php');

Dependencies

The bindings require the following extension in order to work properly:, (*5)

  • curl, although you can use your own non-cURL client if you prefer
  • json
  • mbstring (Multibyte String)

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available., (*6)

Getting Started

Any resource containts five main methods (all, get, create, save, delete), (*7)

Simple usage looks like:, (*8)

Your composer.json file, (*9)

{
    "minimum-stability": "dev",
    "prefer-stable": true,
    "require": {
        "loduis/alegra-php": "1.0.*"
    }
}

Your test.php script, (*10)

<?php

require './vendor/autoload.php';

Alegra\Api::auth('Your user', 'Your api token');
// Also you can auth api with your app credentials
/*
Alegra\Api::auth([
    'username' => 'Your user',
    'password' => 'Your password'
]);
*/

Create an new resource, (*11)

$contact = Alegra\Contact::create(['name' => 'Your contact name']);
print_r($contact);

// Create using save

$contact = new Alegra\Contact;
$contact->name = 'My second contact';
$contact->save(); // Update the contact
print_r($contact);

Get an existing resource, (*12)

$contact = Alegra\Contact::get(100); // where 100 is the id of resource.
$contact->identification = '900.123.123-8';
$contact->email = 'email@server.com';
$contact->save();
print_r($contact);

Save an resource without fetch your data, (*13)


$contact = new Alegra\Contact(100); $contact->email = 'user@server.com'; $contact->save();

Get all resources, (*14)

$contacts = Alegra\Contact::all();
$contacts->each(function ($contact) {
    print_r($contact);
});

// $contacts is instanceof Illuminate\Support\Collection
// You can use methods like
print_r($contacts->slice(0, 3)); // The three first contacts.

Delete an resource, (*15)

// Get a delete

Alegra\Contact::get(1)->delete();

// Delete without fetch data

(new Alegra\Contact(1))->delete();

// Delete using static interface

Alegra\Contact::delete(1);

Catch errors, (*16)

try {
    // Your request code
}

// Exception when a client error is encountered (4xx codes)

catch (GuzzleHttp\Exception\ClientException $e) {
    // code
}

// Exception when a server error is encountered (5xx codes)

catch (GuzzleHttp\Exception\ServerException $e) {
    // code
}

// Exception thrown when a connection cannot be established.

catch (GuzzleHttp\Exception\ConnectException $e) {
    // code
}

// Other exceptions

catch (Exception $e) {
    // code
}

Documentation

Please see http://developer.alegra.com/docs for up-to-date documentation., (*17)

The Versions

21/10 2017

dev-master

9999999-dev http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra

21/10 2017

v0.25.1

0.25.1.0 http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra

21/10 2017

v0.25.0

0.25.0.0 http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra

16/10 2017

v0.24.0

0.24.0.0 http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra

09/10 2017

v0.23.1

0.23.1.0 http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra

08/10 2017

v0.23.0

0.23.0.0 http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra

08/10 2017

v0.22.0

0.22.0.0 http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra

23/04 2017

v0.21.1

0.21.1.0 http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra

18/03 2017

v0.21.0

0.21.0.0 http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra

18/03 2017

v0.20.0

0.20.0.0 http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra

18/03 2017

v0.19.0

0.19.0.0 http://developer.alegra.com

Alegra PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Loduis Madariaga

api alegra