Skip to content

Commit

Permalink
fix: updated sdk version
Browse files Browse the repository at this point in the history
Signed-off-by: Rubicon Lee <132176609+raff-wakflo@users.noreply.github.com>
  • Loading branch information
raff-wakflo committed Jun 11, 2024
1 parent f45e08d commit 4d44adf
Show file tree
Hide file tree
Showing 32 changed files with 269 additions and 45 deletions.
7 changes: 7 additions & 0 deletions connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/wakflo/extensions/internal/connectors/goscript"
"github.com/wakflo/extensions/internal/connectors/javascript"
"github.com/wakflo/extensions/internal/connectors/manual"
"github.com/wakflo/extensions/internal/connectors/shopify"
"github.com/wakflo/extensions/internal/connectors/slack"
"github.com/wakflo/extensions/internal/connectors/todoist"
sdk "github.com/wakflo/go-sdk/connector"
Expand Down Expand Up @@ -77,5 +78,11 @@ func RegisterConnectors() []*sdk.ConnectorPlugin {
connectors = append(connectors, m)
}

// Shopify
shop, err := shopify.NewConnector()
if err == nil {
connectors = append(connectors, shop)
}

return connectors
}
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ module github.com/wakflo/extensions

go 1.22.2

//replace github.com/wakflo/go-sdk => ../go-sdk

require (
github.com/clarkmcc/go-typescript v0.7.0
github.com/dop251/goja v0.0.0-20240516125602-ccbae20bcec2
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1
github.com/gookit/goutil v0.6.15
github.com/open2b/scriggo v0.56.1
github.com/opus-domini/fast-shot v0.10.0
github.com/wakflo/go-sdk v0.2.2
github.com/wakflo/go-sdk v0.2.5
golang.org/x/crypto v0.23.0
google.golang.org/api v0.181.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/wakflo/go-sdk v0.2.2 h1:81sd4DirwZvjJ7sJ73KlnA9xh1t79u2XjDLIGf1wgjI=
github.com/wakflo/go-sdk v0.2.2/go.mod h1:bRNfg6YrzacyX7LcLhmVe1YO0X92jbFG/o0unb91aIg=
github.com/wakflo/go-sdk v0.2.5 h1:2pYn5QJ9p8Y6oN7ZlTLGG3vBWoWdYhNbvNUy8MB4qVs=
github.com/wakflo/go-sdk v0.2.5/go.mod h1:bRNfg6YrzacyX7LcLhmVe1YO0X92jbFG/o0unb91aIg=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
Expand Down
1 change: 0 additions & 1 deletion internal/connectors/cryptography/operation_hash_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"

//nolint:staticcheck
"golang.org/x/crypto/ripemd160"
)
Expand Down
1 change: 0 additions & 1 deletion internal/connectors/csv/operation_get_row_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package javascript

