[cl-soap-cvs] CVS update: cl-soap/test/test-google-adwords.lisp

Sven Van Caekenberghe scaekenberghe at common-lisp.net
Fri Sep 16 12:54:37 UTC 2005


Update of /project/cl-soap/cvsroot/cl-soap/test
In directory common-lisp.net:/tmp/cvs-serv24768/test

Modified Files:
	test-google-adwords.lisp 
Log Message:
1st actual (manual) google adwords api call

Date: Fri Sep 16 14:54:36 2005
Author: scaekenberghe

Index: cl-soap/test/test-google-adwords.lisp
diff -u cl-soap/test/test-google-adwords.lisp:1.1 cl-soap/test/test-google-adwords.lisp:1.2
--- cl-soap/test/test-google-adwords.lisp:1.1	Thu Sep 15 15:34:45 2005
+++ cl-soap/test/test-google-adwords.lisp	Fri Sep 16 14:54:36 2005
@@ -1,6 +1,6 @@
 ;;;; -*- mode: lisp -*-
 ;;;;
-;;;; $Id: test-google-adwords.lisp,v 1.1 2005/09/15 13:34:45 scaekenberghe Exp $
+;;;; $Id: test-google-adwords.lisp,v 1.2 2005/09/16 12:54:36 scaekenberghe Exp $
 ;;;;
 ;;;; Some test on the Google AdWords API (not publically available)
 ;;;;
@@ -13,6 +13,28 @@
 
 (in-package :cl-soap)
 
+;;; account parameters
+
+(defvar *google-adwords-email*)
+(defvar *google-adwords-password*)
+(defvar *google-adwords-user-agent)
+(defvar *google-adwords-token*)
+
+;;; constants
+
+(defconstant +google-adwords-ns-uri+ "https://adwords.google.com/api/adwords/v2")
+
+(defpackage :google
+  (:nicknames "google")
+  (:export 
+   ;; headers
+   "email" "password" "useragent" "token"
+   ;; info service
+   "getUsageQuotaThisMonth" "getUsageQuotaThisMonthResponse" "getUsageQuotaThisMonthReturn")
+  (:documentation "Package for symbols in the Google Adwords API XML Namespace"))
+
+(defparameter *google-adwords-ns* (s-xml:register-namespace +google-adwords-ns-uri+ "google" :google))
+
 ;;; basic WSDL parsing
 
 (defparameter *google-adwords-api-wsdl-urls*
@@ -29,4 +51,32 @@
 (defun parse-all-wsdl ()
   (mapcar #'parse-wsdl-url *google-adwords-api-wsdl-urls*))
 
+;;; manual calls
+
+(defun getUsageQuotaThisMonth ()
+  (let* ((xmethods (make-soap-end-point "https://adwords.google.com:443/api/adwords/v2/InfoService"))
+         (result (soap-call xmethods 
+                            `((google:|email| ,*google-adwords-email*)
+                              (google:|password| ,*google-adwords-password*)
+                              (google:|useragent| ,*google-adwords-user-agent*)
+                              (google:|token| ,*google-adwords-token*))
+                            `(google:|getUsageQuotaThisMonth|)
+                            :envelope-attributes `(:|xmlns| ,+google-adwords-ns-uri+))))
+    (if (eql (lxml-get-tag result) 'google:|getUsageQuotaThisMonthResponse|)
+        (let ((contents (lxml-find-tag 'google:|getUsageQuotaThisMonthReturn| (rest result))))
+          (if contents
+              (coerce (parse-integer (second contents)) 'integer)
+            (error "Expected a <getUsageQuotaThisMonthReturn> element")))
+      (error "Expected a <getUsageQuotaThisMonthResponse> element"))))
+  
+#+NIL
+(defun getUsageQuotaThisMonth ()
+  ;; when we can handle the google type schema this will work ;-)
+  (wsdl-soap-call "https://adwords.google.com:443/api/adwords/v2/InfoService"
+                  "getUsageQuotaThisMonth"
+                  :headers `("email" ,*google-adwords-email* 
+                             "password" ,*google-adwords-password* 
+                             "useragent" ,*google-adwords-user-agent* 
+                             "token" ,*google-adwords-token*)))
+                
 ;;;; eof




More information about the Cl-soap-cvs mailing list