remove old readme
[atutor.git] / jscripts / opensocial / message.js
1 /*
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  *     http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14
15 /**
16  * @fileoverview Representation of a message.
17  */
18
19
20 /**
21  * @class
22  * Base interface for all message objects.
23  * *
24  * <p>
25  * <b>See also:</b>
26  * <a href="opensocial.html#newMessage">opensocial.newMessage()</a>,
27  * <a href="opensocial.html#requestSendMessage">
28  * opensocial.requestSendMessage()</a>
29  *
30
31  *
32  * @name opensocial.Message
33  */
34
35
36 /**
37  * Base interface for all message objects.
38  *
39  * @param {String} body The main text of the message.
40  * @param {Map.<opensocial.Message.Field, Object>} opt_params Any other
41  *    fields that should be set on the message object. All of the defined
42  *    Fields are supported.
43  * @private
44  * @constructor
45  */
46 opensocial.Message = function() {};
47
48
49 /**
50  * @static
51  * @class
52  * All of the fields that messages can have.
53  *
54  * <p>
55  * <b>See also:</b>
56  * <a
57  * href="opensocial.Message.html#getField">opensocial.Message.getField()</a>
58  * </p>
59  *
60  * @name opensocial.Message.Field
61  */
62 opensocial.Message.Field = {
63   /**
64    * The title of the message, specified as an opensocial.Message.Type.
65    * This field may be used interchangeably with the string 'type'.
66    * @member opensocial.Message.Field
67    */
68   TYPE : 'type',
69
70   /**
71    * The title of the message. HTML attributes are allowed and are
72    * sanitized by the container.
73    * This field may be used interchangeably with the string 'title'.
74    * @member opensocial.Message.Field
75    */
76   TITLE : 'title',
77
78   /**
79    * The main text of the message. HTML attributes are allowed and are
80    * sanitized by the container.
81    * This field may be used interchangeably with the string 'body'.
82    * @member opensocial.Message.Field
83    */
84   BODY : 'body',
85
86   /**
87    * The title of the message as a message template. Specifies the
88    * message ID to use in the gadget xml.
89    * This field may be used interchangeably with the string 'titleId'.
90    * @member opensocial.Message.Field
91    */
92   TITLE_ID : 'titleId',
93
94   /**
95    * The main text of the message as a message template. Specifies the
96    * message ID to use in the gadget xml.
97    * This field may be used interchangeably with the string 'bodyId'.
98    * @member opensocial.Message.Field
99    */
100   BODY_ID : 'bodyId'
101 };
102
103
104 /**
105  * @static
106  * @class
107  * The types of messages that can be sent.
108  *
109  * @name opensocial.Message.Type
110  */
111 opensocial.Message.Type = {
112   /**
113    * An email.
114    * This field may be used interchangeably with the string 'email'.
115    * @member opensocial.Message.Type
116    */
117   EMAIL : 'email',
118
119   /**
120    * A short private message.
121    * This field may be used interchangeably with the string 'notification'.
122    * @member opensocial.Message.Type
123    */
124   NOTIFICATION : 'notification',
125
126   /**
127    * A message to a specific user that can be seen only by that user.
128    * This field may be used interchangeably with the string 'privateMessage'.
129    * @member opensocial.Message.Type
130    */
131   PRIVATE_MESSAGE : 'privateMessage',
132
133   /**
134    * A message to a specific user that can be seen by more than that user.
135    * This field may be used interchangeably with the string 'publicMessage'.
136    * @member opensocial.Message.Type
137    */
138   PUBLIC_MESSAGE : 'publicMessage'
139 };
140
141
142 /**
143  * Gets the message data that's associated with the specified key.
144  *
145  * @param {String} key The key to get data for;
146  *   see the <a href="opensocial.Message.Field.html">Field</a> class
147  * for possible values
148  * @param {Map.&lt;opensocial.DataRequest.DataRequestFields, Object&gt;}
149  *  opt_params Additional
150  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
151  *    to pass to the request.
152  * @return {String} The data
153  * @member opensocial.Message
154  */
155 opensocial.Message.prototype.getField = function(key, opt_params) {};
156
157
158 /**
159  * Sets data for this message associated with the given key.
160  *
161  * @param {String} key The key to set data for
162  * @param {String} data The data to set
163  */
164 opensocial.Message.prototype.setField = function(key, data) {};