-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
466 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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 flexport | ||
|
||
import ( | ||
sdk "github.com/wakflo/go-sdk/connector" | ||
) | ||
|
||
func NewConnector() (*sdk.ConnectorPlugin, error) { | ||
return sdk.CreateConnector(&sdk.CreateConnectorArgs{ | ||
Name: "Flexport", | ||
Description: "platform that coordinates global logistics from factory to customer door ", | ||
Logo: "twemoji:small-airplane", | ||
Version: "0.0.1", | ||
Category: sdk.Apps, | ||
Authors: []string{"Wakflo <integrations@wakflo.com>"}, | ||
Triggers: []sdk.ITrigger{}, | ||
Operations: []sdk.IOperation{ | ||
NewGetProductsOperation(), | ||
NewGetOrderOperation(), | ||
NewGetOrderByExternalIDOperation(), | ||
NewGetShipmentOperation(), | ||
NewCancelOrderOperation(), | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// 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 flexport | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/wakflo/go-sdk/autoform" | ||
sdk "github.com/wakflo/go-sdk/connector" | ||
sdkcore "github.com/wakflo/go-sdk/core" | ||
) | ||
|
||
type cancelOrderOperationProps struct { | ||
OrderID string `json:"Id"` | ||
} | ||
|
||
type CancelOrderOperation struct { | ||
options *sdk.OperationInfo | ||
} | ||
|
||
func NewCancelOrderOperation() *CancelOrderOperation { | ||
return &CancelOrderOperation{ | ||
options: &sdk.OperationInfo{ | ||
Name: "Cancel Order", | ||
Description: "Cancel Order", | ||
Auth: sharedAuth, | ||
Input: map[string]*sdkcore.AutoFormSchema{ | ||
"Id": autoform.NewShortTextField(). | ||
SetDisplayName("Order ID"). | ||
SetDescription("Order ID"). | ||
SetRequired(true).Build(), | ||
}, | ||
SampleOutput: map[string]interface{}{}, | ||
ErrorSettings: sdkcore.StepErrorSettings{ | ||
ContinueOnError: false, | ||
RetryOnError: false, | ||
}, | ||
RequireAuth: true, | ||
}, | ||
} | ||
} | ||
|
||
func (c *CancelOrderOperation) Run(ctx *sdk.RunContext) (sdk.JSON, error) { | ||
input := sdk.InputToType[cancelOrderOperationProps](ctx) | ||
|
||
reqURL := fmt.Sprintf("https://logistics-api.flexport.com/logistics/api/2024-07/orders/%s/cancel", input.OrderID) | ||
resp, err := flexportRequest(ctx.Auth.Extra["api-key"], reqURL, http.MethodPost, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return resp, nil | ||
} | ||
|
||
func (c *CancelOrderOperation) Test(ctx *sdk.RunContext) (sdk.JSON, error) { | ||
return c.Run(ctx) | ||
} | ||
|
||
func (c *CancelOrderOperation) GetInfo() *sdk.OperationInfo { | ||
return c.options | ||
} |
71 changes: 71 additions & 0 deletions
71
internal/connectors/flexport/operation_get_all_products.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// 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 flexport | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/wakflo/go-sdk/autoform" | ||
sdk "github.com/wakflo/go-sdk/connector" | ||
sdkcore "github.com/wakflo/go-sdk/core" | ||
) | ||
|
||
type createMeetingOperationProps struct{} | ||
|
||
type GetProductsOperation struct { | ||
options *sdk.OperationInfo | ||
} | ||
|
||
func NewGetProductsOperation() *GetProductsOperation { | ||
return &GetProductsOperation{ | ||
options: &sdk.OperationInfo{ | ||
Name: "Get all products", | ||
Description: "Get all products", | ||
Auth: sharedAuth, | ||
Input: map[string]*sdkcore.AutoFormSchema{ | ||
"topic": autoform.NewShortTextField(). | ||
SetDisplayName(""). | ||
SetDescription(""). | ||
SetRequired(false).Build(), | ||
}, | ||
SampleOutput: map[string]interface{}{}, | ||
ErrorSettings: sdkcore.StepErrorSettings{ | ||
ContinueOnError: false, | ||
RetryOnError: false, | ||
}, | ||
RequireAuth: true, | ||
}, | ||
} | ||
} | ||
|
||
func (c *GetProductsOperation) Run(ctx *sdk.RunContext) (sdk.JSON, error) { | ||
_ = sdk.InputToType[createMeetingOperationProps](ctx) | ||
|
||
reqURL := "https://logistics-api.flexport.com/logistics/api/2024-07/products" | ||
|
||
resp, err := flexportRequest(ctx.Auth.Extra["api-key"], reqURL, http.MethodGet, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return resp, nil | ||
} | ||
|
||
func (c *GetProductsOperation) Test(ctx *sdk.RunContext) (sdk.JSON, error) { | ||
return c.Run(ctx) | ||
} | ||
|
||
func (c *GetProductsOperation) GetInfo() *sdk.OperationInfo { | ||
return c.options | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// 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 flexport | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/wakflo/go-sdk/autoform" | ||
sdk "github.com/wakflo/go-sdk/connector" | ||
sdkcore "github.com/wakflo/go-sdk/core" | ||
) | ||
|
||
type getOrderOperationProps struct { | ||
OrderID string `json:"Id"` | ||
} | ||
|
||
type GetOrderOperation struct { | ||
options *sdk.OperationInfo | ||
} | ||
|
||
func NewGetOrderOperation() *GetOrderOperation { | ||
return &GetOrderOperation{ | ||
options: &sdk.OperationInfo{ | ||
Name: "Get order by ID", | ||
Description: "Get order by ID", | ||
Auth: sharedAuth, | ||
Input: map[string]*sdkcore.AutoFormSchema{ | ||
"Id": autoform.NewShortTextField(). | ||
SetDisplayName("Order ID"). | ||
SetDescription("Order ID from flexport"). | ||
SetRequired(true).Build(), | ||
}, | ||
SampleOutput: map[string]interface{}{}, | ||
ErrorSettings: sdkcore.StepErrorSettings{ | ||
ContinueOnError: false, | ||
RetryOnError: false, | ||
}, | ||
RequireAuth: true, | ||
}, | ||
} | ||
} | ||
|
||
func (c *GetOrderOperation) Run(ctx *sdk.RunContext) (sdk.JSON, error) { | ||
input := sdk.InputToType[getOrderOperationProps](ctx) | ||
|
||
reqURL := "https://logistics-api.flexport.com/logistics/api/2024-07/orders/" + input.OrderID | ||
resp, err := flexportRequest(ctx.Auth.Extra["api-key"], reqURL, http.MethodGet, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return resp, nil | ||
} | ||
|
||
func (c *GetOrderOperation) Test(ctx *sdk.RunContext) (sdk.JSON, error) { | ||
return c.Run(ctx) | ||
} | ||
|
||
func (c *GetOrderOperation) GetInfo() *sdk.OperationInfo { | ||
return c.options | ||
} |
72 changes: 72 additions & 0 deletions
72
internal/connectors/flexport/operation_get_order_by_external_id.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// 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 flexport | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/wakflo/go-sdk/autoform" | ||
sdk "github.com/wakflo/go-sdk/connector" | ||
sdkcore "github.com/wakflo/go-sdk/core" | ||
) | ||
|
||
type getOrderByExternalIDOperationProps struct { | ||
ExternalOrderID string `json:"Id"` | ||
} | ||
|
||
type GetOrderByExternalIDOperation struct { | ||
options *sdk.OperationInfo | ||
} | ||
|
||
func NewGetOrderByExternalIDOperation() *GetOrderByExternalIDOperation { | ||
return &GetOrderByExternalIDOperation{ | ||
options: &sdk.OperationInfo{ | ||
Name: "Get order by External ID", | ||
Description: "Get order using the external order ID given during order creation.", | ||
Auth: sharedAuth, | ||
Input: map[string]*sdkcore.AutoFormSchema{ | ||
"Id": autoform.NewShortTextField(). | ||
SetDisplayName("External Order ID"). | ||
SetDescription("External Order ID from store(woocommerce, shopify etc.)"). | ||
SetRequired(true).Build(), | ||
}, | ||
SampleOutput: map[string]interface{}{}, | ||
ErrorSettings: sdkcore.StepErrorSettings{ | ||
ContinueOnError: false, | ||
RetryOnError: false, | ||
}, | ||
RequireAuth: true, | ||
}, | ||
} | ||
} | ||
|
||
func (c *GetOrderByExternalIDOperation) Run(ctx *sdk.RunContext) (sdk.JSON, error) { | ||
input := sdk.InputToType[getOrderByExternalIDOperationProps](ctx) | ||
|
||
reqURL := "https://logistics-api.flexport.com/logistics/api/2024-07/orders/external_id/" + input.ExternalOrderID | ||
resp, err := flexportRequest(ctx.Auth.Extra["api-key"], reqURL, http.MethodGet, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return resp, nil | ||
} | ||
|
||
func (c *GetOrderByExternalIDOperation) Test(ctx *sdk.RunContext) (sdk.JSON, error) { | ||
return c.Run(ctx) | ||
} | ||
|
||
func (c *GetOrderByExternalIDOperation) GetInfo() *sdk.OperationInfo { | ||
return c.options | ||
} |
Oops, something went wrong.