Repository navigation
Expand file tree
/
Copy pathticketnetwork_state.class.php
More file actions
114 lines (91 loc) · 2.1 KB
/
Copy pathticketnetwork_state.class.php
File metadata and controls
114 lines (91 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* @file ticketnetwork_state.class.php
* @package TicketNetwork
*
* @license see LICENSE.txt
* @author jwwicks <jwwicks-at-gmail-dot-com>
*/
if(!class_exists('TicketNetworkBase')){
require_once('ticketnetwork.class.php');
}
/**
* @class TNState
* @brief TicketNetwork States and Provinces
*
* @since 0.0.1
*/
class TNState extends TicketNetworkBase{
public function __construct($options=false){
self::_defaults();
if($options){
self::config($options);
}
}
public function get($params=false){
$this->_request['method'] = 'GetStates';
if($params){
$this->set($params);
}
return $this;
}
public function search($params=null){
$retval = false;
try{
if(function_exists('apc_fetch')){
if(apc_exists('States')){
$states = apc_fetch('States');
}else{
$states = $this->send('get', array('countryID'=>217))->results();
apc_store('States', $states, 86400);
}
}else{
$states = $this->send('get', array('countryID'=>217))->results();
}
if($states){
foreach($states as $state){
foreach($params as $k=>$v){
if($state->$k == $params[$k]){
//pre($state);
$retval = $state;
}
}
}
}
}catch(Exception $e){
}
return $retval;
}
/**
* Parse the results from TicketNetwork
* @return string|unknown
*/
public function parse(){
$this->_data = array();
try{
parent::parse();
if(!empty($this->_response)){
if(is_array($this->_response->GetStatesResult->States)){
foreach($this->_response->GetStatesResult->States as $key => $value){
foreach($value as $k => $v){
if($v == 'United States of America'){
$this->_data[] = (object) $value;
}
}
}
}else{
$this->_data = $this->_response->GetPricingInfoResult;
}
}
}catch(TNException $e){
}
return $this;
}
protected function _defaults(){
parent::_defaults();
$this->_request = array(
'method' => '',
'parameters' => array()
);
}
}