Skip to content

Commit

Permalink
Update README for the incompatible changes coming for the 3.x branch
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosp committed Nov 27, 2024
1 parent 2abf63f commit 1c81c26
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Includes changes from the following forks:
- [maxlipsky-ca/PHRETS-PHP8](https://github.com/maxlipsky-ca/PHRETS-PHP8)
- [ocusellinc/PHRETS](https://github.com/ocusellinc/PHRETS)

## Compability
It should be a drop-in replacement for troydavisson/PHRETS with the following exceptions:

1. No support for PHP versions before 8.2.
2. RETS version is now an enum and can only be set in the constructor of the Configuration.
3. The client, cookie jar and logger can only be set in the constructor of the Session.

PHRETS
======
Expand All @@ -19,25 +25,27 @@ PHP client library for interacting with a RETS server to pull real estate listin

```php
<?php
require_once("vendor/autoload.php");

date_default_timezone_set('America/New_York');
use PHRETS\Configuration;
use PHRETS\Enums\RETSVersion;
use PHRETS\Session;

require_once("vendor/autoload.php");
date_default_timezone_set('America/New_York');

$config = new \PHRETS\Configuration;
$config = new Configuration(version: RETSVersion::VERSION_1_7_2);
$config->setLoginUrl('rets login url here')
->setUsername('rets username here')
->setPassword('rets password here')
->setRetsVersion('1.7.2');
->setPassword('rets password here');

$rets = new \PHRETS\Session($config);
$rets = new Session($config);

// If you're using Monolog already for logging, you can pass that logging instance to PHRETS for some additional
// If you're using Monolog or any other PSR-3 logger, you can pass it to PHRETS for some additional
// insight into what PHRETS is doing.
//
// $log = new \Monolog\Logger('PHRETS');
// $log->pushHandler(new \Monolog\Handler\StreamHandler('php://stdout', \Monolog\Logger::DEBUG));
// $rets->setLogger($log);
// $rets = new Session($config, logger: $log);

$connect = $rets->Login();

Expand Down Expand Up @@ -73,11 +81,10 @@ PHRETS provides PHP developers a way to integrate RETS functionality directly wi
* HTTP Header management
* Authentication
* Session/Cookie management
* PHP 8.2+ supported

### Installation

The easiest way to get started is using [Composer](http://getcomposer.org) to install
The easiest way to get started is using [Composer](http://getcomposer.org) to install

```js
{
Expand All @@ -88,15 +95,15 @@ The easiest way to get started is using [Composer](http://getcomposer.org) to in
}
],
"require": {
"qoboltd/phrets": "^2.0"
"qoboltd/phrets": "^3.0"
}
}
```

### Get Help
Please use the GitHub's issue tracker for bugs/suggestions.

### Disclaimer
### Disclaimer
In many cases, the capabilities provided by this library are dependent on these features being properly implemented by the RETS server you're accessing. The RETS specification defines how clients and servers communicate, and if a server is doing something unexpected, this library may not work without tweaking some options.

## Documentation
Expand All @@ -105,17 +112,16 @@ In many cases, the capabilities provided by this library are dependent on these

The first step with getting connected to a RETS server is to configure the connection.

```php
$config = new \PHRETS\Configuration;
```php\
$config = new \PHRETS\Configuration(version: \PHRETS\Enums\RETSVersion::VERSION_1_7_2);
$config->setLoginUrl($rets_login_url);
$config->setUsername($rets_username);
$config->setPassword($rets_password);
// optional. value shown below are the defaults used when not overridden
$config->setRetsVersion('1.7.2'); // see constants from \PHRETS\Versions\RETSVersion
$config->setUserAgent('PHRETS/2.0');
$config->setUserAgentPassword($rets_user_agent_password); // string password, if given
$config->setHttpAuthenticationMethod('digest'); // or 'basic' if required
$config->setHttpAuthenticationMethod('digest'); // or 'basic' if required
$config->setOption('use_post_method', false); // boolean
$config->setOption('disable_follow_location', false); // boolean
```
Expand Down Expand Up @@ -228,11 +234,8 @@ $results->last();
// returns an array representing the collected values from the identified field
$all_ids = $results->lists('ListingID');

// export the results in CSV format
$results->toCSV();

// export the results in JSON format
$results->toJSON();
json_encode($results);

// export the results in a simple array format
$results->toArray();
Expand All @@ -244,29 +247,30 @@ Because each $record is an object, some helper methods exist:
$record->isRestricted('Address'); // determine if the RETS server blocked this value
$record->getFields(); // return an array of the field names associated with this record
$record->toArray(); // returns a true PHP array of the given record
$record->toJson(); // returns a JSON encoded string representing the record
json_encode($record); // returns a JSON encoded string representing the record
$record->getResource(); // returns the RETS Resource responsible for this record
$record->getClass(); // returns the RETS Class responsible for this record
```

#### Downloading Media (Photos, Images, Documents, etc.)

The returned value from a `$rets->GetObject()` call is a `\Illuminate\Support\Collection` object which allows many common array-like features as well as some helper methods.
The returned value from a `$rets->GetObject()` call is an array.
The library provides some helper methods for convenience.

```php
$objects = $rets->GetObject($rets_resource, $object_type, $object_keys);

// grab the first object of the set
$objects->first();
\PHRETS\Arr::first($objects);

// grab the last object of the set
$objects->last();
\PHRETS\Arr::last($objects);

// throw out everything but the first 10 objects
$objects = $objects->slice(0, 10);
$objects = array_slice($objects, 0, 10);
```

Each object within that collection is a `\PHRETS\Models\BaseObject` object with it's own set of helper methods:
Each object within the array is a `\PHRETS\Models\BaseObject` object with it's own set of helper methods:

```php
$objects = $rets->GetObject( see above documentation );
Expand Down

0 comments on commit 1c81c26

Please sign in to comment.