mambanation 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +30 -45
- data/VERSION.yml +4 -0
- data/lib/mambanation.rb +2 -2
- data/lib/mambanation/base.rb +125 -31
- data/lib/mambanation/httpauth.rb +10 -1
- data/lib/mambanation/oauth.rb +15 -9
- data/lib/mambanation/request.rb +4 -7
- data/test/fixtures/actions.json +12 -0
- data/test/fixtures/badges.json +12 -0
- data/test/fixtures/chats.json +25 -0
- data/test/fixtures/coms.json +18 -0
- data/test/fixtures/facets.json +15 -1
- data/test/fixtures/last_login.json +3 -0
- data/test/fixtures/mission_families.json +57 -0
- data/test/fixtures/mission_statuses.json +107 -0
- data/test/fixtures/post.json +36 -0
- data/test/fixtures/publish_post.json +43 -0
- data/test/fixtures/roles.json +5 -0
- data/test/fixtures/user_error.json +9 -0
- data/test/fixtures/user_posts.json +70 -0
- data/test/mambanation/base_test.rb +104 -16
- data/test/mambanation/httpauth_test.rb +86 -0
- data/test/mambanation/request_test.rb +112 -0
- data/test/mambanation_test.rb +0 -77
- data/test/test_helper.rb +1 -2
- metadata +64 -32
- data/VERSION +0 -1
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"total_messages":1,
|
3
|
+
"total_pages":1,
|
4
|
+
"current_page":1,
|
5
|
+
"messages": [
|
6
|
+
{
|
7
|
+
"type":"think",
|
8
|
+
"recipients":[ 1, 2],
|
9
|
+
"message":"Salut les gars",
|
10
|
+
"origin":1234,
|
11
|
+
"application":"mambanation",
|
12
|
+
"timestamp":1271176375259,
|
13
|
+
"way":"out"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"type":"think",
|
17
|
+
"recipients":[ 1,1234 ],
|
18
|
+
"message":"Yop",
|
19
|
+
"origin":2,
|
20
|
+
"application":"mambanation",
|
21
|
+
"timestamp":1271176375259,
|
22
|
+
"way":"in"
|
23
|
+
}],
|
24
|
+
"messages_per_page": 50
|
25
|
+
}
|
data/test/fixtures/facets.json
CHANGED
@@ -1 +1,15 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"facebook_id": "12345678901234",
|
3
|
+
"id": 1234,
|
4
|
+
"facets" : [{
|
5
|
+
"status": "active",
|
6
|
+
"type": "Arabic Female",
|
7
|
+
"equipement": ["g_s_basket01_yellow", "g_l_jogging01_red", "g_t_blazer01_blue"],
|
8
|
+
"created_at": 1265292066,
|
9
|
+
"fingerprint": "612a9cdb9bb170c1e67299825be2b898",
|
10
|
+
"updated_at": 1270550620,
|
11
|
+
"name": "b0876096001265292066",
|
12
|
+
"id": 1234,
|
13
|
+
"gender": "F"
|
14
|
+
}]
|
15
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
{
|
2
|
+
"total_entries": 35,
|
3
|
+
"total_pages": 1,
|
4
|
+
"page": 1,
|
5
|
+
"entries" : [
|
6
|
+
{
|
7
|
+
"id" : 1,
|
8
|
+
"title" : "Explorer",
|
9
|
+
"description" : "The Mamberz walked through the MambaNation ...",
|
10
|
+
"reward_description" : [ "item_x123", "item_x234", "8 blings", "10 mamba points" ], // will change
|
11
|
+
"visuel" : "http://my.domain.com/an_image.jpg", // URL to an image stored somewhere
|
12
|
+
"conditions" : [ ... ], // MUST BE DEFINED
|
13
|
+
"completed": "1/6",
|
14
|
+
"missions" : [
|
15
|
+
{
|
16
|
+
"status": "completed",
|
17
|
+
"available": true,
|
18
|
+
"level": 1,
|
19
|
+
"description": null,
|
20
|
+
"started_at": 1274782884,
|
21
|
+
"vibes_reward": 10,
|
22
|
+
"completed_at": 1274783247,
|
23
|
+
"family": "Adventure",
|
24
|
+
"name": "backpacker",
|
25
|
+
"mamba_points_reward": 100,
|
26
|
+
"mission_id": 1
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"status": "started",
|
30
|
+
"available": true,
|
31
|
+
"level": 1,
|
32
|
+
"description": null,
|
33
|
+
"started_at": 1274782884,
|
34
|
+
"vibes_reward": 10,
|
35
|
+
"completed_at": 0,
|
36
|
+
"family": "Discovery",
|
37
|
+
"name": "avatar_creation",
|
38
|
+
"mamba_points_reward": 100,
|
39
|
+
"mission_id": 2
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"status": "pending",
|
43
|
+
"available": true,
|
44
|
+
"level": 1,
|
45
|
+
"description": null,
|
46
|
+
"started_at": 0,
|
47
|
+
"vibes_reward": 10,
|
48
|
+
"completed_at": 0,
|
49
|
+
"family": "Challenge",
|
50
|
+
"name": "orateur",
|
51
|
+
"mamba_points_reward": 100,
|
52
|
+
"mission_id": 8
|
53
|
+
}
|
54
|
+
]
|
55
|
+
}
|
56
|
+
]
|
57
|
+
}
|
@@ -0,0 +1,107 @@
|
|
1
|
+
{
|
2
|
+
"total_entries": 35,
|
3
|
+
"total_pages": 1,
|
4
|
+
"page": 1,
|
5
|
+
"entries" : [
|
6
|
+
{
|
7
|
+
"status": "completed",
|
8
|
+
"image" : "http://mydomain.com/my_image.jpg",
|
9
|
+
"available": true,
|
10
|
+
"level": 1,
|
11
|
+
"description": null,
|
12
|
+
"reward" : {
|
13
|
+
"mamba_points" : 10,
|
14
|
+
"vibes" : 10,
|
15
|
+
"item" : "item_x123",
|
16
|
+
"badge" : {
|
17
|
+
"id" : 1,
|
18
|
+
"name" : "Star"
|
19
|
+
},
|
20
|
+
"com" : null,
|
21
|
+
"fame" : 10
|
22
|
+
}
|
23
|
+
"started_at": 1274782884,
|
24
|
+
"vibes_reward": 10,
|
25
|
+
"completed_at": 1274783247,
|
26
|
+
"family": "Adventure",
|
27
|
+
"name": "backpacker",
|
28
|
+
"mamba_points_reward": 100,
|
29
|
+
"mission_id": 1
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"status": "started",
|
33
|
+
"image" : "http://mydomain.com/my_image.jpg",
|
34
|
+
"available": true,
|
35
|
+
"level": 1,
|
36
|
+
"description": null,
|
37
|
+
"reward" : {
|
38
|
+
"mamba_points" : 10,
|
39
|
+
"vibes" : 10,
|
40
|
+
"item" : "item_x123",
|
41
|
+
"badge" : {
|
42
|
+
"id" : 1,
|
43
|
+
"name" : "Star"
|
44
|
+
},
|
45
|
+
"com" : "Star numeric",
|
46
|
+
"fame" : 10
|
47
|
+
}
|
48
|
+
"started_at": 1274782884,
|
49
|
+
"vibes_reward": 10,
|
50
|
+
"completed_at": 0,
|
51
|
+
"family": "Discovery",
|
52
|
+
"name": "avatar_creation",
|
53
|
+
"mamba_points_reward": 100,
|
54
|
+
"mission_id": 2
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"status": "pending",
|
58
|
+
"image" : "http://mydomain.com/my_image.jpg",
|
59
|
+
"available": true,
|
60
|
+
"level": 1,
|
61
|
+
"description": null,
|
62
|
+
"reward" : {
|
63
|
+
"mamba_points" : 10,
|
64
|
+
"vibes" : 10,
|
65
|
+
"item" : "item_x123",
|
66
|
+
"badge" : {
|
67
|
+
"id" : 1,
|
68
|
+
"name" : "Star"
|
69
|
+
},
|
70
|
+
"com" : null,
|
71
|
+
"fame" : 10
|
72
|
+
}
|
73
|
+
"started_at": 0,
|
74
|
+
"vibes_reward": 10,
|
75
|
+
"completed_at": 0,
|
76
|
+
"family": "Challenge",
|
77
|
+
"name": "orateur",
|
78
|
+
"mamba_points_reward": 100,
|
79
|
+
"mission_id": 8
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"status": "pending",
|
83
|
+
"image" : "http://mydomain.com/my_image.jpg",
|
84
|
+
"available": false,
|
85
|
+
"level": 2,
|
86
|
+
"description": null,
|
87
|
+
"reward" : {
|
88
|
+
"mamba_points" : 10,
|
89
|
+
"vibes" : 10,
|
90
|
+
"item" : "item_x123",
|
91
|
+
"badge" : {
|
92
|
+
"id" : 1,
|
93
|
+
"name" : "Star"
|
94
|
+
},
|
95
|
+
"com" : null,
|
96
|
+
"fame" : 10
|
97
|
+
}
|
98
|
+
"started_at": 0,
|
99
|
+
"vibes_reward": 10,
|
100
|
+
"completed_at": 0,
|
101
|
+
"family": "Challenge",
|
102
|
+
"name": "social",
|
103
|
+
"mamba_points_reward": 100,
|
104
|
+
"mission_id": 9
|
105
|
+
}
|
106
|
+
]
|
107
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"created_at": 1267007807,
|
3
|
+
"updated_at": 1267007807,
|
4
|
+
"attachment": {
|
5
|
+
"href": "http://api.sandbox.mambanation.com/v1/",
|
6
|
+
"name": "LOVE",
|
7
|
+
"media": [
|
8
|
+
{
|
9
|
+
"expanded_width": "320",
|
10
|
+
"swfsrc": "http://api.sandbox.mambanation.com/flv_player.swf?flv=http://d387vg9sga25dr.cloudfront.net/video/1da41a11cf6570642ba9d7c91f2c48_LOVE.flv",
|
11
|
+
"imgsrc": "http://d387vg9sga25dr.cloudfront.net/preview/1da41a11cf6570642ba9d7c91f2c48_LOVE.png",
|
12
|
+
"type": "flash",
|
13
|
+
"expanded_height": "260"
|
14
|
+
}
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"fb_application_id": "293525602735",
|
18
|
+
"id": "4b85013f7656db7914000001",
|
19
|
+
"uid": "100000436786256",
|
20
|
+
"other": {
|
21
|
+
"example": "1234"
|
22
|
+
},
|
23
|
+
"message": "Salut toi, mate cette video !",
|
24
|
+
"target_ids": [
|
25
|
+
"100000195107250",
|
26
|
+
"100000592653443",
|
27
|
+
"100000064204868",
|
28
|
+
"100000491657497",
|
29
|
+
"725944591",
|
30
|
+
"100000606276736"
|
31
|
+
],
|
32
|
+
"replies" : {
|
33
|
+
"100000606276736" : "4b9a0de27656db6ff4000004",
|
34
|
+
"100000195107250" : "4b9a0de27656db6ff4000054"
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
message: 'message perso',
|
3
|
+
attachment: {
|
4
|
+
'name': 'titre',
|
5
|
+
'href': 'url',
|
6
|
+
'caption': 'sous-titre',
|
7
|
+
'description': 'description',
|
8
|
+
'properties': {
|
9
|
+
'property_key': {
|
10
|
+
'text': 'property_text',
|
11
|
+
'href': 'property_url_{{VAR_2}}'
|
12
|
+
}
|
13
|
+
},
|
14
|
+
'media': [{
|
15
|
+
'type': 'flash',
|
16
|
+
'swfsrc': 'url_flash_{{VAR_1}}',
|
17
|
+
'imgsrc': 'url_action',
|
18
|
+
'width': '90',
|
19
|
+
'height': '90',
|
20
|
+
'expanded_width': '460',
|
21
|
+
'expanded_height': '200'
|
22
|
+
}]
|
23
|
+
},
|
24
|
+
action_links : [{
|
25
|
+
'text':'action_links_text',
|
26
|
+
'href':'link_appli'
|
27
|
+
}],
|
28
|
+
uid: MambaNation.userId,
|
29
|
+
target_ids: {
|
30
|
+
uid001 : {
|
31
|
+
VAR_1 : 'Texte de remplacement',
|
32
|
+
VAR_2 : 'UserSpecificVar'
|
33
|
+
},
|
34
|
+
uid002 : {
|
35
|
+
VAR_1 : 'Texte de remplacement',
|
36
|
+
VAR_2 : 'UserSpecificVar'
|
37
|
+
}
|
38
|
+
},
|
39
|
+
other: {
|
40
|
+
'anythingelse' : 'some_text_to_save',
|
41
|
+
'anythingelse' : 'some_text_to_save'
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
{
|
2
|
+
sent: [
|
3
|
+
{
|
4
|
+
"created_at": 1267107614,
|
5
|
+
"published_streams": {
|
6
|
+
"100000436786256": "100000436786256_105254089499150"
|
7
|
+
},
|
8
|
+
"updated_at": 1267107616,
|
9
|
+
"action_links": {
|
10
|
+
"0": {
|
11
|
+
"href": "http://apps.facebook.com/mambatemplate?post_id={{post_id}}",
|
12
|
+
"text": "Reply !"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"attachment": {
|
16
|
+
"href": "http://api.sandbox.mambanation.com:3001/v1/",
|
17
|
+
"name": "NEWYEAR",
|
18
|
+
"media": [{
|
19
|
+
"expanded_width": "320",
|
20
|
+
"swfsrc": "http://api.sandbox.mambanation.com/flv_player.swf?flv=http://d387vg9sga25dr.cloudfront.net/video/1da41a11cf6570642ba9d7c91f2c48_NEWYEAR.flv",
|
21
|
+
"imgsrc": "http://d387vg9sga25dr.cloudfront.net/preview/1da41a11cf6570642ba9d7c91f2c48_NEWYEAR.png",
|
22
|
+
"type": "flash",
|
23
|
+
"expanded_height": "260"
|
24
|
+
}]
|
25
|
+
},
|
26
|
+
"_id": "4b86871ed45037109900001c",
|
27
|
+
"fb_application_id": "293415521400",
|
28
|
+
"uid": "100000436786256",
|
29
|
+
"other": {
|
30
|
+
"example": "1234"
|
31
|
+
},
|
32
|
+
"message": "hihihi",
|
33
|
+
"target_ids": ["100000436786256"]
|
34
|
+
}
|
35
|
+
], // list of posts sent by the user
|
36
|
+
received: [
|
37
|
+
{
|
38
|
+
"created_at": 1267107614,
|
39
|
+
"published_streams": {
|
40
|
+
"100000436786256": "100000436786256_105254089499150"
|
41
|
+
},
|
42
|
+
"updated_at": 1267107616,
|
43
|
+
"action_links": {
|
44
|
+
"0": {
|
45
|
+
"href": "http://apps.facebook.com/mambatemplate?post_id={{post_id}}",
|
46
|
+
"text": "Reply !"
|
47
|
+
}
|
48
|
+
},
|
49
|
+
"attachment": {
|
50
|
+
"href": "http://api.sandbox.mambanation.com:3001/v1/",
|
51
|
+
"name": "NEWYEAR",
|
52
|
+
"media": [{
|
53
|
+
"expanded_width": "320",
|
54
|
+
"swfsrc": "http://api.sandbox.mambanation.com/flv_player.swf?flv=http://d387vg9sga25dr.cloudfront.net/video/1da41a11cf6570642ba9d7c91f2c48_NEWYEAR.flv",
|
55
|
+
"imgsrc": "http://d387vg9sga25dr.cloudfront.net/preview/1da41a11cf6570642ba9d7c91f2c48_NEWYEAR.png",
|
56
|
+
"type": "flash",
|
57
|
+
"expanded_height": "260"
|
58
|
+
}]
|
59
|
+
},
|
60
|
+
"_id": "4b86871ed45037109900001c",
|
61
|
+
"fb_application_id": "293415521400",
|
62
|
+
"uid": "100000436786256",
|
63
|
+
"other": {
|
64
|
+
"example": "1234"
|
65
|
+
},
|
66
|
+
"message": "hihihi",
|
67
|
+
"target_ids": ["100000436786256"]
|
68
|
+
}
|
69
|
+
] // list of posts received by the user
|
70
|
+
}
|
@@ -1,22 +1,110 @@
|
|
1
|
-
require '
|
2
|
-
require '../../lib/mambanation/base.rb'
|
3
|
-
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
4
2
|
|
5
3
|
class BaseTest < Test::Unit::TestCase
|
6
|
-
|
4
|
+
|
5
|
+
context "when connected thru HTTP" do
|
7
6
|
setup do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
should
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
7
|
+
@mambanation = MambaNation::Base.new(MambaNation::HTTPAuth.new("username", "password", :api_endpoint => "api.mambanation.com"))
|
8
|
+
end
|
9
|
+
|
10
|
+
should "have user method for base authenticated calls to get a user's information" do
|
11
|
+
stub_get("http://username:password@api.mambanation.com/v2/users/4.json", 'user.json')
|
12
|
+
user = @mambanation.user(4)
|
13
|
+
user.mamba_level.should == 1
|
14
|
+
user.email.should == "tian.jiang01@gmail.com"
|
15
|
+
end
|
16
|
+
|
17
|
+
should "have facet method for base authenticated calls to get a facet's information" do
|
18
|
+
stub_get("http://username:password@api.mambanation.com/v2/facets/1.json", 'facet.json')
|
19
|
+
facet = @mambanation.facet 1
|
20
|
+
facet.user_id.should == 1
|
21
|
+
end
|
22
|
+
|
23
|
+
should "have user_facets method with given user for base authenticated calls to get a user's facet's information" do
|
24
|
+
stub_get("http://username:password@api.mambanation.com/v2/users/4/facets.json", 'facets.json')
|
25
|
+
facets = @mambanation.user_facets(4)
|
26
|
+
facets.facets.count.should == 1
|
27
|
+
facets.facebook_id == nil
|
28
|
+
end
|
29
|
+
|
30
|
+
should "have user_friends method with given user for base authenticated calls to get a user's facet's information" do
|
31
|
+
stub_get("http://username:password@api.mambanation.com/v2/users/4/friends.json", 'friends.json')
|
32
|
+
friends = @mambanation.user_friends(4)
|
33
|
+
friends.count.should == 2
|
34
|
+
end
|
35
|
+
|
36
|
+
#media api for user in sdk is not rest
|
37
|
+
# should "have user_media method with given user for base authenticated calls to get a user's media's information" do
|
38
|
+
# stub_get("http://username:password@api.mambanation.com/v2/users/5/medias.json", '')
|
39
|
+
# media
|
40
|
+
# end
|
41
|
+
|
42
|
+
# user_set_websession no more in sdk
|
43
|
+
# should "be able to update websession for a user"
|
44
|
+
# stub_post("http://username:password@api.mambanation.com/v2/facets/1.json", '')
|
45
|
+
# end
|
46
|
+
|
47
|
+
should "be able to create a user" do
|
48
|
+
stub_post("http://username:password@api.mambanation.com/v2/users", 'new_user_status.json')
|
49
|
+
response = @mambanation.create_user({"email" => "foofoo@gmail.com", "password" => "foofoo", "password_confirmation" => "foofoo"})
|
50
|
+
response.status.should == "ok"
|
51
|
+
end
|
52
|
+
|
53
|
+
should "be able to create a user with a facebook_id" do
|
54
|
+
stub_post("http://username:password@api.mambanation.com/v2/users", 'new_user_status.json')
|
55
|
+
response = @mambanation.create_user({"facebook_id" => "1474761574"})
|
56
|
+
response.status.should == "ok"
|
57
|
+
end
|
58
|
+
|
59
|
+
should "have user find by existing facebook_id" do
|
60
|
+
stub_get("http://username:password@api.mambanation.com/v2/users/find_by?facebook_id=1474761574", 'user.json')
|
61
|
+
user = @mambanation.user_by_facebook_id 1474761574
|
62
|
+
user.mamba_level.should == 1
|
63
|
+
user.email.should == "tian.jiang01@gmail.com"
|
64
|
+
user.facebook_id.should == 1474761574
|
65
|
+
end
|
66
|
+
|
67
|
+
should "have not found user message when no existing facebook_id" do
|
68
|
+
stub_get("http://username:password@api.mambanation.com/v2/users/find_by?facebook_id=12345", 'not_found_user.json')
|
69
|
+
user = @mambanation.user_by_facebook_id 12345
|
70
|
+
user.message.should == "I can't find this user !"
|
71
|
+
end
|
72
|
+
|
73
|
+
should "have user find by existing email" do
|
74
|
+
stub_get("http://username:password@api.mambanation.com/v2/users/find_by?email=tian.jiang01@gmail.com", 'user.json')
|
75
|
+
user = @mambanation.user_by_email 'tian.jiang01@gmail.com'
|
76
|
+
user.mamba_level.should == 1
|
77
|
+
user.email.should == "tian.jiang01@gmail.com"
|
78
|
+
user.facebook_id.should == 1474761574
|
79
|
+
end
|
80
|
+
|
81
|
+
should "have not found user message when no existing email" do
|
82
|
+
stub_get("http://username:password@api.mambanation.com/v2/users/find_by?email=zahia@gmail.com", 'not_found_user.json')
|
83
|
+
user = @mambanation.user_by_email 'zahia@gmail.com'
|
84
|
+
user.message.should == "I can't find this user !"
|
85
|
+
end
|
86
|
+
|
87
|
+
should "have last login" do
|
88
|
+
stub_get("http://username:password@api.mambanation.com/v2/users/4/last_login.json", 'last_login.json')
|
89
|
+
user = @mambanation.user_last_login(4)
|
90
|
+
user.last_login.should == 1234567890
|
91
|
+
end
|
92
|
+
|
93
|
+
should "have user chat" do
|
94
|
+
stub_get("http://username:password@api.mambanation.com/v2/users/4/chats.json", 'chats.json')
|
95
|
+
chats = @mambanation.user_chats(4)
|
96
|
+
puts chats.class
|
97
|
+
chats.total_messages.should == 1
|
98
|
+
chats.total_pages.should == 1
|
99
|
+
chats.current_page.should == 1
|
100
|
+
chats.messages.size.should == 2
|
101
|
+
chats.messages_per_page.should == 50
|
102
|
+
end
|
103
|
+
|
104
|
+
should "have user coms" do
|
105
|
+
stub_get("http://username:password@api.mambanation.com/v2/users/4/coms.json", 'coms.json')
|
106
|
+
coms = @mambanation.user_coms(4)
|
107
|
+
coms.count.should == 4
|
20
108
|
end
|
21
109
|
end
|
22
110
|
end
|