This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
wp-idxbroker-api.php
1953 lines (1767 loc) · 76.2 KB
/
wp-idxbroker-api.php
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Library for accessing the IDX Broker API on WordPress
*
* @link http://middleware.idxbroker.com/docs/api/methods/index.html API Documentation
* @package WP-API-Libraries\WP-IDX-Broker-API
*/
/*
* Plugin Name: WP IDX Broker API
* Plugin URI: https://github.com/wp-api-libraries/wp-idxbroker-api
* Description: Perform API requests to IDX Broker in WordPress.
* Author: WP API Libraries
* Version: 1.1.0
* Text Domain: wp-idxbroker-api
* Author URI: https://wp-api-libraries.com
* GitHub Plugin URI: https://github.com/wp-api-libraries/wp-idxbroker-api
* GitHub Branch: master
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/* Check if class exists. */
if ( ! class_exists( 'IdxBrokerAPI' ) ) {
/**
* A WordPress API library for accessing the IDX Broker API.
*
* @version 1.1.0
* @link http://middleware.idxbroker.com/docs/api/methods/index.html API Documentation
* @package WP-API-Libraries\WP-IDX-Broker-API
* @author Santiago Garza <https://github.com/sfgarza>
* @author imFORZA <https://github.com/imforza>
*/
class IdxBrokerAPI {
/**
* API URL.
*
* @var string
*/
private $api_url = 'https://api.idxbroker.com/';
/**
* HTTP request arguments.
*
* (default value: array())
*
* @var Array
* @access protected
*/
protected $args = array();
/**
* IDX Broker route to make a the call to.
*
* @var string
*/
protected $route;
/**
* Raw response from IDX Broker server.
*
* @var string
*/
public $response;
/**
* Response code from the server
*
* @var int
*/
public $code;
/**
* __construct function.
*
* @access public
* @param string $api_key IDX Broker API key.
* @param string $partner_key Ancillarykey.
* @param string $outputtype XML or JSON.
* @param string $apiversion Version of API to use.
* @return void
*/
public function __construct( $api_key, $partner_key = null, $outputtype = 'json', $apiversion = '1.7.0' ) {
$this->args['headers'] = array(
'Content-Type' => 'application/x-www-form-urlencoded',
'accesskey' => $api_key,
'ancillarykey' => $partner_key,
'outputtype' => $outputtype,
'apiversion' => $apiversion,
);
// Force use of v 1.6.0
if ( version_compare( $apiversion, '1.6.0', '<' ) ) {
unset( $this->args['headers']['apiversion'] );
$this->args['headers']['apiversion'] = $apiversion;
}
}
/**
* Request function.
*
* @access public
* @return array Array of API results.
*/
public function request() {
$result = false;
$this->response = wp_remote_request( $this->api_url . $this->route, $this->args );
// pp( $this->api_url . $this->route, $this->args );
// pp( $this->api_url . $this->route, $this->response );
$this->get_response_code();
$this->check_usage();
if ( in_array( (int) $this->code, array( 200, 204 ), true ) ) {
$result = json_decode( wp_remote_retrieve_body( $this->response ), true );
}
return $result;
}
/**
* Builds the request for the API call to IDX Broker.
*
* @param string $route The route to make the call to.
* @param array $fields Array containing the http method and body
* of call. Optional for GET requests.
* @return self IdxBrokerAPI Object.
*/
public function build_request( $route, $fields = array() ) {
$this->route = ( isset( $route ) ) ? $route : '';
$this->args['method'] = ( isset( $fields['method'] ) ) ? $fields['method'] : 'GET';
$this->args['body'] = ( isset( $fields['body'] ) ) ? $fields['body'] : '';
return $this;
}
/**
* Saves the hourly API key usage count.
*
* @return string API hourly usage count.
*/
protected function check_usage() {
return wp_remote_retrieve_header( $this->response, 'hourly-access-key-usage' );
}
/**
* Gets the response code from the response.
*/
protected function get_response_code() {
$this->code = wp_remote_retrieve_response_code( $this->response );
if ( WP_DEBUG && ! in_array( (int) $this->code, array( 200, 204 ), true ) ) {
error_log( "[$this->route] response: $this->code" );
}
}
/**
* Get domain used for displaying IDX pages.
*
* @return array Array containing domain 'scheme' & 'url'.
*/
public function get_idx_domain() {
// Make API call to systemlinks cuz IDX Broker doesnt send it in accounts info. ¯\_(ツ)_/¯.
$links = $this->get_clients_systemlinks( 'url' );
// Default to false.
$domain = false;
// Parse URL if successful.
if ( isset( $links[0]['url'] ) ) {
$data = wp_parse_url( $links[0]['url'] );
$domain['scheme'] = $data['scheme'];
$domain['url'] = $data['host'];
$domain['full'] = $data['scheme'] . '://' . $data['host'];
}
return $domain;
}
/*
-------------------------------------------------------------------------------------------------------------
------------------------------------------- Partners Endpoints ----------------------------------------------
-------------------------------------------------------------------------------------------------------------
*/
/**
* Get a list of all agents for your clients.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getAggregatedagents Documentation
* @access public
* @param array $args Query args to send in to API call.
* @return array All available agents.
*/
public function get_partners_aggregatedagents( $args = array() ) {
// Prepare request.
$route = 'partners/aggregatedagents';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Get a list of featured MLS properties.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getAggregatedfeatured Documentation
* @access public
* @param array $args Query args to send in to API call.
* @return array List of featured MLS properties for each client.
*/
public function get_partners_aggregatedfeatured( $args = array() ) {
// Prepare request.
$route = 'partners/aggregatedfeatured';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Get a list of all leads.
*
* For bandwidth and memory considerations there is a limit of 5,000 on the number of leads that can be returned in
* any single request. Even if a full week of data is requested this limit will only be encountered if your clients
* have a combined average 30+ leads created, updated, or active per hour (as such it will be most common when
* requesting leads based on last property update date). If this limit is exceeded a 413 -Requested Entity Too
* Large error is returned. If encountered a smaller interval will need to be used.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getAggregatedleads Documentation
* @access public
* @param array $args Query args to send in to API call.
* @return array The applicable client account ID, lead ID, first name, last name, email address, address, city,
* state/province, country, zipCode, phone number, ID of the agent assigned, email format (html or
* plain text), disabled status (y/n), allowed to log in to their account (y/n), will receive property
* updates (y/n), subscribe date, last edited, last login date, last property update date, last
* activity type, and last activity date.
*/
public function get_partners_aggregatedleads( $args = array() ) {
// Prepare request.
$route = 'partners/aggregatedleads';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Get a list of all leads traffic history.
*
* Note: For bandwidth and memory considerations there is a limit of 5,000 on the number of searches that can be
* returned in any single request.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getAggregatedleadtraffic Documentation
* @access public
* @param array $args Query args to send in to API call.
* @return array The applicable client account ID, date, lead ID, IP , page, and referrer.
*/
public function get_partners_aggregatedleadtraffic( $args = array() ) {
// Prepare request.
$route = 'partners/aggregatedleadtraffic';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* This method gives the status for all MLS listings (not supplemental) broken down by client account ID. This
* includes sold/pending listings with an unknown status which are not usually returned by sold/pending api methods.
* This is helpful if you need to know when previously gathered featured properties have left the market.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getAggregatedlistingstatus Documentation
* @access public
* @param array $args Query args to send in to API call.
* @return array MLS listings along with their statuses.
*/
public function get_partners_aggregatedlistingstatus( $args = array() ) {
// Prepare request.
$route = 'partners/aggregatedlistingstatus';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Get a list of all lead saved properties.
*
* For bandwidth and memory considerations there is a limit of 5,000 on the number of searches that can be returned
* in any single request.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getAggregatedproperties Documentation
* @access public
* @param array $args Query args to send in to API call.
* @return array Search ID, the applicable client account ID, lead ID, page ID, search name, search parameters, lead
* will receive property updates (y/n), created date, last edited date.
*/
public function get_partners_aggregatedproperties( $args = array() ) {
// Prepare request.
$route = 'partners/aggregatedproperties';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Get a list of all lead saved searches.
*
* For bandwidth and memory considerations there is a limit of 5,000 on the number of searches that can be returned
* in any single request.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getAggregatedsearches Documentation
* @access public
* @param array $args Query args to send in to API call.
* @return array Search ID, the applicable client account ID, lead ID, page ID, search name, search parameters, lead
* will receive property updates (y/n), created date, last edited date.
*/
public function get_partners_aggregatedsearches( $args = array() ) {
// Prepare request.
$route = 'partners/aggregatedsearches';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Get a list of sold/pending MLS properties.
*
* Output fields may or may not be populated depending on how the information was entered into the IDX system.
*
* We are planning to add the ability to query by the date the property left the market and, for sold listings, the
* date it was sold in a future update.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getAggregatedsoldpending Documentation
* @access public
* @param array $args Query args to send in to API call.
* @return array List of soldpending properties for each client.
*/
public function get_partners_aggregatedsoldpending( $args = array() ) {
// Prepare request.
$route = 'partners/aggregatedsoldpending';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Get a list of supplemental (non-MLS) properties.
*
* Output fields may or may not be populated depending on how the information was entered into the IDX system.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getAggregatedsupplemental Documentation
* @access public
* @param array $args Query args to send in to API call.
* @return array List of supplemental (non-MLS) properties for each client.
*/
public function get_partners_aggregatedsupplemental( $args = array() ) {
// Prepare request.
$route = 'partners/aggregatedsupplemental';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Get the default api version.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-apiversion Documentation
* @access public
* @return string The default api version.
*/
public function get_partners_apiversion() {
return $this->build_request( 'partners/apiversion' )->request();
}
/**
* List of available MLSs with their fees.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getAvailableMls Documentation
* @access public
* @return array List of available MLSs with their fees.
*/
public function get_partners_availablemls() {
return $this->build_request( 'partners/availablemls' )->request();
}
/**
* A list of clients available to a given partner. The list of clients can be filtered by GET values.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getClients Documentation
* @access public
* @param array $args Query args to send in to API call.
* @return array The account ID, company name, display name, account status, and current API key of each client or
* clients matching the filter values.
*/
public function get_partners_clients( $args = array() ) {
// Prepare request.
$route = 'partners/clients';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* This is a simple, access anywhere, method for getting a list of all API components available.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getListcomponents Documentation
* @access public
* @return array All available APIs/Components.
*/
public function get_partners_listcomponents() {
return $this->build_request( 'partners/listcomponents' )->request();
}
/**
* A simple method for listing all available methods in the current API component. This method will also list which
* request methods (GET, PUT, POST, or DELETE) are supported by each method in addition to each method status.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-listmethods Documentation
* @access public
* @return array Basic information about all available methods in this API.
*/
public function get_partners_listmethods() {
return $this->build_request( 'partners/listmethods' )->request();
}
/**
* Gives the names and IDs of all available property types. This method differs from the property type lookup method
* in the client API component in that it can look up property types for any active Platinum MLS, not just those for
* which the client is a member.
*
* Note: The IDX property types are those used for multiple MLS searches and are equivalent to the property types
* used in the original IDX product. The data returned is structured as:
*
* idxPropTypes
* * parentPtID - the numeric ID for IDX property types; seen as parentPtID when retrieving property information.
* * pt - the 2 to 3 letter abbreviated property type as seen in multiple MLS search queries as the variable pt.
* * propertyType - the human friendly property type name.
* [idxID] in the format a### (this element will not be present at all if no IDX ID is provided)
* * mlsPtID - the numeric ID given to MLS property types; seen as parentPtID when retrieving property
* information and in single MLS search queries as the variable pt.
* * propertyType - the human friendly property type name.
* * parentPtID - the ID of the IDX property type to which this MLS property type belongs.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Partners-getPropertytypess Documentation
* @param string $idx_id The IDX ID of the MLS from which you need property type information. If no IDX ID
* is specified then only the IDX property types (parentPtID) will be returned.
* @param string|array $rf A string or an array of strings of return field names.
* @return array An array containing the IDX property types and, if an IDX ID has been provided,
* the MLS's property types and their IDs.
*/
public function get_partners_propertytypes( $idx_id = '', $rf = '' ) {
// Prepare request.
$route = ('' === $idx_id ) ? 'partners/propertytypes' : "partners/propertytypes/$idx_id";
$args = array(
'rf' => $rf,
);
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/*
-------------------------------------------------------------------------------------------------------------
------------------------------------------- Client Endpoints ------------------------------------------------
-------------------------------------------------------------------------------------------------------------
*/
/**
* Get client account information.
*
* @return object The response.
*/
public function get_clients_accountinfo() {
return $this->build_request( 'clients/accountinfo' )->request();
}
/**
* Update a client's account information.
*
* @param array $data The data to update (key => val).
* @return object The response.
*/
public function update_clients_accountinfo( $data ) {
$fields['method'] = 'POST';
$fields['body'] = $data;
return $this->build_request( 'clients/accountinfo', $fields )->request();
}
/**
* Get your account type.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getAccounttypes Documentation.
*
* @return string Account type.
*/
public function get_clients_accounttype() {
return $this->build_request( 'clients/accounttype' )->request();
}
/**
* View agent information on a multi-user account.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getAgents Documentation.
*
* @param array $args Query args to send in to API call.
* @return array All agents on the account or those matching filter values.
*/
public function get_clients_agents( $args = array() ) {
$route = 'clients/agents';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Get the default api version.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-apiversion Documentation.
*
* @return array The default api version.
*/
public function get_clients_apiversion() {
return $this->build_request( 'clients/apiversion' )->request();
}
/**
* Returns the cities available in each of a client's city lists. Since a client can build any number of city
* lists this method requires the ID of which list you want to view. To get a list of all city lists available do
* not send the primary request ID. The default list on each account has the id combinedActiveMLS
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getCities Documentation.
* @param string $list_id City list id.
* @param string|array $rf A string or an array of strings of return field names.
* @return array All cities in a given list or, if no list ID is provided, a list of list IDs.
*/
public function get_clients_cities( $list_id = '', $rf = '' ) {
$route = ('' === $list_id ) ? 'clients/cities' : "clients/cities/$list_id";
$args = array(
'rf' => $rf,
);
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Returns the IDs and names for each of a client's city lists including MLS city lists. To get the list of all city
* lists available do not send the primary request ID. The default list on each account has the ID combinedActiveMLS
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getCitieslistname Documentation.
*
* @return array A list of city list IDs and names.
*/
public function get_clients_citieslistname() {
return $this->build_request( 'clients/citieslistname' )->request();
}
/**
* Returns the counties available in each of a client's county lists. Since a client can build any number of county
* lists this method requires the ID of which list you want to view. To get a list of all county lists available do
* not send the primary request ID. The default list on each account has the id combinedActiveMLS.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getCounties Documentation.
* @param string $list_id If no ID is given a list of IDs is returned.
* @param string|array $rf A string or an array of strings of fields to return in the output..
* @return array All counties in a given list or, if no list ID is provided, a list of list IDs.
*/
public function get_clients_counties( $list_id = '', $rf = '' ) {
$route = ('' === $list_id ) ? 'clients/counties' : "clients/counties/$list_id";
$args = array(
'rf' => $rf,
);
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Returns the IDs and names for each of a client's counties lists including MLS counties lists. To get the list of
* all counties lists available do not send the primary request ID. The default list on each account has the ID
* combinedActiveMLS
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getCountieslistname Documentation.
*
* @return array A list of counties list IDs and names
*/
public function get_clients_countieslistname() {
return $this->build_request( 'clients/countieslistname' )->request();
}
/**
* Update dynamic wrapper url for global, pages and saved links. If savedLinkID, or pageID are not passed, the
* global dynamic wrapper url will be updated.
*
* @api POST
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-postDynamicwrapperurl Documentation.
* @param string $dynamic_url Dynamic wrapper url.
* @param int $savedlink_id Saved link ID if setting dynamic wrapper url for a specific saved link.
* @param int $page_id Page ID if setting dynamic wrapper url for a specific page.
* @return mixed No data returned on success.
*/
public function post_clients_dynamicwrapperurl( $dynamic_url, $savedlink_id = '', $page_id = '' ) {
$fields['method'] = 'POST';
$fields['body']['dynamicURL'] = $dynamic_url;
if ( ! empty( $savedlink_id ) ) {
$fields['body']['savedLinkID'] = $savedlink_id;
}
if ( ! empty( $page_id ) ) {
$fields['body']['pageID'] = $page_id;
}
return $this->build_request( 'clients/dynamicwrapperurl', $fields )->request();
}
/**
* Returns a basic set of information for all of the client's featured (active) properties
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getFeatured Documentation.
*
* @param array $args Query args to send in to API call.
* @return array Featured properties on the account.
*/
public function get_clients_featured( $args = array() ) {
$route = 'clients/featured';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Returns the allowed returnable fields for a given listingID.
*
* Note: Valid ancillarykey is required in the request header.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-listallowedfields Documentation.
* @param string $idx_id The idxID of MLS.
* @param string $listing_id The listing ID.
* @return array List of fields that are returnable for the listingID.
*/
public function get_clients_listallowedfields( $idx_id, $listing_id ) {
$route = "clients/listallowedfields/$idx_id/$listing_id";
return $this->build_request( $route )->request();
}
/**
* This is a simple, access anywhere, method for getting a list of all API components available.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getListcomponents Documentation.
*
* @return array All available APIs/Components.
*/
public function get_clients_listcomponents() {
return $this->build_request( 'clients/listcomponents' )->request();
}
/**
* Returns the detailed information for a given listingID.
*
* Note: Valid ancillarykey is required in the request header.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-listing Documentation.
* @param string $idx_id The idxID of MLS.
* @param string $listing_id The listing ID.
* @param string $rf Array of fields to return in the output.
* @param bool $disclaimers Include MLS disclaimer/courtesy in the response.
* @return array List of fields that are returnable for the listingID.
*/
public function get_clients_listing( $idx_id, $listing_id, $rf = '', $disclaimers = '' ) {
$route = "clients/listing/$idx_id/$listing_id";
$args = array(
'rf' => $rf,
'disclaimers' => $disclaimers,
);
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* A simple method for listing all available methods in the current API component. This method will also list which
* request methods (GET, PUT, POST, or DELETE) are supported by each method in addition to each method status.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-listmethods Documentation.
*
* @return array Basic information about all available methods in this API.
*/
public function get_clients_listmethods() {
return $this->build_request( 'clients/listmethods' )->request();
}
/**
* View all offices on a mutli-user account.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getOffices Documentation.
*
* @param array $args Query args to send in to API call.
* @return array All offices on the account or those matching filter values.
*/
public function get_clients_offices( $args = array() ) {
$route = 'clients/offices';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Returns the postalcodes available in each of a client's postalcode lists. Since a client can build any number of
* postalcode lists this method requires the ID of which list you want to view. To get a list of all postalcode
* lists available do not send the primary request ID. The default list on each account has the id combinedActiveMLS.
*
* Note: This method was previously called as "zipcodes" but was changed to keep API format more international.
* Calls to "zipcodes" will be forwarded to "postalcodes" and "zipcodes" is listed as deprecated in the method list.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getPostalcodes Documentation.
* @param string $list_id If no ID is given a list of IDs is returned.
* @param array $args Query args to send in to API call.
* @return array All postalcodes in a given list or, if no list ID is provided, a list of list IDs.
*/
public function get_clients_postalcodes( $list_id = '', $args = array() ) {
$route = ( '' === $list_id ) ? 'clients/postalcodes' : "clients/postalcodes/$list_id";
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Returns the IDs and names for each of a client's postalcode lists including MLS postalcode lists. To get the list
* of all postal code lists available do not send the primary request ID. The default list on each account has the ID
* combinedActiveMLS
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getPostalcodeslistname Documentation.
*
* @return array A list of city list IDs and names
*/
public function get_clients_postalcodeslistname() {
return $this->build_request( 'clients/postalcodeslistname' )->request();
}
/**
* Returns the search results for a provided saved link ID.
*
* Note: Valid ancillarykey is required in the request header.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-properties Documentation.
* @param string $saved_links_id The ID of a client's saved link.
* @param array $args Query args to send in to API call.
* @return array All property results for a provided Saved Link ID.
*/
public function get_clients_properties( $saved_links_id, $args = array() ) {
$route = "clients/properties/$saved_links_id";
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Remove a new client saved link.
*
* @api DELETE
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-deleteSavedlinks Documentation.
* @param string $saved_links_id The ID of a client's saved link.
* @return mixed Nothing on success.
*/
public function delete_clients_savedlink( $saved_links_id ) {
$fields['method'] = 'DELETE';
$route = "clients/savedlinks/$saved_links_id";
return $this->build_request( $route, $fields )->request();
}
/**
* Get saved links for a given client account.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getSavedlinks Documentation.
* @param array $args Query args to send in to API call.
* @return array All saved links on the account.
*/
public function get_clients_savedlinks( $args = array() ) {
$route = 'clients/savedlinks';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Update an existing client's saved link
*
* This method is to be used at your own risk. We will NOT be held accountable for programmatic errors in your code
* or the improper use of search values or options within said values resulting in broken saved links.
*
* Note: The updatable fields need to be in a URL encoded, ampersand delineated query string format.
*
* Data Example:
* $data = array(
* 'linkName' => 'Good_side_of_tracks',
* 'pageTitle' => 'Good_side_of_tracks',
* 'linkTitle' => 'Good_side_of_tracks',
* 'queryString' => array('idxID' => 'a001', 'hp' => '200000')
* );
*
* @api POST
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-postSavedlinks Documentation.
* @param string $saved_links_id The ID of a client's saved link.
* @param array $data Savedlink fields to update.
* @return mixed If no POST data is supplied, then a list of updatable fields with format
* information is returned, otherwise on success 204 is returned.
*/
public function post_clients_savedlink( $saved_links_id, $data = array() ) {
$fields['method'] = 'POST';
$fields['body'] = $data;
$route = "clients/savedlinks/$saved_links_id";
return $this->build_request( $route, $fields )->request();
}
/**
* Create a new client saved link.
*
* Note: The updatable fields need to be in a URL encoded, ampersand delineated query string format. This action is
* not allowed if the client has more than 1000 saved links.
*
* Data Example:
* $data = array(
* 'linkName' => 'Good_side_of_tracks',
* 'pageTitle' => 'Good_side_of_tracks',
* 'linkTitle' => 'Good_side_of_tracks',
* 'queryString' => array('idxID' => 'a001', 'hp' => '200000')
* );
*
* @api PUT
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-putSavedlinks Documentation.
* @param array $data Savedlink fields to create.
* @return mixed If a client saved link is successfully created, the new saved link's ID will be
* returned. If no PUT data is supplied, then a list of updatable fields with format
* information is returned.
*/
public function put_clients_savedlink( $data = array() ) {
$fields['method'] = 'PUT';
$fields['body'] = $data;
$route = 'clients/savedlinks';
return $this->build_request( $route, $fields )->request();
}
/**
* Performs search and returns the results.
*
* Note: Valid ancillarykey is required in the request header.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getSearchquery Documentation.
* @param array $args Query args to send in to API call.
* @return array All available APIs/Components.
*/
public function get_clients_searchquery( $args = array() ) {
$route = 'clients/searchquery';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Returns a basic set of information for all of the client's sold and pending properties. That is, those that have
* been removed from their MLS data.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getSoldpending Documentation.
* @param array $args Query args to send in to API call.
* @return array Sold/pending properties on the account.
*/
public function get_clients_soldpending( $args = array() ) {
$route = 'clients/soldpending';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Remove a clients supplemental property.
*
* This method is to be used at your own risk. We will NOT be held accountable for programmatic errors in your code
* or the improper use of search values or options within said values resulting in deletion of supplemental properties.
*
* @api DELETE
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-deleteSupplemental Documentation.
* @param string $listing_id The listingID of a supplmental property.
* @return mixed Nothing on success.
*/
public function delete_clients_supplemental( $listing_id ) {
$fields['method'] = 'DELETE';
$route = "clients/supplemental/$listing_id";
return $this->build_request( $route, $fields )->request();
}
/**
* Returns a basic set of information for all of the client's supplemental (non-MLS) properties.
*
* @api GET
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-getSupplemental Documentation.
* @param array $args Query args to send in to API call.
* @return array Supplemental properties on the account.
*/
public function get_clients_supplemental( $args = array() ) {
$route = 'clients/supplemental';
$route = add_query_arg( $args, $route );
return $this->build_request( $route )->request();
}
/**
* Update an existing supplemental listing.
*
* Note: if updating images, existing images are deleted and the new images are inserted instead for the listing.
*
* Data Example:
* $data = array(
* 'likeIdxID' => 'a001',
* 'likeMlsPtID' => '1',
* 'images' => array('http://example.com/image1.jpg', 'http://example.com/image2.jpg')
* );
*
* @api POST
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-postSupplemental Documentation.
* @param string $listing_id The supplemental listing ID.
* @param array $data Supplemental fields to update.
* @return mixed If no POST data is supplied, then a list of updatable fields with format information
* is returned, otherwise on success 204 is returned.
*/
public function update_clients_supplemental( $listing_id, $data = array() ) {
$fields['method'] = 'POST';
$fields['body'] = $data;
$route = "clients/supplemental/$listing_id";
return $this->build_request( $route, $fields )->request();
}
/**
* Create a new supplemental listing.
*
* Note: likeIdxID and likeMlsPtID fields are required.
*
* Data Example:
* $data = array(
* 'likeIdxID' => 'a001',
* 'likeMlsPtID' => '1',
* 'images' => array('http://example.com/image1.jpg', 'http://example.com/image2.jpg')
* );
*
* @api PUT
* @see http://middleware.idxbroker.com/docs/api/methods/index.html#api-Clients-putSupplemental Documentation.
* @param array $data Supplemental fields to create.
* @return mixed If a supplemental listing is successfully created, the new supplemental listing ID will be
* returned. If no PUT data is supplied, then a list of updatable fields with format
* information is returned.
*/
public function create_clients_supplemental( $data = array() ) {
$fields['method'] = 'PUT';
$fields['body'] = $data;
$route = 'clients/supplemental';
return $this->build_request( $route, $fields )->request();
}
/**
* Put Supplemental Properties.
* @param array $data Data.