import (
"github.com/gocarina/gocsv"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
Expand Down
5 changes: 2 additions & 3 deletions internal/connectors/googledrive/operation_create_folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import (
"context"
"errors"

"google.golang.org/api/drive/v3"
"google.golang.org/api/option"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
"google.golang.org/api/drive/v3"
"google.golang.org/api/option"
)

type createFileOperationProps struct {
Expand Down
5 changes: 2 additions & 3 deletions internal/connectors/googledrive/operation_duplicate_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import (
"context"
"errors"

"google.golang.org/api/drive/v3"
"google.golang.org/api/option"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
"google.golang.org/api/drive/v3"
"google.golang.org/api/option"
)

type duplicateFileOperationProps struct {
Expand Down
5 changes: 2 additions & 3 deletions internal/connectors/googledrive/operation_get_file_by_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import (
"context"
"errors"

"google.golang.org/api/drive/v3"
"google.golang.org/api/option"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
"google.golang.org/api/drive/v3"
"google.golang.org/api/option"
)

type getFileByIDOperationProps struct {
Expand Down
5 changes: 2 additions & 3 deletions internal/connectors/googledrive/operation_list_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ import (
"fmt"
"strings"

"google.golang.org/api/drive/v3"
"google.golang.org/api/option"

sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
"google.golang.org/api/drive/v3"
"google.golang.org/api/option"
)

type listFilesOperationProps struct {
Expand Down
5 changes: 2 additions & 3 deletions internal/connectors/googledrive/operation_read_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import (
"context"
"errors"

"google.golang.org/api/drive/v3"
"google.golang.org/api/option"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
"google.golang.org/api/drive/v3"
"google.golang.org/api/option"
)

type readFileOperationProps struct {
Expand Down
3 changes: 1 addition & 2 deletions internal/connectors/googledrive/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import (
"slices"

fastshot "github.com/opus-domini/fast-shot"
"google.golang.org/api/drive/v3"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
"google.golang.org/api/drive/v3"
)

var (
Expand Down
5 changes: 2 additions & 3 deletions internal/connectors/googledrive/trigger_new_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ import (
"time"

fastshot "github.com/opus-domini/fast-shot"
"google.golang.org/api/drive/v3"
"google.golang.org/api/option"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
"google.golang.org/api/drive/v3"
"google.golang.org/api/option"
)

type triggerNewFileProps struct {
Expand Down
5 changes: 2 additions & 3 deletions internal/connectors/googledrive/trigger_new_folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ import (
"fmt"
"strings"

"google.golang.org/api/drive/v3"
"google.golang.org/api/option"

sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
"google.golang.org/api/drive/v3"
"google.golang.org/api/option"
)

type TriggerNewFolder struct {
Expand Down
5 changes: 2 additions & 3 deletions internal/connectors/googledrive/upload_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import (
"context"
"errors"

"google.golang.org/api/drive/v3"
"google.golang.org/api/option"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
"google.golang.org/api/drive/v3"
"google.golang.org/api/option"
)

type uploadFileOperationProps struct {
Expand Down
1 change: 0 additions & 1 deletion internal/connectors/goscript/operation_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

"github.com/open2b/scriggo"
"github.com/open2b/scriggo/native"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
Expand Down
1 change: 0 additions & 1 deletion internal/connectors/javascript/operation_run_jscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"time"

"github.com/dop251/goja"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
Expand Down
1 change: 0 additions & 1 deletion internal/connectors/javascript/operation_run_tscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"strings"

"github.com/clarkmcc/go-typescript"

"github.com/wakflo/go-sdk/autoform"
sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
Expand Down
34 changes: 34 additions & 0 deletions internal/connectors/shopify/lib.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2022-present Wakflo
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package shopify

import (
sdk "github.com/wakflo/go-sdk/connector"
)

func NewConnector() (*sdk.ConnectorPlugin, error) {
return sdk.CreateConnector(&sdk.CreateConnectorArgs{
Name: "Shopify",
Description: "interacts with Shopify API",
Logo: "logos:shopify",
Version: "0.0.1",
Category: sdk.Apps,
Authors: []string{"Wakflo <integrations@wakflo.com>"},
Triggers: []sdk.ITrigger{},
Operations: []sdk.IOperation{
NewListProductsOperation(),
},
})
}
120 changes: 120 additions & 0 deletions internal/connectors/shopify/lib_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright 2022-present Wakflo
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package shopify

import (
"testing"

sdk "github.com/wakflo/go-sdk/connector"
sdkcore "github.com/wakflo/go-sdk/core"
)

func TestNewConnector(t *testing.T) {
testCases := []struct {
name string
operationName string
wantErr bool
}{
{
name: "Success",
operationName: "create-new-file",
wantErr: false,
},
}

_ = &sdk.RunContext{
Workflow: nil,
Step: nil,
Auth: &sdkcore.AuthContext{
AccessToken: "",
Token: nil,
TokenType: "",
Username: "",
Password: "",
Secret: "",
},
State: &sdkcore.StepsState{
Steps: map[string]*sdkcore.StepState{
"step-1": {
ConnectorName: "",
Version: "",
Input: map[string]interface{}{},
Output: map[string]interface{}{},
Logs: nil,
Status: "",
},
},
CurrentStepID: "step-1",
},
}

for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
instance, err := NewConnector()
spider := sdk.NewSpiderTest(t, instance)
connector := spider.GetConfig()

if (err != nil) != testCase.wantErr {
t.Errorf("NewConnector() error = %v, wantErr %v", err, testCase.wantErr)
return
}

if connector == nil {
t.Fatal("NewConnector() returned nil")
}

if connector.DisplayName != "Google Drive" {
t.Errorf("NewConnector() Name = %s, want %s", connector.DisplayName, "Google Drive")
}

if connector.Description != "some google drive connector" {
t.Errorf("NewConnector() Description = %s, want %s", connector.Description, "some google drive connector")
}

if connector.Logo != "logos:google-drive" {
t.Errorf("NewConnector() Logo = %s, want %s", connector.Logo, "logos:google-drive")
}

if connector.Version != "0.0.1" {
t.Errorf("NewConnector() Version = %s, want %s", connector.Version, "0.0.1")
}

if connector.Category != sdk.Apps {
t.Errorf("NewConnector() Category = %v, want %v", connector.Category, sdk.Apps)
}

if len(connector.Authors) != 1 || connector.Authors[0] != "Wakflo <integrations@wakflo.com>" {
t.Errorf("NewConnector() Authors = %v, want %v", connector.Authors, []string{"Wakflo <integrations@wakflo.com>"})
}

if len(spider.Triggers()) != 2 {
t.Errorf("NewConnector() Triggers() count = %d, want %d", len(spider.Triggers()), 2)
}

if len(spider.Operations()) != 6 {
t.Errorf("NewConnector() Operations() count = %d, want %d", len(spider.Operations()), 6)
}

/*_, err = spider.RunOperation(testCase.operationName, ctx)
if err != nil {
t.Errorf("NewConnector() RunOperation() with name %v threw an error = %v", testCase.operationName, err)
}
if trigger!= "some data" {
t.Errorf("NewConnector() RunOperation() response = %v, want %v", trigger["data"], "some data")
}*/
})
}
}
Loading

0 comments on commit 4d44adf

Please sign in to comment.