static void Main(string[] args) { // ================================= // // PASTE IN VARIABLE VALUES HERE // // ================================= // const string FUNCTIONNAME = "adamHelloWorldFlow"; const string SOLUTIONID = "playgroun_f9839"; const string CLIENTID = "joeflow_b0b6941"; //Get from aws or Alex //Get from aws or Alex const string ENVIRONMENTID = "d1"; // workspace and app where the trigger will fire. const string EVENTSOURCE = "joeFlow - !BBC - Playground Test Space|Field Types"; // the item id you are using for the trigger inside Podio. This can be found inside the item in Podio under Actions>Developer. Ronald DEmo App const string TRIGGER_ITEM = "1467386578"; const string JWT = "eyJhbGciOiJIUzI1NiIsInR5cCI6ICJKV1QifQ.eyJPQXV0aENsaWVudElkIjoic2Fhc2FmcmFzLWRldiIsIlByaXZpbGVnZXMiOlt7InNvbHV0aW9uSWQiOm51bGwsInZlcnNpb24iOm51bGwsImNsaWVudEZpbHRlciI6bnVsbCwiY29tbWFuZCI6bnVsbCwidXJsIjpudWxsLCJmaWx0ZXIiOm51bGx9XSwiaXNzIjoiYXBpLnNhYXNzYWZyYXMuY29tIiwic3ViIjoiYWRhbUBicmlja2JyaWRnZWNvbnN1bHRpbmcuY29tIiwiYXVkIjoiaHR0cHM6Ly93d3cuc2Fhc3NhZnJhcy5jb20vYXV0aCIsImlhdCI6MTU5NDY2MzYwMiwibmJmIjoxNTk0NjYzNjAyLCJleHAiOjE1OTQ3NTAwNjJ9.M2vvv73vv73vv73vv73vv73vv70Q77-9KA_vv718cwTvv73vv71s77-9Xg3vv71iZO-_ve-_vQLvv71R77-977-9"; var custom = new Dictionary <string, string> { { "x-saasafras-jwt", JWT } }; var clientContext = new LocalLambdaClientContext(custom); // replace with your function name ILambdaContext context = new LocalLambdaContext($"{FUNCTIONNAME}.aws", "$LATEST", clientContext); // replace with your function name var container = PodioContainerFactory.GetPodioContainer(FUNCTIONNAME); var command = new SaasafrasSolutionCommand <SaasafrasPodioEvent> { solutionId = SOLUTIONID, //Get from aws or Alex version = "0.0", clientFilter = new SaasafrasClientFilter { clientIds = new[] { CLIENTID }, environmentIds = new[] { ENVIRONMENTID } }, command = "send-podio-event-to-function", resource = new SaasafrasPodioEvent { target = $"{FUNCTIONNAME}:DEV", hash = "Ul4rc9sqSAeQ6MQb_QLb71BXXsQVDijkNXUQEjoWUA8", source = EVENTSOURCE, key = null, hook_id = "16094574", //this doesn't matter for local testing. type = "item.create", //this doesn't matter for local testing. item_id = TRIGGER_ITEM, item_revision_id = "0" //this doesn't matter for local testing. } }; var response = container.EntryPoint(command, context).Result; Console.WriteLine($"{response}"); }
public async Task <FunctionContainerResponse> Handler(SaasafrasSolutionCommand <SaasafrasPodioEvent> command, ILambdaContext lambdaContext) { var container = PodioContainerFactory.GetPodioContainer("TemplateFunctionContainer"); lambdaContext.Logger.LogLine("Entered container."); var message = await container.EntryPoint(command, lambdaContext); lambdaContext.Logger.LogLine(message.ToString()); return(message); }
public async Task <FunctionContainerResponse> Handle(SaasafrasSolutionCommand <SaasafrasPodioEvent> command) { client.log("This will go the client log file."); solution.log("This will go to the solution log file."); //check for valid itemId if (!int.TryParse(command.resource.item_id, out int itemId)) { throw new ArgumentException("we were expecting an integer"); } //get Podio client var podio = new Podio(accessTokenProvider); var userService = new PodioCore.Services.UserService(podio); solution.log("calling podio"); var user = await userService.GetUser(); solution.log($"podio api user_id : {user.UserId}"); solution.log($"podio api email : {user.Mail}"); //get item that fired the event var currentItem = await podio.GetFullItem(itemId) ?? throw new Exception($"failed to get item {itemId}"); client.log($"Item was created in {currentItem.App.Config.Name}."); //update the function name var functionName = "adamHelloWorldFlow"; var uniqueId = currentItem.ItemId.ToString(); var lockId = await functionLocker.LockFunction(functionName, uniqueId); if (string.IsNullOrEmpty(lockId)) { throw new Exception($"Failed to acquire lock for {functionName} and id {uniqueId}"); } try { /**======================= * WRITE YOU LOGIC HERE ! * =========================*/ // easily reference Podio spaces, apps and fields //var mySolution = await saasafrasDictionary.GetDictionary(); //int MyAppMyFieldId = int.Parse(dictionary["My Space| My App | My Field"]) // access spaces, apps or fields from the solution dictionary //var dictionary = await saasafrasDictionary.GetDictionary(); //var demoApp = dictionary["!BBC - Playground Test Space| Demo App"]; //Console.WriteLine(demoApp); //int FieldsAppTitleFieldId = int.Parse(dictionary["!BBC - Playground Test Space|Field Types|Title"]); //System.Console.WriteLine(FieldsAppTitleFieldId); // id of the field //var FieldsAppTitleField = currentItem.Field<TextItemField>(FieldsAppTitleFieldId); //System.Console.WriteLine(FieldsAppTitleField.Label); // id of the field await podio.CommentOnItem("adams first comment", currentItem.ItemId, false); } catch (Exception ex) { Console.WriteLine($"Function {functionName}"); Console.WriteLine($"Exception: {ex}"); } finally { await functionLocker.UnlockFunction(functionName, uniqueId, lockId); } return(new FunctionContainerResponse { message = "success" }); }