commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / packages / Google / library / googlenotificationhistory.php
1 <?php
2 /*
3 * Copyright (C) 2010 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *
18 */
19
20 /** This class handles the notification history requests it's instantiated to
21 * create notification history requests.
22 *
23 * refer to /demo/basicapiresponsehandlerdemo.php for a API V2.5 example.
24 */
25 class GoogleNotificationHistoryRequest {
26 var $merchant_id;
27 var $merchant_key;
28 var $server_type;
29
30 var $log;
31 var $schema_url;
32
33 /**
34 * @param string $id merchant Id
35 * @param string $key merchant Key
36 * @param string $server_type server environment production or sandbox
37 */
38 function GoogleNotificationHistoryRequest($id=null, $key=null, $server_type="sandbox"){
39 require_once('googlerequest.php');
40 $this->merchant_id = $id;
41 $this->merchant_key = $key;
42 $this->server_type = $server_type;
43 $this->schema_url = "http://checkout.google.com/schema/2";
44 }
45
46 /**
47 * Send a <notification-history-request> request to Google Checkout
48 *
49 * info: {@link http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API_Notification_History_API.html}
50 *
51 * @param string $sn serial number
52 * @param string $npt next page token
53 * @param array $orders array of string google order numbers
54 * @param array $nt array of string notification types
55 * @param array $st array of tracking data where tracking code => carrier
56 * @param string @st string of start time in format YYYY-MM-DD[T]HH:MM:SS[Timezone] ie
57 * 2010-05-01T05:00:00Z
58 * @param string @et string of end time in format YYYY-MM-DD[T]HH:MM:SS[Timezone] ie
59 * 2010-05-02T05:00:00Z
60 */
61 function SendNotificationHistoryRequest($sn = null, $npt = null, $orders = array(), $nt = array(), $st = null, $et = null){
62 $postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
63 $postargs .= "<notification-history-request xmlns=\"".$this->schema_url."\">";
64 if(isset($sn)){
65 $postargs .= "<serial-number>".$sn."</serial-number>";
66 } elseif(isset($npt)) {
67 $postargs .= "<next-page-token>".$npt."</next-page-token>";
68 }
69 else{
70 if(isset($orders) && count($orders) > 0){
71 $postargs .= "<order-numbers>";
72 foreach ($orders as $order){
73 $postargs .= "<google-order-number>".$order."</google-order-number>";
74 }
75 $postargs .= "</order-numbers>";
76 }
77 if(isset($nt) && count($nt) > 0){
78 $postargs .= "<notification-types>";
79 foreach ($nt as $notification_type){
80 $postargs .= "<notification-type>".$notification_type."</notification-type";
81 }
82 $postargs .= "</notification-types>";
83 }
84 if(isset($st) && isset($et)){
85 $postargs .= "<start-time>".$st."</start-time>";
86 $postargs .= "<end-time".$et."</end-time>";
87 }
88 }
89 $postargs .= "</notification-history-request>";
90
91 $Grequest = new GoogleRequest($this->merchant_id, $this->merchant_key, $this->server_type);
92 return $Grequest->SendReq($Grequest->GetReportUrl(), $Grequest->GetAuthenticationHeaders(), $postargs);
93 }
94 }
95 ?>