myspace-ruby 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +284 -0
- data/doc/classes/MySpace.html +666 -0
- data/doc/classes/MySpace/Album.html +225 -0
- data/doc/classes/MySpace/Connection.html +427 -0
- data/doc/classes/MySpace/Detail.html +191 -0
- data/doc/classes/MySpace/FriendStatus.html +131 -0
- data/doc/classes/MySpace/Friends.html +141 -0
- data/doc/classes/MySpace/Friendship.html +205 -0
- data/doc/classes/MySpace/Group.html +301 -0
- data/doc/classes/MySpace/Groups.html +146 -0
- data/doc/classes/MySpace/Interest.html +156 -0
- data/doc/classes/MySpace/InvalidClassDefinition.html +111 -0
- data/doc/classes/MySpace/InvalidCredentials.html +111 -0
- data/doc/classes/MySpace/InvalidDataFormat.html +111 -0
- data/doc/classes/MySpace/InvalidObjectMap.html +111 -0
- data/doc/classes/MySpace/InvalidRequest.html +111 -0
- data/doc/classes/MySpace/InvalidRequestParams.html +111 -0
- data/doc/classes/MySpace/InvalidResponse.html +111 -0
- data/doc/classes/MySpace/Mood.html +131 -0
- data/doc/classes/MySpace/Object.html +348 -0
- data/doc/classes/MySpace/Photo.html +146 -0
- data/doc/classes/MySpace/Photos.html +136 -0
- data/doc/classes/MySpace/Profile.html +176 -0
- data/doc/classes/MySpace/Status.html +131 -0
- data/doc/classes/MySpace/UnknownDataType.html +111 -0
- data/doc/classes/MySpace/User.html +162 -0
- data/doc/classes/MySpace/Video.html +256 -0
- data/doc/classes/MySpace/Videos.html +126 -0
- data/doc/classes/MySpaceAPITest.html +916 -0
- data/doc/created.rid +1 -0
- data/doc/files/lib/myspace_rb.html +185 -0
- data/doc/files/tests/test_rb.html +109 -0
- data/doc/fr_class_index.html +28 -0
- data/doc/fr_file_index.html +29 -0
- data/doc/fr_method_index.html +54 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/myspace.rb +45 -0
- data/lib/myspace/classes/album.rb +25 -0
- data/lib/myspace/classes/detail.rb +22 -0
- data/lib/myspace/classes/friends.rb +16 -0
- data/lib/myspace/classes/friendship.rb +27 -0
- data/lib/myspace/classes/group.rb +55 -0
- data/lib/myspace/classes/interest.rb +16 -0
- data/lib/myspace/classes/mood.rb +9 -0
- data/lib/myspace/classes/photo.rb +21 -0
- data/lib/myspace/classes/profile.rb +22 -0
- data/lib/myspace/classes/status.rb +9 -0
- data/lib/myspace/classes/user.rb +17 -0
- data/lib/myspace/classes/video.rb +41 -0
- data/lib/myspace/connection.rb +110 -0
- data/lib/myspace/error.rb +12 -0
- data/lib/myspace/loader.rb +74 -0
- data/lib/myspace/object.rb +116 -0
- data/tests/test.rb +148 -0
- metadata +108 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Class: MySpace::Mood</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Class</strong></td>
|
|
53
|
+
<td class="class-name-in-header">MySpace::Mood</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../../files/lib/myspace/classes/mood_rb.html">
|
|
59
|
+
lib/myspace/classes/mood.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
<tr class="top-aligned-row">
|
|
66
|
+
<td><strong>Parent:</strong></td>
|
|
67
|
+
<td>
|
|
68
|
+
<a href="Object.html">
|
|
69
|
+
MySpace::Object
|
|
70
|
+
</a>
|
|
71
|
+
</td>
|
|
72
|
+
</tr>
|
|
73
|
+
</table>
|
|
74
|
+
</div>
|
|
75
|
+
<!-- banner header -->
|
|
76
|
+
|
|
77
|
+
<div id="bodyContent">
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
<div id="contextContent">
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
<!-- if includes -->
|
|
92
|
+
|
|
93
|
+
<div id="section">
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
<div id="attribute-list">
|
|
100
|
+
<h3 class="section-bar">Attributes</h3>
|
|
101
|
+
|
|
102
|
+
<div class="name-list">
|
|
103
|
+
<table>
|
|
104
|
+
<tr class="top-aligned-row context-row">
|
|
105
|
+
<td class="context-item-name">mood</td>
|
|
106
|
+
<td class="context-item-value"> [RW] </td>
|
|
107
|
+
<td class="context-item-desc"></td>
|
|
108
|
+
</tr>
|
|
109
|
+
<tr class="top-aligned-row context-row">
|
|
110
|
+
<td class="context-item-name">user</td>
|
|
111
|
+
<td class="context-item-value"> [RW] </td>
|
|
112
|
+
<td class="context-item-desc"></td>
|
|
113
|
+
</tr>
|
|
114
|
+
</table>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
<!-- if method_list -->
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
<div id="validator-badges">
|
|
127
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
</body>
|
|
131
|
+
</html>
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Class: MySpace::Object</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Class</strong></td>
|
|
53
|
+
<td class="class-name-in-header">MySpace::Object</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../../files/lib/myspace/object_rb.html">
|
|
59
|
+
lib/myspace/object.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
<tr class="top-aligned-row">
|
|
66
|
+
<td><strong>Parent:</strong></td>
|
|
67
|
+
<td>
|
|
68
|
+
<a href="Object.html">
|
|
69
|
+
Object
|
|
70
|
+
</a>
|
|
71
|
+
</td>
|
|
72
|
+
</tr>
|
|
73
|
+
</table>
|
|
74
|
+
</div>
|
|
75
|
+
<!-- banner header -->
|
|
76
|
+
|
|
77
|
+
<div id="bodyContent">
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
<div id="contextContent">
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div id="method-list">
|
|
88
|
+
<h3 class="section-bar">Methods</h3>
|
|
89
|
+
|
|
90
|
+
<div class="name-list">
|
|
91
|
+
<a href="#M000032">build_request</a>
|
|
92
|
+
<a href="#M000034">get</a>
|
|
93
|
+
<a href="#M000033">get_raw</a>
|
|
94
|
+
<a href="#M000030">json_to_obj</a>
|
|
95
|
+
<a href="#M000031">json_to_obj_collection</a>
|
|
96
|
+
<a href="#M000029">new</a>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
<!-- if includes -->
|
|
104
|
+
|
|
105
|
+
<div id="section">
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
<!-- if method_list -->
|
|
115
|
+
<div id="methods">
|
|
116
|
+
<h3 class="section-bar">Public Class methods</h3>
|
|
117
|
+
|
|
118
|
+
<div id="method-M000032" class="method-detail">
|
|
119
|
+
<a name="M000032"></a>
|
|
120
|
+
|
|
121
|
+
<div class="method-heading">
|
|
122
|
+
<a href="#M000032" class="method-signature">
|
|
123
|
+
<span class="method-name">build_request</span><span class="method-args">(params,optParams=nil,format="json")</span>
|
|
124
|
+
</a>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<div class="method-description">
|
|
128
|
+
<p>
|
|
129
|
+
Builds a REST request based on the supplied params and optParams
|
|
130
|
+
</p>
|
|
131
|
+
<p><a class="source-toggle" href="#"
|
|
132
|
+
onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
|
|
133
|
+
<div class="method-source-code" id="M000032-source">
|
|
134
|
+
<pre>
|
|
135
|
+
<span class="ruby-comment cmt"># File lib/myspace/object.rb, line 53</span>
|
|
136
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_request</span>(<span class="ruby-identifier">params</span>,<span class="ruby-identifier">optParams</span>=<span class="ruby-keyword kw">nil</span>,<span class="ruby-identifier">format</span>=<span class="ruby-value str">"json"</span>)
|
|
137
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">params</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">!=</span> <span class="ruby-ivar">@numParams</span>
|
|
138
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidRequestParams</span>.<span class="ruby-identifier">new</span>(
|
|
139
|
+
<span class="ruby-node">"#{self}.get needs #{@numParams} (#{@pathFormat})"</span>)
|
|
140
|
+
<span class="ruby-keyword kw">end</span>
|
|
141
|
+
|
|
142
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidRequest</span>.<span class="ruby-identifier">new</span>(
|
|
143
|
+
<span class="ruby-node">"try a collection of #{self} objects"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@pathFormat</span>.<span class="ruby-identifier">nil?</span>
|
|
144
|
+
|
|
145
|
+
<span class="ruby-keyword kw">begin</span>
|
|
146
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-node">"/#{API_VERSION}#{@pathFormat % params}.#{format}"</span>
|
|
147
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
|
148
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidRequestParams</span>.<span class="ruby-identifier">new</span>(
|
|
149
|
+
<span class="ruby-node">"couldn't build a path from params '#{params.join("'")}' \
|
|
150
|
+
and format string #{@pathFormat}. Exception is: (#{e})"</span>)
|
|
151
|
+
<span class="ruby-keyword kw">end</span>
|
|
152
|
+
|
|
153
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">optParams</span>
|
|
154
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidRequestParams</span>.<span class="ruby-identifier">new</span>(
|
|
155
|
+
<span class="ruby-value str">"optParams should be a Hash."</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">optParams</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Hash</span>)
|
|
156
|
+
|
|
157
|
+
<span class="ruby-identifier">path</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">"?"</span>
|
|
158
|
+
|
|
159
|
+
<span class="ruby-identifier">optParams</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
|
160
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@optParams</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@optParams</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">k</span>)
|
|
161
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidRequestParams</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"option '#{k}' is not valid."</span>)
|
|
162
|
+
<span class="ruby-keyword kw">end</span>
|
|
163
|
+
<span class="ruby-identifier">path</span> <span class="ruby-operator">+=</span> <span class="ruby-node">"#{k}=#{v}&"</span>
|
|
164
|
+
}
|
|
165
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp re">/&$/</span>,<span class="ruby-value str">""</span>)
|
|
166
|
+
<span class="ruby-keyword kw">end</span>
|
|
167
|
+
<span class="ruby-identifier">path</span>
|
|
168
|
+
<span class="ruby-keyword kw">end</span>
|
|
169
|
+
</pre>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<div id="method-M000034" class="method-detail">
|
|
175
|
+
<a name="M000034"></a>
|
|
176
|
+
|
|
177
|
+
<div class="method-heading">
|
|
178
|
+
<a href="#M000034" class="method-signature">
|
|
179
|
+
<span class="method-name">get</span><span class="method-args">(params,optParams=nil)</span>
|
|
180
|
+
</a>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<div class="method-description">
|
|
184
|
+
<p>
|
|
185
|
+
Performs a <a href="Object.html#M000034">get</a> request to the API servers
|
|
186
|
+
and returns some <a href="../MySpace.html">MySpace</a> object
|
|
187
|
+
</p>
|
|
188
|
+
<p><a class="source-toggle" href="#"
|
|
189
|
+
onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
|
|
190
|
+
<div class="method-source-code" id="M000034-source">
|
|
191
|
+
<pre>
|
|
192
|
+
<span class="ruby-comment cmt"># File lib/myspace/object.rb, line 94</span>
|
|
193
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">params</span>,<span class="ruby-identifier">optParams</span>=<span class="ruby-keyword kw">nil</span>)
|
|
194
|
+
|
|
195
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">build_request</span>(<span class="ruby-identifier">params</span>,<span class="ruby-identifier">optParams</span>)
|
|
196
|
+
<span class="ruby-comment cmt">#puts "#{path} pathFormat #{@pathFormat} childType #{@childType} </span>
|
|
197
|
+
<span class="ruby-comment cmt">#childBase #{@childBase} numParams #{@numParams}"</span>
|
|
198
|
+
|
|
199
|
+
<span class="ruby-identifier">body</span> = <span class="ruby-constant">MySpace</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">get_body</span>(<span class="ruby-identifier">path</span>)
|
|
200
|
+
|
|
201
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@dataType</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"Hash"</span>
|
|
202
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">json_to_obj</span>(<span class="ruby-identifier">body</span>)
|
|
203
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@dataType</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"Array"</span>
|
|
204
|
+
<span class="ruby-identifier">body</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp re">/\{"Groups"\:/</span>,<span class="ruby-value str">'{"groups":'</span>) <span class="ruby-comment cmt"># you did not see this</span>
|
|
205
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">json_to_obj_collection</span>(<span class="ruby-identifier">body</span>)
|
|
206
|
+
<span class="ruby-keyword kw">else</span>
|
|
207
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidRequestParams</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{@dataType} is not a valid data type."</span>)
|
|
208
|
+
<span class="ruby-keyword kw">end</span>
|
|
209
|
+
<span class="ruby-keyword kw">end</span>
|
|
210
|
+
</pre>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
<div id="method-M000033" class="method-detail">
|
|
216
|
+
<a name="M000033"></a>
|
|
217
|
+
|
|
218
|
+
<div class="method-heading">
|
|
219
|
+
<a href="#M000033" class="method-signature">
|
|
220
|
+
<span class="method-name">get_raw</span><span class="method-args">(params,optParams=nil,format="json")</span>
|
|
221
|
+
</a>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<div class="method-description">
|
|
225
|
+
<p>
|
|
226
|
+
Performs a request to the API servers and returns the raw JSON/XML
|
|
227
|
+
</p>
|
|
228
|
+
<p><a class="source-toggle" href="#"
|
|
229
|
+
onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
|
|
230
|
+
<div class="method-source-code" id="M000033-source">
|
|
231
|
+
<pre>
|
|
232
|
+
<span class="ruby-comment cmt"># File lib/myspace/object.rb, line 88</span>
|
|
233
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_raw</span>(<span class="ruby-identifier">params</span>,<span class="ruby-identifier">optParams</span>=<span class="ruby-keyword kw">nil</span>,<span class="ruby-identifier">format</span>=<span class="ruby-value str">"json"</span>)
|
|
234
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">build_request</span>(<span class="ruby-identifier">params</span>,<span class="ruby-identifier">optParams</span>,<span class="ruby-identifier">format</span>)
|
|
235
|
+
<span class="ruby-constant">MySpace</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">get_body</span>(<span class="ruby-identifier">path</span>)
|
|
236
|
+
<span class="ruby-keyword kw">end</span>
|
|
237
|
+
</pre>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<div id="method-M000030" class="method-detail">
|
|
243
|
+
<a name="M000030"></a>
|
|
244
|
+
|
|
245
|
+
<div class="method-heading">
|
|
246
|
+
<a href="#M000030" class="method-signature">
|
|
247
|
+
<span class="method-name">json_to_obj</span><span class="method-args">(body)</span>
|
|
248
|
+
</a>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<div class="method-description">
|
|
252
|
+
<p>
|
|
253
|
+
Attempts to convert JSON to <a href="../MySpace.html">MySpace</a> objects
|
|
254
|
+
</p>
|
|
255
|
+
<p><a class="source-toggle" href="#"
|
|
256
|
+
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
|
257
|
+
<div class="method-source-code" id="M000030-source">
|
|
258
|
+
<pre>
|
|
259
|
+
<span class="ruby-comment cmt"># File lib/myspace/object.rb, line 25</span>
|
|
260
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">json_to_obj</span>(<span class="ruby-identifier">body</span>)
|
|
261
|
+
<span class="ruby-keyword kw">begin</span>
|
|
262
|
+
<span class="ruby-identifier">obj</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">body</span>))
|
|
263
|
+
<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">user</span> = <span class="ruby-constant">MySpace</span><span class="ruby-operator">::</span><span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">user</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">"user"</span>)
|
|
264
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
|
265
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidResponse</span>, <span class="ruby-node">"could not parse json from #{body}: '#{e}'"</span>
|
|
266
|
+
<span class="ruby-keyword kw">end</span>
|
|
267
|
+
<span class="ruby-identifier">obj</span>
|
|
268
|
+
<span class="ruby-keyword kw">end</span>
|
|
269
|
+
</pre>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
<div id="method-M000031" class="method-detail">
|
|
275
|
+
<a name="M000031"></a>
|
|
276
|
+
|
|
277
|
+
<div class="method-heading">
|
|
278
|
+
<a href="#M000031" class="method-signature">
|
|
279
|
+
<span class="method-name">json_to_obj_collection</span><span class="method-args">(body)</span>
|
|
280
|
+
</a>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<div class="method-description">
|
|
284
|
+
<p>
|
|
285
|
+
Attempts to convert JSON to a <a href="../MySpace.html">MySpace</a> objects
|
|
286
|
+
(with child collections)
|
|
287
|
+
</p>
|
|
288
|
+
<p><a class="source-toggle" href="#"
|
|
289
|
+
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
|
|
290
|
+
<div class="method-source-code" id="M000031-source">
|
|
291
|
+
<pre>
|
|
292
|
+
<span class="ruby-comment cmt"># File lib/myspace/object.rb, line 36</span>
|
|
293
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">json_to_obj_collection</span>(<span class="ruby-identifier">body</span>)
|
|
294
|
+
<span class="ruby-keyword kw">begin</span>
|
|
295
|
+
<span class="ruby-identifier">obj</span> = <span class="ruby-identifier">json_to_obj</span>(<span class="ruby-identifier">body</span>)
|
|
296
|
+
|
|
297
|
+
<span class="ruby-identifier">col</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">instance_variable_get</span> <span class="ruby-node">"@#{@childBase}"</span>
|
|
298
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidResponse</span>, <span class="ruby-node">"No '#{@childBase}' in response"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">col</span>
|
|
299
|
+
|
|
300
|
+
<span class="ruby-identifier">col</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">instance_variable_set</span> <span class="ruby-node">"@#{@childBase}"</span>,
|
|
301
|
+
<span class="ruby-identifier">col</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">eval</span>(<span class="ruby-node">"#{@childType}.new(o)"</span>) }
|
|
302
|
+
|
|
303
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
|
304
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidResponse</span>, <span class="ruby-node">"could not parse json from #{body}: '#{e}'"</span>
|
|
305
|
+
<span class="ruby-keyword kw">end</span>
|
|
306
|
+
<span class="ruby-identifier">obj</span>
|
|
307
|
+
<span class="ruby-keyword kw">end</span>
|
|
308
|
+
</pre>
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
</div>
|
|
312
|
+
|
|
313
|
+
<div id="method-M000029" class="method-detail">
|
|
314
|
+
<a name="M000029"></a>
|
|
315
|
+
|
|
316
|
+
<div class="method-heading">
|
|
317
|
+
<a href="#M000029" class="method-signature">
|
|
318
|
+
<span class="method-name">new</span><span class="method-args">(attribs={})</span>
|
|
319
|
+
</a>
|
|
320
|
+
</div>
|
|
321
|
+
|
|
322
|
+
<div class="method-description">
|
|
323
|
+
<p><a class="source-toggle" href="#"
|
|
324
|
+
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
|
325
|
+
<div class="method-source-code" id="M000029-source">
|
|
326
|
+
<pre>
|
|
327
|
+
<span class="ruby-comment cmt"># File lib/myspace/object.rb, line 19</span>
|
|
328
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">attribs</span>={})
|
|
329
|
+
<span class="ruby-identifier">attribs</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">key</span>,<span class="ruby-identifier">val</span><span class="ruby-operator">|</span> <span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">"@#{key}"</span>,<span class="ruby-identifier">val</span>) }
|
|
330
|
+
<span class="ruby-keyword kw">end</span>
|
|
331
|
+
</pre>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
</div>
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
</div>
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
</div>
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
<div id="validator-badges">
|
|
344
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
</body>
|
|
348
|
+
</html>
|