Repository: amp-labs/connectors
Pull request #122 (2024-03-22 10:53:43)

[ENG-881] feat: Add Microsoft dynamic365-business-central connector
## Catalog variables
Dynamics365BusinessCentral Provider = "dynamics365BusinessCentral"

## Notes
Supports batching requests and pagination as well

## Testing

### GET

URL: http://localhost:4444/v2.0/2a909abc-d594-408f-bfa0-cffbe67bc4bf/Production/api/v2.0/companies(7ace90d9-b3d3-ee11-904f-6045bde9c6f5)/projects(f30643f2-91e7-ee11-a1fd-6045bda565d9)
![GET](https://github.com/amp-labs/connectors/assets/163011126/0a9a5ded-7b82-4071-8d3d-fc12a9410612)

### POST

URL: http://localhost:4444/v2.0/2a909abc-d594-408f-bfa0-cffbe67bc4bf/Production/api/v2.0/companies(7ace90d9-b3d3-ee11-904f-6045bde9c6f5)/projects
![POST](https://github.com/amp-labs/connectors/assets/163011126/1f0080e6-bcb5-4772-bab5-3c51e86c8b29)

### PUT/PATCH

URL: http://localhost:4444/v2.0/2a909abc-d594-408f-bfa0-cffbe67bc4bf/Production/api/v2.0/companies(7ace90d9-b3d3-ee11-904f-6045bde9c6f5)/projects(f30643f2-91e7-ee11-a1fd-6045bda565d9)
![PATCH](https://github.com/amp-labs/connectors/assets/163011126/24b7499c-6aef-42d8-921c-16d4cb8050ca)

### DELETE

URL: http://localhost:4444/v2.0/2a909abc-d594-408f-bfa0-cffbe67bc4bf/Production/api/v2.0/companies(7ace90d9-b3d3-ee11-904f-6045bde9c6f5)/projects(f30643f2-91e7-ee11-a1fd-6045bda565d9)
![DELETE](https://github.com/amp-labs/connectors/assets/163011126/600c29f0-b6eb-4b26-97cd-7439be8c417e)



Patch:
diff --git a/providers/catalog.go b/providers/catalog.go
index 912abfd0..0a4ea8f4 100644
--- a/providers/catalog.go
+++ b/providers/catalog.go
@@ -5,31 +5,32 @@ package providers
 // ================================================================================
 
 const (
-	Salesforce                Provider = "salesforce"
-	Hubspot                   Provider = "hubspot"
-	LinkedIn                  Provider = "linkedIn"
-	Salesloft                 Provider = "salesloft"
-	Outreach                  Provider = "outreach"
-	Pipedrive                 Provider = "pipedrive"
-	Copper                    Provider = "copper"
-	ZohoCRM                   Provider = "zohoCRM"
-	Sellsy                    Provider = "sellsy"
-	Attio                     Provider = "attio"
-	Close                     Provider = "close"
-	Keap                      Provider = "keap"
-	Asana                     Provider = "asana"
-	Dropbox                   Provider = "dropbox"
-	Notion                    Provider = "notion"
-	Gong                      Provider = "gong"
-	Zoom                      Provider = "zoom"
-	Intercom                  Provider = "intercom"
-	DocuSign                  Provider = "docuSign"
-	DocuSignDeveloper         Provider = "docuSignDeveloper"
-	Calendly                  Provider = "calendly"
-	AWeber                    Provider = "aWeber"
-	GetResponse               Provider = "getResponse"
-	ConstantContact           Provider = "constantContact"
-	MicrosoftDynamics365Sales Provider = "microsoftDynamics365Sales"
+	Salesforce                          Provider = "salesforce"
+	Hubspot                             Provider = "hubspot"
+	LinkedIn                            Provider = "linkedIn"
+	Salesloft                           Provider = "salesloft"
+	Outreach                            Provider = "outreach"
+	Pipedrive                           Provider = "pipedrive"
+	Copper                              Provider = "copper"
+	ZohoCRM                             Provider = "zohoCRM"
+	Sellsy                              Provider = "sellsy"
+	Attio                               Provider = "attio"
+	Close                               Provider = "close"
+	Keap                                Provider = "keap"
+	Asana                               Provider = "asana"
+	Dropbox                             Provider = "dropbox"
+	Notion                              Provider = "notion"
+	Gong                                Provider = "gong"
+	Zoom                                Provider = "zoom"
+	Intercom                            Provider = "intercom"
+	DocuSign                            Provider = "docuSign"
+	DocuSignDeveloper                   Provider = "docuSignDeveloper"
+	Calendly                            Provider = "calendly"
+	AWeber                              Provider = "aWeber"
+	GetResponse                         Provider = "getResponse"
+	ConstantContact                     Provider = "constantContact"
+	MicrosoftDynamics365Sales           Provider = "microsoftDynamics365Sales"
+	MicrosoftDynamics365BusinessCentral Provider = "microsoftDynamics365BusinessCentral"
 )
 
 // ================================================================================
@@ -527,4 +528,26 @@ var catalog = CatalogType{ // nolint:gochecknoglobals
 			Write:     false,
 		},
 	},
+
+	// Microsoft Dynamics 365 Business Central configuration
+	MicrosoftDynamics365BusinessCentral: {
+		AuthType: Oauth2,
+		BaseURL:  "https://api.businesscentral.dynamics.com",
+		OauthOpts: OauthOpts{
+			AuthURL:                   "https://login.microsoftonline.com/{{.workspace}}/oauth2/v2.0/authorize",
+			TokenURL:                  "https://login.microsoftonline.com/{{.workspace}}/oauth2/v2.0/token",
+			ExplicitScopesRequired:    true,
+			ExplicitWorkspaceRequired: true,
+			TokenMetadataFields: TokenMetadataFields{
+				ScopesField: "scope",
+			},
+		},
+		Support: Support{
+			BulkWrite: false,
+			Proxy:     false,
+			Read:      false,
+			Subscribe: false,
+			Write:     false,
+		},
+	},
 }


Test patch:
diff --git a/providers/catalog_test.go b/providers/catalog_test.go
index 19cdc754..d80c6136 100644
--- a/providers/catalog_test.go
+++ b/providers/catalog_test.go
@@ -617,6 +617,34 @@ var testCases = []struct { // nolint
 		},
 		expectedErr: nil,
 	},
+	{
+		provider:    MicrosoftDynamics365BusinessCentral,
+		description: "Dynamics 365 Business Central provider config with substitutions",
+		substitutions: map[string]string{
+			"workspace": "tenantID",
+		},
+		expected: &ProviderInfo{
+			Support: Support{
+				Read:      false,
+				Write:     false,
+				BulkWrite: false,
+				Subscribe: false,
+				Proxy:     false,
+			},
+			AuthType: Oauth2,
+			OauthOpts: OauthOpts{
+				AuthURL:                   "https://login.microsoftonline.com/tenantID/oauth2/v2.0/authorize",
+				TokenURL:                  "https://login.microsoftonline.com/tenantID/oauth2/v2.0/token",
+				ExplicitScopesRequired:    true,
+				ExplicitWorkspaceRequired: true,
+				TokenMetadataFields: TokenMetadataFields{
+					ScopesField: "scope",
+				},
+			},
+			BaseURL: "https://api.businesscentral.dynamics.com",
+		},
+		expectedErr: nil,
+	},
 }
 
 func TestReadInfo(t *testing.T) { // nolint