<commit_before># EchoMTG PHP Library

Basic wrapper for the [EchoMTG](http://echomtg.com) REST API to manage Magic: the Gathering card collections, prices, and values. See more information on API developments at [http://echomtg.com/api](http://echomtg.com/api).

This PHP library is currently in development/beta testing and provided as-is.

## Installation

Make sure you have an EchoMTG account (you can register for free). The API does not currently support OAuth so all authentication is done via encrypted posts.

Copy the `api.php` library file into your project and instantiate a new object:

    require 'api.php';

    $echomtg = new EchoPHP( '<EMAIL>', 'password' );
    $echomtg->initSession();

Note: `initSession()` will check to see if your auth token has been saved to your current session; if it isn't, it posts to `/user/auth` to sign in you.

## Usage

This wrapper class is in development, check below for the currently supported api calls.

### Managing Inventory

#### Adding cards to inventory `[POST]`

To add a card individually, use the `addCard()` method:

    $echomtg->addCard( 4797, 1, 1.50, '08-20-2015', 0 );

The only required parameter is the first one, the card's [Mutiverse ID](http://gatherer.wizards.com), i.e., it's ID in Gatherer. You can get this by hand by searching for the card/printing there or using the [MTGJson](http://mtgjson.com) API (or similar services).

The other parameters are quantity, your purchase price, the date of your purchase in mm-dd-yyyy format, and whether the card is foil (1) or not (0).

#### Removing cards from the inventory `[PUT]`

To remove a card by the inventory ID, use `removeCard()`. It only takes the ID of the card in your inventory.

#### Adjusting the acquisition price `[PUT]`

To adjust the acquisition price of a card in inventory, call `adjustAcquiredPrice()`, passing in the card's inventory ID in your inventory and the price you want to set.

#### Toggling foil status `[PUT]`

Set a card in inventory as a foil (1) or not foil (0) by calling `toggleFoil()`, passing in the card's inventory ID and the foil boolean.

#### Adjusting the acquisition date `[PUT]`

To adjust the acquisition date of a card in inventory, call `adjustAcquiredDate()`, passing in the card's inventory ID and the date you want to set in `MM-DD-YYYY` format (`m-d-Y` in PHP `date()` lingo).

### Viewing Inventory

#### Getting the inventory `[POST]`
<commit_msg>Reference call reference, and proper HTTPS link<commit_after># EchoMTG PHP Library
Basic wrapper for the [EchoMTG](https://www.echomtg.com) REST API to manage Magic: the Gathering card collections, prices, and values. See more information on API developments at [https://www.echomtg.com/api](https://www.echomtg.com/api).

This PHP library is currently in development/beta testing and provided as-is.

## Installation

Make sure you have an EchoMTG account (you can register for free). The API does not currently support OAuth so all authentication is done via encrypted posts.

Copy the `api.php` library file into your project and instantiate a new object:

    require 'api.php';

    $echomtg = new EchoPHP( '<EMAIL>', 'password' );
    $echomtg->initSession();

Note: `initSession()` will check to see if your auth token has been saved to your current session; if it isn't, it posts to `/user/auth` to sign in you.

## Usage

This wrapper class is in development, check below for the currently supported api calls.

### Managing Inventory

#### Adding cards to inventory `[POST]`

To add a card individually, use the `addCard()` method:

    $echomtg->addCard( 4797, 1, 1.50, '08-20-2015', 0 );

The only required parameter is the first one, the card's [Mutiverse ID](http://gatherer.wizards.com), i.e., it's ID in Gatherer. There are two ways to get this. First is usings EchoMTG's card reference call, you have to AUTH'd to make this call, https://www.echomtg.com/api/data/card_reference/auth=XXXXXXXXXXXXXXX (available in JSON, XML, or CSV.. full reference in the EchoMTG API), this reference is important because Promo cards do not have a Multiverse ID, but they are assigned them by EchoMTG in this reference. This allows you to add promo cards programmatically. Alternatively you can get Multiverse ID's by hand by searching for the card/printing there or using the [MTGJson](http://mtgjson.com) API (or similar services).

The other parameters are quantity, your purchase price, the date of your purchase in mm-dd-yyyy format, and whether the card is foil (1) or not (0).

#### Removing cards from the inventory `[PUT]`

To remove a card by the inventory ID, use `removeCard()`. It only takes the ID of the card in your inventory.

#### Adjusting the acquisition price `[PUT]`

To adjust the acquisition price of a card in inventory, call `adjustAcquiredPrice()`, passing in the card's inventory ID in your inventory and the price you want to set.

#### Toggling foil status `[PUT]`

Set a card in inventory as a foil (1) or not foil (0) by calling `toggleFoil()`, passing in the card's inventory ID and the foil boolean.

#### Adjusting the acquisition date `[PUT]`

To adjust the acquisition date of a card in inventory, call `adjustAcquiredDate()`, passing in the card's inventory ID and the date you want to set in `MM-DD-YYYY` format (`m-d-Y` in PHP `date()` lingo).

### Viewing Inventory

#### Getting the inventory `[POST]`

{'fraction_non_alphanumeric': 0.0967982129560685, 'fraction_numerical': 0.00781831720029784, 'mean_word_length': 4.330357142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6103916', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1490, 'n_words': 776}