Skip to content

Commit

Permalink
Merge pull request #4 from apruve/AP-3072
Browse files Browse the repository at this point in the history
AP-3072 - porting to v4 API.
  • Loading branch information
Pro777 committed Jun 2, 2017
2 parents dd522a9 + 65f536d commit 34e89b3
Show file tree
Hide file tree
Showing 31 changed files with 1,577 additions and 1,542 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

vendor/
composer.phar
phpunit.phar
.idea/
.DS_Store
9 changes: 4 additions & 5 deletions Apruve.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php

interface Environment
{
const PROD = 'https://app.apruve.com';
const TEST = 'https://test.apruve.com';
const DEV = 'http://localhost:3000';
interface Environment {
const PROD = 'https://app.apruve.com';
const TEST = 'https://test.apruve.com';
const DEV = 'http://localhost:3000';
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Please use [Github issues](https://github.com/apruve/apruve-php/issues) to reque
Add this require to your `composer.json`:

"require": {
"apruve/apruve-php": "~1.0"
"apruve/apruve-php": "~1.2"
}

**NOTE**: Be sure to update the version as you update the version of apruve-php
Expand Down
38 changes: 19 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"name": "apruve/apruve-php",
"description": "Apruve PHP Library to support apruve.js.",
"require-dev": {
"phpunit/phpunit": "4.1.0"
},
"license": "MIT",
"authors": [
{
"name": "Apruve",
"email": "support@apruve.com"
}
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-0" : {
"Apruve" : "src"
}
"name": "apruve/apruve-php",
"description": "Apruve PHP Library to support apruve.js.",
"require-dev": {
"phpunit/phpunit": "4.1.0"
},
"license": "MIT",
"authors": [
{
"name": "Apruve",
"email": "support@apruve.com"
}
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-0": {
"Apruve": "src"
}
}
}
98 changes: 43 additions & 55 deletions src/Apruve/ApruveObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,47 @@

abstract class ApruveObject {

protected $client;

public function __construct($values=[], $client=null)
{
if ($client == null)
{
$this->client = new Client();
}
else
{
$this->client = $client;
}
foreach ($values as $name => $value)
{
$this->$name = $value;
}
}

public function toHashString()
{
$ret = '';
$called_class = get_called_class();
foreach ($called_class::$hash_order as $key)
{
$ret .= $this->$key;
}
return $ret;
}

public function toJsonArray()
{
$jsonArr = [];
$called_class = get_called_class();
foreach ($called_class::$json_fields as $key)
{
if (gettype($this->$key) == "array")
{
$jsonArr[$key] = [];
foreach($this->$key as $item)
{
array_push($jsonArr[$key], $item->toJsonArray());
}
}
else
{
$jsonArr[$key] = $this->$key;
}
}
return $jsonArr;
}

public function toJson()
{
return json_encode($this->toJsonArray());
}
protected $client;

public function __construct( $values = [], $client = null ) {
if ( $client == null ) {
$this->client = new Client();
} else {
$this->client = $client;
}
foreach ( $values as $name => $value ) {
$this->$name = $value;
}
}

public function toHashString() {
$ret = '';
$called_class = get_called_class();
foreach ( $called_class::$hash_order as $key ) {
$ret .= $this->$key;
}

return $ret;
}

public function toJson() {
return json_encode( $this->toJsonArray() );
}

public function toJsonArray() {
$jsonArr = [];
$called_class = get_called_class();
foreach ( $called_class::$json_fields as $key ) {
if ( gettype( $this->$key ) == "array" ) {
$jsonArr[ $key ] = [];
foreach ( $this->$key as $item ) {
array_push( $jsonArr[ $key ], $item->toJsonArray() );
}
} else {
$jsonArr[ $key ] = $this->$key;
}
}

return $jsonArr;
}
}
Loading

0 comments on commit 34e89b3

Please sign in to comment.