Skip to content

Commit

Permalink
Merge pull request #17 from wujun4code/cloud-functions
Browse files Browse the repository at this point in the history
feat: call LeanEngine cloud functions.
  • Loading branch information
Wu Jun (Miracle is awesome!!!) authored Oct 29, 2017
2 parents 670dbea + 57c1172 commit 9ec637e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
- [ ] send
- [ ] verify
- [ ] captcha
- [ ] RxAVEngine
- [ ] callCloudFunctions
- [ ] rpcCloudFunctions
- [ ] RxAVCloud
- [x] callCloudFunction
- [ ] rpcCloudFunction
- [ ] RxAVRealtime - [RxAVRealtime doc issue](https://github.com/RxLeanCloud/rx-lean-swift/issues/5)
- [x] connect
- [x] connectWithUser
Expand Down
4 changes: 4 additions & 0 deletions src/RxLeanCloudSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
6A2757FD1ED9BA21000D9DA3 /* RxAVUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A2757FC1ED9BA21000D9DA3 /* RxAVUser.swift */; };
6A2758011ED9C15E000D9DA3 /* UserController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A2758001ED9C15E000D9DA3 /* UserController.swift */; };
6A2758031ED9C16D000D9DA3 /* IUserController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A2758021ED9C16D000D9DA3 /* IUserController.swift */; };
6A3F43A81FA48E5F00B784EE /* RxAVCloud.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A3F43A71FA48E5F00B784EE /* RxAVCloud.swift */; };
6A42AB971ED4FE26000E9D05 /* IAVEncoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A42AB961ED4FE26000E9D05 /* IAVEncoder.swift */; };
6A42AB991ED4FEE8000E9D05 /* AVEncoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A42AB981ED4FEE8000E9D05 /* AVEncoder.swift */; };
6A42ABA51ED51AD3000E9D05 /* AVDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A42ABA41ED51AD3000E9D05 /* AVDecoder.swift */; };
Expand Down Expand Up @@ -73,6 +74,7 @@
6A2757FC1ED9BA21000D9DA3 /* RxAVUser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxAVUser.swift; sourceTree = "<group>"; };
6A2758001ED9C15E000D9DA3 /* UserController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserController.swift; sourceTree = "<group>"; };
6A2758021ED9C16D000D9DA3 /* IUserController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IUserController.swift; sourceTree = "<group>"; };
6A3F43A71FA48E5F00B784EE /* RxAVCloud.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RxAVCloud.swift; sourceTree = "<group>"; };
6A42AB961ED4FE26000E9D05 /* IAVEncoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IAVEncoder.swift; sourceTree = "<group>"; };
6A42AB981ED4FEE8000E9D05 /* AVEncoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AVEncoder.swift; sourceTree = "<group>"; };
6A42ABA41ED51AD3000E9D05 /* AVDecoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AVDecoder.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -303,6 +305,7 @@
6AEB4AC71ED94F2500F3F06A /* RxAVRealtime.swift */,
6A2757FC1ED9BA21000D9DA3 /* RxAVUser.swift */,
6AEB4AC81ED94F2500F3F06A /* RxAVWebSocket.swift */,
6A3F43A71FA48E5F00B784EE /* RxAVCloud.swift */,
);
path = Public;
sourceTree = "<group>";
Expand Down Expand Up @@ -558,6 +561,7 @@
6AEB4A9E1ED8283500F3F06A /* QueryController.swift in Sources */,
6AA097871ED329E100114C43 /* IAVCommandRunner.swift in Sources */,
6A42ABA91ED52FD6000E9D05 /* ObjectDecoder.swift in Sources */,
6A3F43A81FA48E5F00B784EE /* RxAVCloud.swift in Sources */,
6A42AB971ED4FE26000E9D05 /* IAVEncoder.swift in Sources */,
6AC498BB1EE55038008BB978 /* IRxKVStorage.swift in Sources */,
6AEB4AA91ED92A4D00F3F06A /* RxWebSocketClient.swift in Sources */,
Expand Down
27 changes: 27 additions & 0 deletions src/RxLeanCloudSwift/Public/RxAVCloud.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// RxAVCloud.swift
// RxLeanCloudSwift
//
// Created by WuJun on 28/10/2017.
// Copyright © 2017 LeanCloud. All rights reserved.
//

import Foundation
import RxSwift

/*
* LeanEngine
*/
public class RxAVCloud {
public static func callCloudFuntion(funtionName: String, payload: [String: Any]?, app: RxAVApp?) -> Observable<[String:Any]?> {
var _app = app
if _app == nil {
_app = RxAVClient.sharedInstance.getCurrentApp()
}
let cmd = AVCommand(relativeUrl: "/functions/\(funtionName)", method: "POST", data: payload, app: _app!)
return RxAVCorePlugins.sharedInstance.commandRunner.runRxCommand(command: cmd).map({ (avResponse) -> [String: Any]? in
return avResponse.jsonBody
})
}
}

0 comments on commit 9ec637e

Please sign in to comment.