Skip to content

Commit

Permalink
Merge pull request #1 from teocomi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
teocomi authored Aug 24, 2023
2 parents f809f7b + 31a423f commit 5876034
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions AutomateFunction.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.ComponentModel.DataAnnotations;
using Objects.Geometry;
using Objects.Geometry;
using Speckle.Core.Api;
using Speckle.Core.Credentials;
using Speckle.Core.Models;
using Speckle.Core.Models.Extensions;
using Speckle.Core.Transports;
using System.ComponentModel.DataAnnotations;

/// <summary>
/// This class describes the user specified variables that the function wants to work with.
Expand All @@ -12,15 +13,12 @@
/// are valid and match the required schema.
class FunctionInputs
{
[Required]
public string SpeckleTypeToCount;
}

class AutomateFunction
{
public static async Task<int> Run(
public static async Task<string> Run(
SpeckleProjectData speckleProjectData,
FunctionInputs functionInputs,
string speckleToken
)
{
Expand All @@ -31,22 +29,12 @@ string speckleToken
};
var client = new Client(account);

var streamId = await client.StreamCreate(new StreamCreateInput { description = "Speckle Automate is Awesome ⭐", name = "Automated Stream" });
var data = new Base();
data["matteos-prop"] = "zis iz a test";
var commitId = await Helpers.Send(streamId, data, "I'M A BOT", "automate");

// HACK needed for the objects kit to initialize
var p = new Point();

var commit = await client.CommitGet(
speckleProjectData.ProjectId,
speckleProjectData.VersionId
);

var serverTransport = new ServerTransport(account, speckleProjectData.ProjectId);
var rootObject = await Operations.Receive(
commit.referencedObject,
serverTransport,
new MemoryTransport()
);

return rootObject.Flatten().Count( b => b.speckle_type == functionInputs.SpeckleTypeToCount);
return $"{speckleProjectData.SpeckleServerUrl}/streams/{streamId}/commits/{commitId}";
}
}

0 comments on commit 5876034

Please sign in to comment.