Commits

Anonymous committed 24bd8b3

wf

Comments (0)

Files changed (3)

as3snapi-core/src/as3snapi/networks/mock/MockDataCapture.as

 public class MockDataCapture {
     private var bus:IBus;
 
+    //TODO use SnapshotBuilder
     private var data:Object = {};
 
     public function MockDataCapture(bus:IBus) {

as3snapi-core/src/as3snapi/networks/mock/SnapshotBuilder.as

  * @author nitrobin
  */
 package as3snapi.networks.mock {
+
 public class SnapshotBuilder {
     private var snapshot:Object;
 
         return this;
     }
 
-    public function setInviterId(inviterId:String):SnapshotBuilder {
-        snapshot.inviterId = inviterId;
-        setProfile(inviterId);
+    public function setRefererId(refererId:String):SnapshotBuilder {
+        snapshot.refererId = refererId;
+        setProfile(refererId);
+        return this;
+    }
+
+    public function setFlashVars(flashVars:Object):SnapshotBuilder {
+        snapshot.flashVars = flashVars;
         return this;
     }
 
         return this;
     }
 
+    public function addAppFriend(userId:String, fullName:String = null):SnapshotBuilder {
+        var appFriendsUids:Array = snapshot.appFriendsUids || [];
+        appFriendsUids.push(userId);
+        setProfile(userId, fullName);
+        snapshot.appFriendsUids = appFriendsUids;
+        return this;
+    }
+
     public function setFriendsUids(friendsUids:Array):SnapshotBuilder {
         snapshot.friendsUids = friendsUids;
         for each(var uid:String in friendsUids) {
         return this;
     }
 
-    public function setProfile(userId:String, fullName:String = null):SnapshotBuilder {
+    public function addFriend(userId:String, fullName:String = null):SnapshotBuilder {
+        var friendsUids:Array = snapshot.friendsUids || [];
+        friendsUids.push(userId);
+        setProfile(userId, fullName);
+        snapshot.friendsUids = friendsUids;
+        return this;
+    }
+
+    public function setProfile(userId:String, fullName:String = null, avatar:String = null, photos:Array = null, profileUrl:String = null, gender:String = null):SnapshotBuilder {
         var profiles:Object = snapshot.profiles || {};
         profiles[userId] = {
             userId:userId,
-            fullName:fullName || ("user" + userId)
+            fullName:fullName || ("user" + userId),
+            avatar:avatar,
+            photos:photos,
+            profileUrl:profileUrl,
+            gender:gender
         };
         snapshot.profiles = profiles;
         return this;
     public static function helloWorld():SnapshotBuilder {
         return new SnapshotBuilder()
                 .setShortNetworkId("mock")
+                .setAppId("0")
                 .setUserId("1")
-                .setInviterId("2")
+                .setRefererId("2")
                 .setFriendsUids(["2", "3", "4"])
                 .setAppFriendsUids(["2", "3"]);
     }

as3snapi-sandbox/src/HelloWorld.as

 package {
 import as3snapi.ConnectionFactory;
+import as3snapi.DefaultBusFactory;
 import as3snapi.IConnectionFactory;
 import as3snapi.api.INetworkConnection;
 import as3snapi.api.NetworkConnectHandler;
                     new ModuleVkcom(),
                     new ModuleMock(),
                 ],
-                new <IBusModule>[ // Подключение дополнительных модуле
-                    new BusModuleLogTrace() // Включаем выдачу внутренних логов через trace
-                ]
+                new DefaultBusFactory(
+                        new <IBusModule>[ // Подключение дополнительных модуле
+                            new BusModuleLogTrace() // Включаем выдачу внутренних логов через trace
+                        ])
         );
 
         // Подключаемся к API