badgeville_berlin 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardoc/checksums +17 -17
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/README.md +3 -0
- data/README_ADVANCED.md +3 -1
- data/doc/BadgevilleBerlin.html +32 -22
- data/doc/BadgevilleBerlin/Activity.html +43 -27
- data/doc/BadgevilleBerlin/ActivityDefinition.html +46 -27
- data/doc/BadgevilleBerlin/BaseResource.html +488 -94
- data/doc/BadgevilleBerlin/Config.html +66 -45
- data/doc/BadgevilleBerlin/Errors.html +48 -36
- data/doc/BadgevilleBerlin/Group.html +46 -27
- data/doc/BadgevilleBerlin/Leaderboard.html +46 -27
- data/doc/BadgevilleBerlin/Player.html +65 -26
- data/doc/BadgevilleBerlin/Reward.html +43 -27
- data/doc/BadgevilleBerlin/RewardDefinition.html +46 -27
- data/doc/BadgevilleBerlin/Site.html +43 -27
- data/doc/BadgevilleBerlin/Team.html +174 -0
- data/doc/BadgevilleBerlin/Track.html +43 -27
- data/doc/BadgevilleBerlin/User.html +43 -27
- data/doc/BadgevilleBerlinJsonFormat.html +92 -92
- data/doc/_index.html +46 -35
- data/doc/class_list.html +12 -6
- data/doc/css/full_list.css +6 -2
- data/doc/css/style.css +58 -50
- data/doc/file.README.html +194 -78
- data/doc/file_list.html +12 -6
- data/doc/frames.html +20 -5
- data/doc/index.html +194 -78
- data/doc/js/app.js +54 -45
- data/doc/js/full_list.js +36 -13
- data/doc/js/jquery.js +4 -16
- data/doc/method_list.html +53 -15
- data/doc/top-level-namespace.html +27 -18
- data/lib/badgeville_berlin/version.rb +1 -1
- metadata +4 -2
data/doc/file.README.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.
|
9
|
+
— Documentation by YARD 0.8.2.1
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -15,10 +15,12 @@
|
|
15
15
|
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
16
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
18
19
|
relpath = '';
|
19
|
-
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
20
21
|
</script>
|
21
22
|
|
23
|
+
|
22
24
|
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
23
25
|
|
24
26
|
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
@@ -26,148 +28,262 @@
|
|
26
28
|
|
27
29
|
</head>
|
28
30
|
<body>
|
29
|
-
<script type="text/javascript" charset="utf-8">
|
30
|
-
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
-
</script>
|
32
|
-
|
33
31
|
<div id="header">
|
34
32
|
<div id="menu">
|
35
33
|
|
36
|
-
<a href="_index.html"
|
34
|
+
<a href="_index.html">Index</a> »
|
37
35
|
<span class="title">File: README</span>
|
38
36
|
|
39
|
-
|
37
|
+
|
40
38
|
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
39
|
</div>
|
42
40
|
|
43
41
|
<div id="search">
|
44
42
|
|
45
|
-
<a
|
43
|
+
<a class="full_list_link" id="class_list_link"
|
44
|
+
href="class_list.html">
|
45
|
+
Class List
|
46
|
+
</a>
|
46
47
|
|
47
|
-
<a
|
48
|
+
<a class="full_list_link" id="method_list_link"
|
49
|
+
href="method_list.html">
|
50
|
+
Method List
|
51
|
+
</a>
|
48
52
|
|
49
|
-
<a
|
53
|
+
<a class="full_list_link" id="file_list_link"
|
54
|
+
href="file_list.html">
|
55
|
+
File List
|
56
|
+
</a>
|
50
57
|
|
51
58
|
</div>
|
52
59
|
<div class="clear"></div>
|
53
60
|
</div>
|
54
|
-
|
61
|
+
|
55
62
|
<iframe id="search_frame"></iframe>
|
56
|
-
|
63
|
+
|
57
64
|
<div id="content"><div id='filecontents'><h1>Badgeville RESTful Wrapper for Berlin API -- Basic README</h1>
|
58
65
|
|
59
|
-
<p>This is
|
66
|
+
<p>This is an open source Ruby wrapper for interacting with the <a href="http://rules.badgeville.com/display/doc/2.0+Core+API+Documentation">Badgeville RESTful Berlin API</a>.</p>
|
60
67
|
|
61
68
|
<h2>Features</h2>
|
62
69
|
|
63
70
|
<ul>
|
64
|
-
<li>Uses the activeresource (3.
|
65
|
-
<li>Allows creating, reading (finding), updating and deleting the following classes of remote resources: Site, User, Player, ActivityDefinition, Activity.</li>
|
71
|
+
<li>Uses the activeresource (3.1.3) gem to map ActiveModel-like RESTful methods to resources on the remote Badgeville server.</li>
|
72
|
+
<li>Allows creating, reading (finding), updating and deleting the following classes of remote resources: Site, User, Player, ActivityDefinition, Activity, Reward and RewardDefinition.</li>
|
66
73
|
</ul>
|
67
74
|
|
68
75
|
|
69
76
|
<h2>Basic Examples</h2>
|
70
77
|
|
71
|
-
<h3>1. Configure the gem to use your Badgeville API Key and the site to which your requests should go.</h3>
|
78
|
+
<h3>1. Configure the gem to use your Badgeville Private API Key and the site to which your requests should go.</h3>
|
72
79
|
|
73
|
-
<p
|
74
|
-
BadgevilleBerlin::Config.conf(
|
75
|
-
:site => "http://sandbox.v2.badgeville.com",
|
76
|
-
:api_key => MY_API_KEY)
|
77
|
-
</code></p>
|
80
|
+
<p>```ruby</p>
|
78
81
|
|
79
|
-
<
|
82
|
+
<pre class="code ruby"><code> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_conf'>conf</span><span class='lparen'>(</span>
|
83
|
+
<span class='symbol'>:host_name</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>http://example.com</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
84
|
+
<span class='symbol'>:api_key</span> <span class='op'>=></span> <span class='const'>MY_API_KEY</span><span class='rparen'>)</span>
|
85
|
+
</code></pre>
|
80
86
|
|
81
|
-
<p
|
82
|
-
|
83
|
-
:name => "My Website",
|
84
|
-
:url => "mydomain.com",
|
85
|
-
:network_id => MY_NETWORK_ID )
|
86
|
-
success = new_site.save
|
87
|
-
</code></p>
|
87
|
+
<p>```
|
88
|
+
:host_name should be the Badgeville endpoint that receives your calls, NOT your site URL. Example: "http://sandbox.v2.badgeville.com"</p>
|
88
89
|
|
89
|
-
<h3>
|
90
|
+
<h3>2. Add a new site to your network. Find your network ID the Publisher Module's tabbed menu ( Develop > Home ) or contact <a href="mailto:support@badgeville.com">support@badgeville.com</a></h3>
|
90
91
|
|
91
|
-
<p
|
92
|
-
new_user = BadgevilleBerlin::User.new(
|
93
|
-
:name => 'visitor_username',
|
94
|
-
:network_id => MY_NETWORK_ID,
|
95
|
-
:email => 'visitor@emailserver.com',
|
96
|
-
:password => 'visitor_password' )
|
97
|
-
success = new_user.save
|
98
|
-
</code></p>
|
92
|
+
<p>```ruby</p>
|
99
93
|
|
100
|
-
<
|
94
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_new_site'>new_site</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>Site</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
95
|
+
<span class='symbol'>:name</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>My Website</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
96
|
+
<span class='symbol'>:url</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>mydomain.com</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
97
|
+
<span class='symbol'>:network_id</span> <span class='op'>=></span> <span class='const'>MY_NETWORK_ID</span> <span class='rparen'>)</span>
|
98
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_new_site'>new_site</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
99
|
+
</code></pre>
|
101
100
|
|
102
|
-
<p
|
103
|
-
user_found_by_id = BadgevilleBerlin::User.find( new_user.id )
|
104
|
-
user_found_by_id.email = 'revised_visitor@emailserver.com'
|
105
|
-
success = user_found_by_id.save
|
106
|
-
</code></p>
|
101
|
+
<p>```</p>
|
107
102
|
|
108
|
-
<h3>
|
103
|
+
<h3>3. Create a user on your network.</h3>
|
109
104
|
|
110
|
-
<
|
111
|
-
|
112
|
-
|
113
|
-
:user_id => new_user.id )
|
114
|
-
success = new_player.save
|
115
|
-
</code></p>
|
105
|
+
<ul>
|
106
|
+
<li>See the API Explorer for required and optional parameters.</li>
|
107
|
+
</ul>
|
116
108
|
|
117
|
-
<h3>6. Register a player behavior (e.g. share) for the newly created player.</h3>
|
118
109
|
|
119
|
-
<p
|
120
|
-
new_activity = BadgevilleBerlin::Activity.new(
|
121
|
-
:verb => 'share',
|
122
|
-
:player_id => new_player.id )
|
123
|
-
success = new_activity.save
|
124
|
-
</code></p>
|
110
|
+
<p>```ruby</p>
|
125
111
|
|
126
|
-
<
|
112
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_new_user'>new_user</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
113
|
+
<span class='symbol'>:name</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor_username</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
114
|
+
<span class='symbol'>:network_id</span> <span class='op'>=></span> <span class='const'>MY_NETWORK_ID</span><span class='comma'>,</span>
|
115
|
+
<span class='symbol'>:email</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor@emailserver.com</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
116
|
+
<span class='symbol'>:password</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor_password</span><span class='tstring_end'>'</span></span> <span class='rparen'>)</span>
|
117
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_new_user'>new_user</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
118
|
+
</code></pre>
|
127
119
|
|
128
|
-
<
|
120
|
+
<p>```</p>
|
121
|
+
|
122
|
+
<h3>4. See error messages from the remote server.</h3>
|
123
|
+
|
124
|
+
<ul>
|
125
|
+
<li>Here we attempt to create a second user on the network with the same email as the first user.</li>
|
126
|
+
<li>See the API Explorer for required and optional parameters.</li>
|
127
|
+
</ul>
|
128
|
+
|
129
|
+
|
130
|
+
<p>```ruby</p>
|
131
|
+
|
132
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_new_user2'>new_user2</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
133
|
+
<span class='symbol'>:name</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor_username</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
134
|
+
<span class='symbol'>:network_id</span> <span class='op'>=></span> <span class='const'>MY_NETWORK_ID</span><span class='comma'>,</span>
|
135
|
+
<span class='symbol'>:email</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor@emailserver.com</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
136
|
+
<span class='symbol'>:password</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor_password</span><span class='tstring_end'>'</span></span> <span class='rparen'>)</span>
|
137
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_new_user2'>new_user2</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
138
|
+
|
139
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_new_user2'>new_user2</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_messages'>messages</span> <span class='comment'># {:email=>["user email is already taken"]}
|
140
|
+
</span> <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_new_user2'>new_user2</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='lbracket'>[</span><span class='symbol'>:email</span><span class='rbracket'>]</span> <span class='comment'># ["user email is already taken"]
|
141
|
+
</span></code></pre>
|
142
|
+
|
143
|
+
<p>```</p>
|
144
|
+
|
145
|
+
<h3>5. Find a user to update user properties.</h3>
|
146
|
+
|
147
|
+
<ul>
|
148
|
+
<li>Here we find the newly created user by ID to update their email address.</li>
|
149
|
+
<li>See the API Explorer for a full list of user properties to update.</li>
|
150
|
+
</ul>
|
151
|
+
|
152
|
+
|
153
|
+
<p>```ruby</p>
|
154
|
+
|
155
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_user_found_by_id'>user_found_by_id</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span> <span class='id identifier rubyid_new_user'>new_user</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='rparen'>)</span>
|
156
|
+
<span class='id identifier rubyid_user_found_by_id'>user_found_by_id</span><span class='period'>.</span><span class='id identifier rubyid_email'>email</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>revised_visitor@emailserver.com</span><span class='tstring_end'>'</span></span>
|
157
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_user_found_by_id'>user_found_by_id</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
158
|
+
|
159
|
+
<span class='id identifier rubyid_updated_user'>updated_user</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span> <span class='id identifier rubyid_new_user'>new_user</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='rparen'>)</span>
|
160
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_updated_user'>updated_user</span><span class='period'>.</span><span class='id identifier rubyid_email'>email</span> <span class='comment'># revised_visitor@emailserver.com
|
161
|
+
</span></code></pre>
|
162
|
+
|
163
|
+
<p>```</p>
|
164
|
+
|
165
|
+
<h3>6. Create a player.</h3>
|
166
|
+
|
167
|
+
<ul>
|
168
|
+
<li>Here we create a player for the new site, corresponding to the user with the updated email address.</li>
|
169
|
+
<li>See the API Explorer for required and optional parameters.</li>
|
170
|
+
</ul>
|
129
171
|
|
130
|
-
<p>Print HTTP requests and JSON responses by installing the "logger" gem and including this code in your script.</p>
|
131
172
|
|
132
|
-
<p>```ruby
|
133
|
-
|
134
|
-
BadgevilleBerlin
|
135
|
-
|
173
|
+
<p>```ruby</p>
|
174
|
+
|
175
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_new_player'>new_player</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>Player</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
176
|
+
<span class='symbol'>:site_id</span> <span class='op'>=></span> <span class='id identifier rubyid_new_site'>new_site</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='comma'>,</span>
|
177
|
+
<span class='symbol'>:user_id</span> <span class='op'>=></span> <span class='id identifier rubyid_user_found_by_id'>user_found_by_id</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='rparen'>)</span>
|
178
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_new_player'>new_player</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
179
|
+
</code></pre>
|
180
|
+
|
181
|
+
<p>```</p>
|
182
|
+
|
183
|
+
<h3>7. Find existing players by email.</h3>
|
184
|
+
|
185
|
+
<ul>
|
186
|
+
<li>Here we find an existing player by email.</li>
|
187
|
+
<li>To get all players on the network that match the email, we have passed :all.</li>
|
188
|
+
<li>You can alternatively pass :first or :last in the place of :all.</li>
|
189
|
+
</ul>
|
190
|
+
|
191
|
+
|
192
|
+
<p>``` ruby</p>
|
193
|
+
|
194
|
+
<pre class="code ruby"><code> <span class='ivar'>@existing_player</span> <span class='op'>=</span> <span class='const'>Player</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='symbol'>:all</span><span class='comma'>,</span> <span class='symbol'>:params</span> <span class='op'>=></span> <span class='lbrace'>{</span><span class='symbol'>:email</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>revised_visitor@emailserver.com</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
195
|
+
</code></pre>
|
196
|
+
|
197
|
+
<p>```</p>
|
198
|
+
|
199
|
+
<h3>8. Register a player behavior.</h3>
|
200
|
+
|
201
|
+
<ul>
|
202
|
+
<li>Here we record the fact that the newly created player performed a "share" behavior.</li>
|
203
|
+
<li>See the API Explorer for required and optional parameters.</li>
|
204
|
+
</ul>
|
205
|
+
|
206
|
+
|
207
|
+
<p>```ruby</p>
|
208
|
+
|
209
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_new_activity'>new_activity</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>Activity</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
210
|
+
<span class='symbol'>:verb</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>share</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
211
|
+
<span class='symbol'>:player_id</span> <span class='op'>=></span> <span class='id identifier rubyid_new_player'>new_player</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='rparen'>)</span>
|
212
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_new_activity'>new_activity</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
213
|
+
</code></pre>
|
136
214
|
|
137
215
|
<p>```</p>
|
138
216
|
|
139
|
-
<
|
217
|
+
<h2>Monitoring HTTP Requests and JSON Responses</h2>
|
218
|
+
|
219
|
+
<p>Print HTTP requests and JSON responses by installing the "logger" gem and including this code in your script.</p>
|
140
220
|
|
141
|
-
<p
|
221
|
+
<p>```ruby</p>
|
142
222
|
|
143
|
-
<
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
223
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>logger</span><span class='tstring_end'>'</span></span>
|
224
|
+
<span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>BaseResource</span><span class='period'>.</span><span class='id identifier rubyid_logger'>logger</span> <span class='op'>=</span> <span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>STDOUT</span><span class='rparen'>)</span>
|
225
|
+
<span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>BaseResource</span><span class='period'>.</span><span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_level'>level</span> <span class='op'>=</span> <span class='const'>Logger</span><span class='op'>::</span><span class='const'>DEBUG</span>
|
226
|
+
</code></pre>
|
227
|
+
|
228
|
+
<p>```</p>
|
148
229
|
|
149
230
|
<h2>Dependencies</h2>
|
150
231
|
|
151
232
|
<ul>
|
152
233
|
<li>activeresource (3.1.3) - Provides Ruby classes to RESTfully interact with remote resources.</li>
|
153
|
-
<li>logger (1.2.8) - Provides logging to the standard output stream.</li>
|
154
234
|
</ul>
|
155
235
|
|
156
236
|
|
157
237
|
<h2>Installation</h2>
|
158
238
|
|
159
|
-
<p>
|
239
|
+
<p>gem install badgeville_berlin</p>
|
160
240
|
|
161
241
|
<h2>Documentation</h2>
|
162
242
|
|
163
243
|
<p>For more documentation on how the Badgeville RESTful Berlin API works, see [here] (http://rules.badgeville.com/display/doc/2.0+Core+API+Documentation).</p>
|
164
244
|
|
245
|
+
<h2>Submitting an Issue</h2>
|
246
|
+
|
247
|
+
<p>You can use the <a href="https://github.com/badgeville/badgeville-ruby/issues">GitHub issue tracker</a> to report bugs. After ensuring that the bug has not already been submitted, please submit:</p>
|
248
|
+
|
249
|
+
<ol>
|
250
|
+
<li>A <a href="https://gist.github.com/">gist</a> a that contains a stack trace.</li>
|
251
|
+
<li>Details needed to reproduce the bug, including gem version, Ruby version and operating system.</li>
|
252
|
+
</ol>
|
253
|
+
|
254
|
+
|
255
|
+
<h2>Submitting a Pull Request</h2>
|
256
|
+
|
257
|
+
<ol>
|
258
|
+
<li>Click the GitHub "Fork" button to fork this project.</li>
|
259
|
+
<li><p>Clone the repository for a local copy:</p>
|
260
|
+
|
261
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_git'>git</span> <span class='id identifier rubyid_clone'>clone</span> <span class='id identifier rubyid_git'>git</span><span class='ivar'>@github</span><span class='period'>.</span><span class='id identifier rubyid_com'>com</span><span class='symbol'>:username</span><span class='op'>/</span><span class='id identifier rubyid_badgeville'>badgeville</span><span class='op'>-</span><span class='id identifier rubyid_ruby'>ruby</span><span class='period'>.</span><span class='id identifier rubyid_git'>git</span>
|
262
|
+
</code></pre></li>
|
263
|
+
<li><p>Create a topic branch:</p>
|
264
|
+
|
265
|
+
<pre class="code ruby"><code> git checkout -b my_bug_fix_or_feature_branch
|
266
|
+
</code></pre></li>
|
267
|
+
<li><p>Add documentation and specs for your bug fix or feature.</p></li>
|
268
|
+
<li>Implement your bug fix or feature.</li>
|
269
|
+
<li><p>Run the following command to ensure your tests cover your changes:</p>
|
270
|
+
|
271
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_bundle'>bundle</span> <span class='id identifier rubyid_exec'>exec</span> <span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_spec'>spec</span>
|
272
|
+
</code></pre></li>
|
273
|
+
<li><p>Commit and push your changes.</p></li>
|
274
|
+
<li>Click the GitHub "Pull Request" to submit a pull request. Please do not include changes to the gemspec, version or history file.</li>
|
275
|
+
</ol>
|
276
|
+
|
277
|
+
|
278
|
+
<p>-## Contributors
|
279
|
+
-David Czarnecki wrote the initial gem that inspired this wrapper.</p>
|
280
|
+
|
165
281
|
<p>Copyright (c) 2012 Badgeville.</p></div></div>
|
166
|
-
|
282
|
+
|
167
283
|
<div id="footer">
|
168
|
-
Generated on
|
284
|
+
Generated on Wed Jan 8 10:43:04 2014 by
|
169
285
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
170
|
-
0.
|
286
|
+
0.8.2.1 (ruby-1.9.2).
|
171
287
|
</div>
|
172
288
|
|
173
289
|
</body>
|
data/doc/file_list.html
CHANGED
@@ -8,13 +8,13 @@
|
|
8
8
|
|
9
9
|
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
10
|
|
11
|
-
|
11
|
+
|
12
12
|
|
13
13
|
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
14
14
|
|
15
15
|
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
16
|
|
17
|
-
|
17
|
+
|
18
18
|
<base id="base_target" target="_parent" />
|
19
19
|
</head>
|
20
20
|
<body>
|
@@ -28,16 +28,22 @@
|
|
28
28
|
<h1 id="full_list_header">File List</h1>
|
29
29
|
<div id="nav">
|
30
30
|
|
31
|
-
<a target="_self" href="class_list.html">
|
31
|
+
<span><a target="_self" href="class_list.html">
|
32
|
+
Classes
|
33
|
+
</a></span>
|
32
34
|
|
33
|
-
<a target="_self" href="method_list.html">
|
35
|
+
<span><a target="_self" href="method_list.html">
|
36
|
+
Methods
|
37
|
+
</a></span>
|
34
38
|
|
35
|
-
<a target="_self" href="file_list.html">
|
39
|
+
<span><a target="_self" href="file_list.html">
|
40
|
+
Files
|
41
|
+
</a></span>
|
36
42
|
|
37
43
|
</div>
|
38
44
|
<div id="search">Search: <input type="text" /></div>
|
39
45
|
|
40
|
-
<ul id="full_list" class="
|
46
|
+
<ul id="full_list" class="file">
|
41
47
|
|
42
48
|
|
43
49
|
<li class="r1"><a href="index.html" title="README">README</a></li>
|
data/doc/frames.html
CHANGED
@@ -4,10 +4,25 @@
|
|
4
4
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
5
|
<head>
|
6
6
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
-
<title>Documentation by YARD 0.
|
7
|
+
<title>Documentation by YARD 0.8.2.1</title>
|
8
8
|
</head>
|
9
|
-
<
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
<script type="text/javascript" charset="utf-8">
|
10
|
+
window.onload = function() {
|
11
|
+
var match = window.location.hash.match(/^#!(.+)/);
|
12
|
+
var name = 'index.html';
|
13
|
+
if (match) {
|
14
|
+
name = unescape(match[1]);
|
15
|
+
}
|
16
|
+
document.writeln('<frameset cols="20%,*">' +
|
17
|
+
'<frame name="list" src="class_list.html" />' +
|
18
|
+
'<frame name="main" src="' + name + '" />' +
|
19
|
+
'</frameset>');
|
20
|
+
}
|
21
|
+
</script>
|
22
|
+
<noscript>
|
23
|
+
<frameset cols="20%,*">
|
24
|
+
<frame name="list" src="class_list.html" />
|
25
|
+
<frame name="main" src="index.html" />
|
26
|
+
</frameset>
|
27
|
+
</noscript>
|
13
28
|
</html>
|
data/doc/index.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.
|
9
|
+
— Documentation by YARD 0.8.2.1
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -15,10 +15,12 @@
|
|
15
15
|
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
16
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
18
19
|
relpath = '';
|
19
|
-
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
20
21
|
</script>
|
21
22
|
|
23
|
+
|
22
24
|
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
23
25
|
|
24
26
|
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
@@ -26,148 +28,262 @@
|
|
26
28
|
|
27
29
|
</head>
|
28
30
|
<body>
|
29
|
-
<script type="text/javascript" charset="utf-8">
|
30
|
-
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
-
</script>
|
32
|
-
|
33
31
|
<div id="header">
|
34
32
|
<div id="menu">
|
35
33
|
|
36
|
-
<a href="_index.html"
|
34
|
+
<a href="_index.html">Index</a> »
|
37
35
|
<span class="title">File: README</span>
|
38
36
|
|
39
|
-
|
37
|
+
|
40
38
|
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
39
|
</div>
|
42
40
|
|
43
41
|
<div id="search">
|
44
42
|
|
45
|
-
<a
|
43
|
+
<a class="full_list_link" id="class_list_link"
|
44
|
+
href="class_list.html">
|
45
|
+
Class List
|
46
|
+
</a>
|
46
47
|
|
47
|
-
<a
|
48
|
+
<a class="full_list_link" id="method_list_link"
|
49
|
+
href="method_list.html">
|
50
|
+
Method List
|
51
|
+
</a>
|
48
52
|
|
49
|
-
<a
|
53
|
+
<a class="full_list_link" id="file_list_link"
|
54
|
+
href="file_list.html">
|
55
|
+
File List
|
56
|
+
</a>
|
50
57
|
|
51
58
|
</div>
|
52
59
|
<div class="clear"></div>
|
53
60
|
</div>
|
54
|
-
|
61
|
+
|
55
62
|
<iframe id="search_frame"></iframe>
|
56
|
-
|
63
|
+
|
57
64
|
<div id="content"><div id='filecontents'><h1>Badgeville RESTful Wrapper for Berlin API -- Basic README</h1>
|
58
65
|
|
59
|
-
<p>This is
|
66
|
+
<p>This is an open source Ruby wrapper for interacting with the <a href="http://rules.badgeville.com/display/doc/2.0+Core+API+Documentation">Badgeville RESTful Berlin API</a>.</p>
|
60
67
|
|
61
68
|
<h2>Features</h2>
|
62
69
|
|
63
70
|
<ul>
|
64
|
-
<li>Uses the activeresource (3.
|
65
|
-
<li>Allows creating, reading (finding), updating and deleting the following classes of remote resources: Site, User, Player, ActivityDefinition, Activity.</li>
|
71
|
+
<li>Uses the activeresource (3.1.3) gem to map ActiveModel-like RESTful methods to resources on the remote Badgeville server.</li>
|
72
|
+
<li>Allows creating, reading (finding), updating and deleting the following classes of remote resources: Site, User, Player, ActivityDefinition, Activity, Reward and RewardDefinition.</li>
|
66
73
|
</ul>
|
67
74
|
|
68
75
|
|
69
76
|
<h2>Basic Examples</h2>
|
70
77
|
|
71
|
-
<h3>1. Configure the gem to use your Badgeville API Key and the site to which your requests should go.</h3>
|
78
|
+
<h3>1. Configure the gem to use your Badgeville Private API Key and the site to which your requests should go.</h3>
|
72
79
|
|
73
|
-
<p
|
74
|
-
BadgevilleBerlin::Config.conf(
|
75
|
-
:site => "http://sandbox.v2.badgeville.com",
|
76
|
-
:api_key => MY_API_KEY)
|
77
|
-
</code></p>
|
80
|
+
<p>```ruby</p>
|
78
81
|
|
79
|
-
<
|
82
|
+
<pre class="code ruby"><code> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_conf'>conf</span><span class='lparen'>(</span>
|
83
|
+
<span class='symbol'>:host_name</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>http://example.com</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
84
|
+
<span class='symbol'>:api_key</span> <span class='op'>=></span> <span class='const'>MY_API_KEY</span><span class='rparen'>)</span>
|
85
|
+
</code></pre>
|
80
86
|
|
81
|
-
<p
|
82
|
-
|
83
|
-
:name => "My Website",
|
84
|
-
:url => "mydomain.com",
|
85
|
-
:network_id => MY_NETWORK_ID )
|
86
|
-
success = new_site.save
|
87
|
-
</code></p>
|
87
|
+
<p>```
|
88
|
+
:host_name should be the Badgeville endpoint that receives your calls, NOT your site URL. Example: "http://sandbox.v2.badgeville.com"</p>
|
88
89
|
|
89
|
-
<h3>
|
90
|
+
<h3>2. Add a new site to your network. Find your network ID the Publisher Module's tabbed menu ( Develop > Home ) or contact <a href="mailto:support@badgeville.com">support@badgeville.com</a></h3>
|
90
91
|
|
91
|
-
<p
|
92
|
-
new_user = BadgevilleBerlin::User.new(
|
93
|
-
:name => 'visitor_username',
|
94
|
-
:network_id => MY_NETWORK_ID,
|
95
|
-
:email => 'visitor@emailserver.com',
|
96
|
-
:password => 'visitor_password' )
|
97
|
-
success = new_user.save
|
98
|
-
</code></p>
|
92
|
+
<p>```ruby</p>
|
99
93
|
|
100
|
-
<
|
94
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_new_site'>new_site</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>Site</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
95
|
+
<span class='symbol'>:name</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>My Website</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
96
|
+
<span class='symbol'>:url</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>mydomain.com</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
97
|
+
<span class='symbol'>:network_id</span> <span class='op'>=></span> <span class='const'>MY_NETWORK_ID</span> <span class='rparen'>)</span>
|
98
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_new_site'>new_site</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
99
|
+
</code></pre>
|
101
100
|
|
102
|
-
<p
|
103
|
-
user_found_by_id = BadgevilleBerlin::User.find( new_user.id )
|
104
|
-
user_found_by_id.email = 'revised_visitor@emailserver.com'
|
105
|
-
success = user_found_by_id.save
|
106
|
-
</code></p>
|
101
|
+
<p>```</p>
|
107
102
|
|
108
|
-
<h3>
|
103
|
+
<h3>3. Create a user on your network.</h3>
|
109
104
|
|
110
|
-
<
|
111
|
-
|
112
|
-
|
113
|
-
:user_id => new_user.id )
|
114
|
-
success = new_player.save
|
115
|
-
</code></p>
|
105
|
+
<ul>
|
106
|
+
<li>See the API Explorer for required and optional parameters.</li>
|
107
|
+
</ul>
|
116
108
|
|
117
|
-
<h3>6. Register a player behavior (e.g. share) for the newly created player.</h3>
|
118
109
|
|
119
|
-
<p
|
120
|
-
new_activity = BadgevilleBerlin::Activity.new(
|
121
|
-
:verb => 'share',
|
122
|
-
:player_id => new_player.id )
|
123
|
-
success = new_activity.save
|
124
|
-
</code></p>
|
110
|
+
<p>```ruby</p>
|
125
111
|
|
126
|
-
<
|
112
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_new_user'>new_user</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
113
|
+
<span class='symbol'>:name</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor_username</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
114
|
+
<span class='symbol'>:network_id</span> <span class='op'>=></span> <span class='const'>MY_NETWORK_ID</span><span class='comma'>,</span>
|
115
|
+
<span class='symbol'>:email</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor@emailserver.com</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
116
|
+
<span class='symbol'>:password</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor_password</span><span class='tstring_end'>'</span></span> <span class='rparen'>)</span>
|
117
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_new_user'>new_user</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
118
|
+
</code></pre>
|
127
119
|
|
128
|
-
<
|
120
|
+
<p>```</p>
|
121
|
+
|
122
|
+
<h3>4. See error messages from the remote server.</h3>
|
123
|
+
|
124
|
+
<ul>
|
125
|
+
<li>Here we attempt to create a second user on the network with the same email as the first user.</li>
|
126
|
+
<li>See the API Explorer for required and optional parameters.</li>
|
127
|
+
</ul>
|
128
|
+
|
129
|
+
|
130
|
+
<p>```ruby</p>
|
131
|
+
|
132
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_new_user2'>new_user2</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
133
|
+
<span class='symbol'>:name</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor_username</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
134
|
+
<span class='symbol'>:network_id</span> <span class='op'>=></span> <span class='const'>MY_NETWORK_ID</span><span class='comma'>,</span>
|
135
|
+
<span class='symbol'>:email</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor@emailserver.com</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
136
|
+
<span class='symbol'>:password</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>visitor_password</span><span class='tstring_end'>'</span></span> <span class='rparen'>)</span>
|
137
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_new_user2'>new_user2</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
138
|
+
|
139
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_new_user2'>new_user2</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_messages'>messages</span> <span class='comment'># {:email=>["user email is already taken"]}
|
140
|
+
</span> <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_new_user2'>new_user2</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='lbracket'>[</span><span class='symbol'>:email</span><span class='rbracket'>]</span> <span class='comment'># ["user email is already taken"]
|
141
|
+
</span></code></pre>
|
142
|
+
|
143
|
+
<p>```</p>
|
144
|
+
|
145
|
+
<h3>5. Find a user to update user properties.</h3>
|
146
|
+
|
147
|
+
<ul>
|
148
|
+
<li>Here we find the newly created user by ID to update their email address.</li>
|
149
|
+
<li>See the API Explorer for a full list of user properties to update.</li>
|
150
|
+
</ul>
|
151
|
+
|
152
|
+
|
153
|
+
<p>```ruby</p>
|
154
|
+
|
155
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_user_found_by_id'>user_found_by_id</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span> <span class='id identifier rubyid_new_user'>new_user</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='rparen'>)</span>
|
156
|
+
<span class='id identifier rubyid_user_found_by_id'>user_found_by_id</span><span class='period'>.</span><span class='id identifier rubyid_email'>email</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>revised_visitor@emailserver.com</span><span class='tstring_end'>'</span></span>
|
157
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_user_found_by_id'>user_found_by_id</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
158
|
+
|
159
|
+
<span class='id identifier rubyid_updated_user'>updated_user</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span> <span class='id identifier rubyid_new_user'>new_user</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='rparen'>)</span>
|
160
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_updated_user'>updated_user</span><span class='period'>.</span><span class='id identifier rubyid_email'>email</span> <span class='comment'># revised_visitor@emailserver.com
|
161
|
+
</span></code></pre>
|
162
|
+
|
163
|
+
<p>```</p>
|
164
|
+
|
165
|
+
<h3>6. Create a player.</h3>
|
166
|
+
|
167
|
+
<ul>
|
168
|
+
<li>Here we create a player for the new site, corresponding to the user with the updated email address.</li>
|
169
|
+
<li>See the API Explorer for required and optional parameters.</li>
|
170
|
+
</ul>
|
129
171
|
|
130
|
-
<p>Print HTTP requests and JSON responses by installing the "logger" gem and including this code in your script.</p>
|
131
172
|
|
132
|
-
<p>```ruby
|
133
|
-
|
134
|
-
BadgevilleBerlin
|
135
|
-
|
173
|
+
<p>```ruby</p>
|
174
|
+
|
175
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_new_player'>new_player</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>Player</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
176
|
+
<span class='symbol'>:site_id</span> <span class='op'>=></span> <span class='id identifier rubyid_new_site'>new_site</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='comma'>,</span>
|
177
|
+
<span class='symbol'>:user_id</span> <span class='op'>=></span> <span class='id identifier rubyid_user_found_by_id'>user_found_by_id</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='rparen'>)</span>
|
178
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_new_player'>new_player</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
179
|
+
</code></pre>
|
180
|
+
|
181
|
+
<p>```</p>
|
182
|
+
|
183
|
+
<h3>7. Find existing players by email.</h3>
|
184
|
+
|
185
|
+
<ul>
|
186
|
+
<li>Here we find an existing player by email.</li>
|
187
|
+
<li>To get all players on the network that match the email, we have passed :all.</li>
|
188
|
+
<li>You can alternatively pass :first or :last in the place of :all.</li>
|
189
|
+
</ul>
|
190
|
+
|
191
|
+
|
192
|
+
<p>``` ruby</p>
|
193
|
+
|
194
|
+
<pre class="code ruby"><code> <span class='ivar'>@existing_player</span> <span class='op'>=</span> <span class='const'>Player</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='symbol'>:all</span><span class='comma'>,</span> <span class='symbol'>:params</span> <span class='op'>=></span> <span class='lbrace'>{</span><span class='symbol'>:email</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>revised_visitor@emailserver.com</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
195
|
+
</code></pre>
|
196
|
+
|
197
|
+
<p>```</p>
|
198
|
+
|
199
|
+
<h3>8. Register a player behavior.</h3>
|
200
|
+
|
201
|
+
<ul>
|
202
|
+
<li>Here we record the fact that the newly created player performed a "share" behavior.</li>
|
203
|
+
<li>See the API Explorer for required and optional parameters.</li>
|
204
|
+
</ul>
|
205
|
+
|
206
|
+
|
207
|
+
<p>```ruby</p>
|
208
|
+
|
209
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_new_activity'>new_activity</span> <span class='op'>=</span> <span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>Activity</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
210
|
+
<span class='symbol'>:verb</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>share</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
211
|
+
<span class='symbol'>:player_id</span> <span class='op'>=></span> <span class='id identifier rubyid_new_player'>new_player</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='rparen'>)</span>
|
212
|
+
<span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_new_activity'>new_activity</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
213
|
+
</code></pre>
|
136
214
|
|
137
215
|
<p>```</p>
|
138
216
|
|
139
|
-
<
|
217
|
+
<h2>Monitoring HTTP Requests and JSON Responses</h2>
|
218
|
+
|
219
|
+
<p>Print HTTP requests and JSON responses by installing the "logger" gem and including this code in your script.</p>
|
140
220
|
|
141
|
-
<p
|
221
|
+
<p>```ruby</p>
|
142
222
|
|
143
|
-
<
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
223
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>logger</span><span class='tstring_end'>'</span></span>
|
224
|
+
<span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>BaseResource</span><span class='period'>.</span><span class='id identifier rubyid_logger'>logger</span> <span class='op'>=</span> <span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>STDOUT</span><span class='rparen'>)</span>
|
225
|
+
<span class='const'>BadgevilleBerlin</span><span class='op'>::</span><span class='const'>BaseResource</span><span class='period'>.</span><span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_level'>level</span> <span class='op'>=</span> <span class='const'>Logger</span><span class='op'>::</span><span class='const'>DEBUG</span>
|
226
|
+
</code></pre>
|
227
|
+
|
228
|
+
<p>```</p>
|
148
229
|
|
149
230
|
<h2>Dependencies</h2>
|
150
231
|
|
151
232
|
<ul>
|
152
233
|
<li>activeresource (3.1.3) - Provides Ruby classes to RESTfully interact with remote resources.</li>
|
153
|
-
<li>logger (1.2.8) - Provides logging to the standard output stream.</li>
|
154
234
|
</ul>
|
155
235
|
|
156
236
|
|
157
237
|
<h2>Installation</h2>
|
158
238
|
|
159
|
-
<p>
|
239
|
+
<p>gem install badgeville_berlin</p>
|
160
240
|
|
161
241
|
<h2>Documentation</h2>
|
162
242
|
|
163
243
|
<p>For more documentation on how the Badgeville RESTful Berlin API works, see [here] (http://rules.badgeville.com/display/doc/2.0+Core+API+Documentation).</p>
|
164
244
|
|
245
|
+
<h2>Submitting an Issue</h2>
|
246
|
+
|
247
|
+
<p>You can use the <a href="https://github.com/badgeville/badgeville-ruby/issues">GitHub issue tracker</a> to report bugs. After ensuring that the bug has not already been submitted, please submit:</p>
|
248
|
+
|
249
|
+
<ol>
|
250
|
+
<li>A <a href="https://gist.github.com/">gist</a> a that contains a stack trace.</li>
|
251
|
+
<li>Details needed to reproduce the bug, including gem version, Ruby version and operating system.</li>
|
252
|
+
</ol>
|
253
|
+
|
254
|
+
|
255
|
+
<h2>Submitting a Pull Request</h2>
|
256
|
+
|
257
|
+
<ol>
|
258
|
+
<li>Click the GitHub "Fork" button to fork this project.</li>
|
259
|
+
<li><p>Clone the repository for a local copy:</p>
|
260
|
+
|
261
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_git'>git</span> <span class='id identifier rubyid_clone'>clone</span> <span class='id identifier rubyid_git'>git</span><span class='ivar'>@github</span><span class='period'>.</span><span class='id identifier rubyid_com'>com</span><span class='symbol'>:username</span><span class='op'>/</span><span class='id identifier rubyid_badgeville'>badgeville</span><span class='op'>-</span><span class='id identifier rubyid_ruby'>ruby</span><span class='period'>.</span><span class='id identifier rubyid_git'>git</span>
|
262
|
+
</code></pre></li>
|
263
|
+
<li><p>Create a topic branch:</p>
|
264
|
+
|
265
|
+
<pre class="code ruby"><code> git checkout -b my_bug_fix_or_feature_branch
|
266
|
+
</code></pre></li>
|
267
|
+
<li><p>Add documentation and specs for your bug fix or feature.</p></li>
|
268
|
+
<li>Implement your bug fix or feature.</li>
|
269
|
+
<li><p>Run the following command to ensure your tests cover your changes:</p>
|
270
|
+
|
271
|
+
<pre class="code ruby"><code> <span class='id identifier rubyid_bundle'>bundle</span> <span class='id identifier rubyid_exec'>exec</span> <span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_spec'>spec</span>
|
272
|
+
</code></pre></li>
|
273
|
+
<li><p>Commit and push your changes.</p></li>
|
274
|
+
<li>Click the GitHub "Pull Request" to submit a pull request. Please do not include changes to the gemspec, version or history file.</li>
|
275
|
+
</ol>
|
276
|
+
|
277
|
+
|
278
|
+
<p>-## Contributors
|
279
|
+
-David Czarnecki wrote the initial gem that inspired this wrapper.</p>
|
280
|
+
|
165
281
|
<p>Copyright (c) 2012 Badgeville.</p></div></div>
|
166
|
-
|
282
|
+
|
167
283
|
<div id="footer">
|
168
|
-
Generated on
|
284
|
+
Generated on Wed Jan 8 10:43:04 2014 by
|
169
285
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
170
|
-
0.
|
286
|
+
0.8.2.1 (ruby-1.9.2).
|
171
287
|
</div>
|
172
288
|
|
173
289
|
</body>
|