summaryrefslogtreecommitdiff
path: root/tests/unit/Soap/ContactManager.php
blob: 2fbeec48ef1e93b4edfa7ed7917f65da7ec6db90 (plain)
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
<?php

/**
  * Keeps track of the people in our Contact list.
  *
  * Starts with a standard Contact list and can add
  * new people to our list or change existing Contacts.
  * This class is for example purposes only, just to
  * show how to create a webservice
  */
class ContactManager{

	/**
	 * Gets the current Contact list.
	 * @return Contact[]
	 * @soapmethod
	 */
	public function	getContacts() {
		$Contact = new Contact();
		$Contact->address = new Address();
		$Contact->address->city ="sesamcity";
		$Contact->address->street ="sesamstreet";
		$Contact->email = "me@you.com";
		$Contact->id = 1;
		$Contact->name ="me";

		$ret[] = $Contact;
		//debugObject("Contacten: ",$ret);
		return $ret;
	}

	/**
	  * Gets the Contact with the given id.
	  * @param int $id The id
	  * @return Contact
	  * @soapmethod
	  */
	public function	getContact($id) {
		//get Contact from db
		//might wanna throw an exception when it does not exists
		throw new Exception("Contact '$id' not found");
	}
	/**
	  * Generates an new, empty Contact template
	  * @return Contact
	  * @soapmethod
	  */
	public function newContact() {
		return new Contact();
	}

	/**
	  * Saves a given Contact
	  * @param Contact $Contact
	  * @return boolean
	  * @soapmethod
	  */
	public function saveContact(Contact $Contact) {
		//error_log(var_export($Contact,true));
		//$Contact->save();
		return true;
	}

	/**
	 * @return mixed
	 * @soapmethod
	 */
	public function getList()
	{
		return array(array(1,2), array("12", 1.2));
	}

	/**
	 * @return array
	 * @soapmethod
	 */
	public function getEmptyArray()
	{
		return array();
	}

}


/**
  * The Contact details for a person
  *
  * Stores the person's name, address and e-mail
  * This class is for example purposes only, just to
  * show how to create a webservice
  *
  */
class Contact{

	/**
	 * @var int $id
	 * @soapproperty
	 */
	public $id;

	/**
	* @var string $name
	 * @soapproperty
	*/
	public $name;

	/** @var Address $address
	 * @soapproperty
	*/
	public $address;

	/** @var string $email
	 * @soapproperty
	*/
	public $email;

	/**
	  * saves a Contact
	  *
	  * @return void
	  */
	public function save() {
		//save Contact 2 db
	}
}

/**
  * Stores an address
  *
  * An address consists of a street, number, zipcode and city.
  * This class is for example purposes only, just to
  * show how to create a webservice
  *
  */
class Address{
	/** @var string $street
	 * @soapproperty
	*/
	public $street;

	/** @var string $nr
	 * @soapproperty
	*/
	public $nr;

	/** @var string $zipcode
	 * @soapproperty
	*/
	public $zipcode;

	/** @var string $city
	 * @soapproperty
	*/
	public $city;
}