Skip to content

Commit f4e2053

Browse files
committed
V14 Integrations (Semrush)
- Minor changes
1 parent 2da311f commit f4e2053

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

src/Umbraco.Forms.Integrations.Crm.Hubspot/Client/src/lang/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
FieldMappingsDescription: `Map Umbraco Form fields to Hubspot contact fields`,
66
},
77
hubspotFormWorkflow:{
8-
SelectHubspotField : `Select Hubspot field`,
8+
SelectHubspotField : `Select HubSpot field`,
99
SelectFormField: `Select Form field`,
1010
},
1111
} as UmbLocalizationDictionary;

src/Umbraco.Forms.Integrations.Crm.Hubspot/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static class ManagementApi
88

99
public const string ApiName = "hubspot-management";
1010

11-
public const string ApiTitle = "Hubspot Management API";
11+
public const string ApiTitle = "HubSpot Management API";
1212

1313
public const string ContactGroupName = "Contacts";
1414

src/Umbraco.Forms.Integrations.Crm.Hubspot/HubspotComposer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void Compose(IUmbracoBuilder builder)
3030
{
3131
Title = Constants.ManagementApi.ApiTitle,
3232
Version = "Latest",
33-
Description = $"Describes the {Constants.ManagementApi.ApiTitle} available for handling Hubspot-CRM automation and configuration."
33+
Description = $"Describes the {Constants.ManagementApi.ApiTitle} available for handling HubSpot CRM automation and configuration."
3434
});
3535

3636
options.CustomOperationIds(e => $"{e.ActionDescriptor.RouteValues["action"]}");

