Skip to content

Commit b9c2e47

Browse files
author
Sean Larkin
committed
Initial commit of MBBitz's 1.1 release of the HaPi library.
0 parents  commit b9c2e47

30 files changed

+8025
-0
lines changed

Harvest/Abstract.php

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
<?php
2+
/*
3+
* copyright (c) 2009 MDBitz - Matthew John Denton - mdbitz.com
4+
*
5+
* This file is part of HarvestAPI.
6+
*
7+
* HarvestAPI is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* HarvestAPI is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with HarvestAPI. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
/**
22+
* Abstract
23+
*
24+
* This file contains the class Harvest_Abstract
25+
*
26+
* @author Matthew John Denton <[email protected]>
27+
* @package com.mdbitz.harvest
28+
*/
29+
30+
/**
31+
* Harvest_Abstract defines the base class utilized by all Harvest Objects
32+
*
33+
* @package com.mdbitz.harvest
34+
*/
35+
abstract class Harvest_Abstract {
36+
37+
/**
38+
* @var string Document Element Name
39+
*/
40+
protected $_root = "";
41+
42+
/**
43+
* @var boolean Convert underscores
44+
*/
45+
protected $_convert = true;
46+
47+
/**
48+
* @var array Object Values
49+
*/
50+
protected $_values = array();
51+
52+
/**
53+
* magic method to return non public properties
54+
*
55+
* @see get
56+
* @param mixed $property
57+
* @return mixed
58+
*/
59+
public function __get( $property )
60+
{
61+
return $this->get( $property );
62+
}
63+
64+
/**
65+
* get specifed property
66+
*
67+
* @param mixed $property
68+
* @return mixed
69+
*/
70+
public function get( $property )
71+
{
72+
$value = null;
73+
74+
if( $this->_convert ) {
75+
$property = str_replace( "_", "-", $property );
76+
} else {
77+
$property = str_replace( "-", "_", $property );
78+
}
79+
80+
if (array_key_exists($property, $this->_values)) {
81+
return $this->_values[$property];
82+
} else {
83+
return null;
84+
}
85+
86+
}
87+
88+
/**
89+
* magic method to set non public properties
90+
*
91+
* @see set
92+
* @param mixed $property
93+
* @param mixed $value
94+
* @return void
95+
*/
96+
public function __set( $property, $value )
97+
{
98+
$this->set( $property, $value );
99+
}
100+
101+
/**
102+
* set property to specified value
103+
*
104+
* @param mixed $property
105+
* @param mixed $value
106+
* @return void
107+
*/
108+
public function set($property, $value)
109+
{
110+
if( $this->_convert ) {
111+
$property = str_replace( "_", "-", $property );
112+
} else {
113+
$property = str_replace( "-", "_", $property );
114+
}
115+
116+
$this->_values[$property] = $value;
117+
}
118+
119+
/**
120+
* magic method used for method overloading
121+
*
122+
* @param string $method name of the method
123+
* @param array $args method arguments
124+
* @return mixed the return value of the given method
125+
*/
126+
public function __call($method, $arguments)
127+
{
128+
if( count($arguments) == 0 ) {
129+
return $this->get( $method );
130+
} else if( count( $arguments ) == 1 ) {
131+
return $this->set( $method, $arguments[0] );
132+
}
133+
134+
throw new Harvest_Exception( sprintf('Unknown method %s::%s', get_class($this), $method));
135+
}
136+
137+
/**
138+
* magic method used for method overloading
139+
*
140+
* @param XMLNode $node xml node to parse
141+
* @return void
142+
*/
143+
public function parseXML( $node ) {
144+
145+
foreach ( $node->childNodes as $item ) {
146+
if( $item->nodeName != "#text" ){
147+
$this->set( $item->nodeName, $item->nodeValue);
148+
}
149+
}
150+
151+
}
152+
153+
/**
154+
* Convert Harvest Object to XML representation
155+
*
156+
* @return string
157+
*/
158+
public function toXML( )
159+
{
160+
$xml = "<$this->_root>";
161+
foreach ( $this->_values as $key => $value ) {
162+
$xml .= "<$key>$value</$key>";
163+
}
164+
$xml .= "</$this->_root>";
165+
return $xml;
166+
}
167+
168+
}

Harvest/Category.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/*
3+
* copyright (c) 2009 MDBitz - Matthew John Denton - mdbitz.com
4+
*
5+
* This file is part of HarvestAPI.
6+
*
7+
* HarvestAPI is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* HarvestAPI is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with HarvestAPI. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
/**
22+
* Category
23+
*
24+
* This file contains the class Harvest_Category
25+
*
26+
* @author Matthew John Denton <[email protected]>
27+
* @version 0.1
28+
* @package com.mdbitz.harvest
29+
*/
30+
31+
/**
32+
* Harvest Categroy Object
33+
*
34+
* @package com.mdbitz.harvest
35+
*/
36+
class Harvest_Category extends Harvest_Abstract {
37+
38+
}

Harvest/Client.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/*
3+
* copyright (c) 2009 MDBitz - Matthew John Denton - mdbitz.com
4+
*
5+
* This file is part of HarvestAPI.
6+
*
7+
* HarvestAPI is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* HarvestAPI is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with HarvestAPI. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
/**
22+
* Client
23+
*
24+
* This file contains the class Harvest_Client
25+
*
26+
* @author Matthew John Denton <[email protected]>
27+
* @package com.mdbitz.harvest
28+
*/
29+
30+
/**
31+
* Harvest Client Object
32+
*
33+
* <b>Properties</b>
34+
* <ul>
35+
* <li>active</li>
36+
* <li>cache-version</li>
37+
* <li>currency</li>
38+
* <li>default-invoice-timeframe</li>
39+
* <li>details</li>
40+
* <li>highrise-id</li>
41+
* <li>id</li>
42+
* <li>name</li>
43+
* </ul>
44+
*
45+
* @package com.mdbitz.harvest
46+
*/
47+
class Harvest_Client extends Harvest_Abstract {
48+
49+
/**
50+
* @var string client
51+
*/
52+
protected $_root = "client";
53+
54+
}

Harvest/Contact.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/*
3+
* copyright (c) 2009 MDBitz - Matthew John Denton - mdbitz.com
4+
*
5+
* This file is part of HarvestAPI.
6+
*
7+
* HarvestAPI is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* HarvestAPI is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with HarvestAPI. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
/**
22+
* Contact
23+
*
24+
* This file contains the class Harvest_Contact
25+
*
26+
* @author Matthew John Denton <[email protected]>
27+
* @package com.mdbitz.harvest
28+
*/
29+
30+
/**
31+
* Harvest Contact Object
32+
*
33+
* <b>Properties</b>
34+
* <ul>
35+
* <li>client-id</li>
36+
* <li>email</li>
37+
* <li>fax</li>
38+
* <li>first-name</li>
39+
* <li>id</li>
40+
* <li>last-name</li>
41+
* <li>phone-mobile</li>
42+
* <li>phone-office</li>
43+
* <li>title</li>
44+
* </ul>
45+
*
46+
* @package com.mdbitz.harvest
47+
*/
48+
class Harvest_Contact extends Harvest_Abstract {
49+
50+
/**
51+
* @var string contact
52+
*/
53+
protected $_root = "contact";
54+
55+
}

0 commit comments

Comments
 (0)