Skip to content

Commit

Permalink
Merge pull request #103 from umbraco/v14/feature/42961-V14-Integratio…
Browse files Browse the repository at this point in the history
…ns-(HubSpot/Forms)

V14: Integrations (HubSpot/Forms)
  • Loading branch information
dtng95 authored Oct 2, 2024
2 parents 08b6bd3 + 7c5c5a9 commit 2000e76
Show file tree
Hide file tree
Showing 53 changed files with 610 additions and 1,243 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Forms.Integrations.Crm.Hubspot.Models.Dtos;
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;

Expand All @@ -17,7 +12,7 @@ public AuthorizeController(IContactService contactService) : base(contactService
}

[HttpPost("authorize")]
[ProducesResponseType(typeof(Task<AuthorizationResult>), StatusCodes.Status200OK)]
public async Task<IActionResult> Authorize([FromBody] AuthorizationRequest request) => Ok(await ContactService.AuthorizeAsync(request.Code));
[ProducesResponseType(typeof(AuthorizationResult), StatusCodes.Status200OK)]
public async Task<IActionResult> Authorize([FromBody]AuthorizationRequest request) => Ok(await ContactService.AuthorizeAsync(request.Code));
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using Asp.Versioning;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Forms.Integrations.Crm.Hubspot.Models.Dtos;
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Forms.Integrations.Crm.Hubspot.Models.Responses;
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;

namespace Umbraco.Forms.Integrations.Crm.Hubspot.Api.Management.Controllers.Contacts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;

namespace Umbraco.Forms.Integrations.Crm.Hubspot.Api.Management.Controllers.Contacts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Asp.Versioning;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Forms.Core.Services;

namespace Umbraco.Forms.Integrations.Crm.Hubspot.Api.Management.Controllers.Forms
{
[ApiVersion("1.0")]
[BackOfficeRoute($"{Constants.ManagementApi.RootPath}/v{{version:apiVersion}}/forms")]
[ApiExplorerSettings(GroupName = Constants.ManagementApi.FormGroupName)]
public class FormControllerBase : HubspotControllerBase
{
protected readonly IFormService FormService;

public FormControllerBase(IFormService formService)
{
FormService = formService;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Forms.Core.Services;
using Umbraco.Forms.Integrations.Crm.Hubspot.Models.Dtos;

namespace Umbraco.Forms.Integrations.Crm.Hubspot.Api.Management.Controllers.Forms
{
public class GetFormFieldsController : FormControllerBase
{
public GetFormFieldsController(IFormService formService) : base(formService)
{
}

[HttpGet("fields")]
[ProducesResponseType(typeof(List<HubspotWorkflowFormFieldDto>), StatusCodes.Status200OK)]
public IActionResult GetFormFields(string formId)
{
List<HubspotWorkflowFormFieldDto> formFields = new List<HubspotWorkflowFormFieldDto>();
var result = FormService.Get(new Guid(formId));
if (result != null)
{
formFields = result.AllFields.Select(s => new HubspotWorkflowFormFieldDto{ Caption = s.Caption, Id = s.Id }).ToList();
}
return Ok(formFields);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Cms.Api.Common.Attributes;
using Umbraco.Cms.Web.Common.Authorization;
using Umbraco.Cms.Web.Common.Routing;

namespace Umbraco.Forms.Integrations.Crm.Hubspot.Api.Management.Controllers
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const outputPath = 'Debug' !== 'Release' ? '../wwwroot' : '../obj/Debug/net8.0/clientassets'
export const outputPath = 'Debug' !== 'Release' ? '../wwwroot' : '../obj/Debug/net8.0/clientassets'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { CancelablePromise } from './core/CancelablePromise';
import { OpenAPI } from './core/OpenAPI';
import { request as __request } from './core/request';
import type { IsAuthorizationConfiguredResponse, GetAuthenticationUrlResponse, AuthorizeData, AuthorizeResponse, DeauthorizeResponse, GetAllResponse } from './types.gen';
import type { IsAuthorizationConfiguredResponse, GetAuthenticationUrlResponse, AuthorizeData, AuthorizeResponse, DeauthorizeResponse, GetAllResponse, GetFormFieldsData, GetFormFieldsResponse } from './types.gen';

export class ContactsService {
/**
Expand Down Expand Up @@ -65,4 +65,23 @@ export class ContactsService {
});
}

}

export class FormsService {
/**
* @param data The data for the request.
* @param data.formId
* @returns unknown OK
* @throws ApiError
*/
public static getFormFields(data: GetFormFieldsData = {}): CancelablePromise<GetFormFieldsResponse> {
return __request(OpenAPI, {
method: 'GET',
url: '/umbraco/hubspot/management/api/v1/forms/fields',
query: {
formId: data.formId
}
});
}

}
Loading

0 comments on commit 2000e76

Please sign in to comment.