src/Umbraco.Forms.Integrations.Crm.Hubspot/HubspotWorkflow.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Microsoft.Extensions.Logging;
2-
3-
using Newtonsoft.Json;
2+
using System.Text.Json;
43
using Umbraco.Forms.Core;
54
using Umbraco.Forms.Core.Attributes;
65
using Umbraco.Forms.Core.Enums;
@@ -33,15 +32,10 @@ public HubspotWorkflow(ILogger<HubspotWorkflow> logger, IContactService contactS
3332
[Setting("Field Mappings", Description = "Map Umbraco Form fields to HubSpot contact fields", View = "Hubspot.PropertyEditorUi.Mapping")]
3433
public string FieldMappings { get; set; }
3534

36-
public WorkflowExecutionStatus Execute(WorkflowExecutionContext context)
37-
{
38-
throw new NotImplementedException();
39-
}
40-
4135
public override async Task<WorkflowExecutionStatus> ExecuteAsync(WorkflowExecutionContext context)
4236
{
4337
var fieldMappingsRawJson = FieldMappings;
44-
var fieldMappings = JsonConvert.DeserializeObject<List<MappedProperty>>(fieldMappingsRawJson);
38+
var fieldMappings = JsonSerializer.Deserialize<List<MappedProperty>>(fieldMappingsRawJson);
4539
if (fieldMappings.Count == 0)
4640
{
4741
_logger.LogWarning("Save Contact to HubSpot: Missing HubSpot field mappings for workflow for the form {FormName} ({FormId})", context.Form.Name, context.Form.Id);

src/Umbraco.Forms.Integrations.Crm.Hubspot/Services/HubspotContactService.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public async Task<AuthorizationResult> AuthorizeAsync(string code)
6868
AuthorizationCode = code,
6969
};
7070
var response = await GetResponse(OAuthTokenProxyUrl,
71-
HttpMethod.Post, content: tokenRequest, contentType: "application/x-www-form-urlencoded").ConfigureAwait(false);
71+
HttpMethod.Post, content: tokenRequest, contentType: "application/x-www-form-urlencoded");
7272
if (response.IsSuccessStatusCode)
7373
{
7474
var responseContent = await response.Content.ReadAsStringAsync();
@@ -108,7 +108,7 @@ public async Task<IEnumerable<Property>> GetContactPropertiesAsync()
108108

109109
var requestUrl = $"{CrmV3ApiBaseUrl}properties/contacts";
110110
var httpMethod = HttpMethod.Get;
111-
var response = await GetResponse(requestUrl, httpMethod, authenticationDetails).ConfigureAwait(false);
111+
var response = await GetResponse(requestUrl, httpMethod, authenticationDetails);
112112
if (response.IsSuccessStatusCode == false)
113113
{
114114
var retryResult = await HandleFailedRequest(response.StatusCode, requestUrl, httpMethod, authenticationDetails);
@@ -190,7 +190,7 @@ public async Task<CommandResult> PostContactAsync(Record record, List<MappedProp
190190
// https://api.hubapi.com/crm/v3/objects/contacts?hapikey=YOUR_HUBSPOT_API_KEY
191191
var requestUrl = $"{CrmV3ApiBaseUrl}objects/contacts";
192192
var httpMethod = HttpMethod.Post;
193-
var response = await GetResponse(requestUrl, httpMethod, authenticationDetails, propertiesRequestV3, JsonContentType).ConfigureAwait(false);
193+
var response = await GetResponse(requestUrl, httpMethod, authenticationDetails, propertiesRequestV3, JsonContentType);
194194

195195
// Depending on POST status fail or mark workflow as completed
196196
if (response.IsSuccessStatusCode == false)
@@ -235,7 +235,7 @@ private async Task<CommandResult> UpdateContactAsync(Record record, Authenticati
235235
// It uses the V1 API but support suggests it will be added to V3 before being depreciated so we can use safely:
236236
// https://community.hubspot.com/t5/APIs-Integrations/Get-Contacts-from-contact-list-using-email/m-p/419493/highlight/true#M41567
237237
var requestUrl = $"{CrmApiHost}/contacts/v1/contact/email/{email}/profile";
238-
var response = await GetResponse(requestUrl, HttpMethod.Post, authenticationDetails, postData, JsonContentType).ConfigureAwait(false);
238+
var response = await GetResponse(requestUrl, HttpMethod.Post, authenticationDetails, postData, JsonContentType);
239239
if (response.IsSuccessStatusCode == false)
240240
{
241241
var retryResult = await HandleFailedRequest(response.StatusCode, requestUrl, HttpMethod.Post, authenticationDetails, postData, JsonContentType);
@@ -308,7 +308,7 @@ private async Task<string> GetOAuthAccessTokenFromCacheOrRefreshToken(string ref
308308
if (accessToken != null)
309309
{
310310
// No access token in the cache, so get a new one from the refresh token.
311-
await RefreshOAuthAccessToken(refreshToken).ConfigureAwait(false);
311+
await RefreshOAuthAccessToken(refreshToken);
312312
accessToken = _appCaches.RuntimeCache.Get(AccessTokenCacheKey).ToString();
313313
}
314314

@@ -323,7 +323,7 @@ private async Task RefreshOAuthAccessToken(string refreshToken)
323323
RedirectUrl = OAuthRedirectUrl,
324324
RefreshToken = refreshToken,
325325
};
326-
var response = await GetResponse(OAuthTokenProxyUrl, HttpMethod.Post, content: tokenRequest, contentType: "application/x-www-form-urlencoded").ConfigureAwait(false);
326+
var response = await GetResponse(OAuthTokenProxyUrl, HttpMethod.Post, content: tokenRequest, contentType: "application/x-www-form-urlencoded");
327327
if (response.IsSuccessStatusCode)
328328
{
329329
var responseContent = await response.Content.ReadAsStringAsync();
@@ -382,12 +382,12 @@ private async Task<HttpResponseMessage> GetResponse(
382382
case AuthenticationMode.OAuth:
383383
requestMessage.Headers.Authorization =
384384
new AuthenticationHeaderValue("Bearer",
385-
await GetOAuthAccessTokenFromCacheOrRefreshToken(authenticationDetails.RefreshToken).ConfigureAwait(false));
385+
await GetOAuthAccessTokenFromCacheOrRefreshToken(authenticationDetails.RefreshToken));
386386
break;
387387
}
388388
}
389389

390-
return await httpClient.SendAsync(requestMessage).ConfigureAwait(false);
390+
return await httpClient.SendAsync(requestMessage);
391391
}
392392

393393
private static HttpContent CreateRequestContent(object data, string contentType)
@@ -430,7 +430,7 @@ private async Task<HandleFailedRequestResult> HandleFailedRequest(
430430
await RefreshOAuthAccessToken(authenticationDetails.RefreshToken);
431431

432432
// Repeat the operation using the refreshed token.
433-
var response = await GetResponse(requestUrl, httpMethod, authenticationDetails, content, contentType).ConfigureAwait(false);
433+
var response = await GetResponse(requestUrl, httpMethod, authenticationDetails, content, contentType);
434434
if (response.IsSuccessStatusCode)
435435
{
436436
result.Success = true;

0 commit comments

Comments
 (0)