-
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
14 changed files
with
358 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = crlf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
# Project files | ||
[*.csproj] | ||
indent_size = 2 | ||
insert_final_newline = false | ||
|
||
# JSON files | ||
[*.json] | ||
indent_size = 2 | ||
|
||
# Configuration files | ||
[*.config] | ||
indent_size = 2 | ||
|
||
# Dotnet code style settings | ||
[*.{cs,vb}] | ||
|
||
# Sort using and Import directives with System.* appearing first | ||
dotnet_sort_system_directives_first = true | ||
|
||
# Avoid "this." and "Me." if not necessary | ||
dotnet_style_qualification_for_field = false:suggestion | ||
dotnet_style_qualification_for_property = false:suggestion | ||
dotnet_style_qualification_for_method = false:suggestion | ||
dotnet_style_qualification_for_event = false:suggestion | ||
|
||
# Use language keywords instead of framework type names for type references | ||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion | ||
dotnet_style_predefined_type_for_member_access = true:suggestion | ||
|
||
# Use explicit accessibility modifiers | ||
dotnet_style_require_accessibility_modifiers = true:suggestion | ||
|
||
# Suggest more modern language features when available | ||
dotnet_style_object_initializer = true:suggestion | ||
dotnet_style_collection_initializer = true:suggestion | ||
dotnet_style_coalesce_expression = true:suggestion | ||
dotnet_style_null_propagation = true:suggestion | ||
dotnet_style_explicit_tuple_names = true:suggestion | ||
dotnet_prefer_inferred_tuple_names = true:suggestion | ||
dotnet_prefer_inferred_anonymous_type_member_names = true:suggestion | ||
|
||
# CSharp code style settings | ||
[*.cs] | ||
|
||
# Prefer curly braces even for one line of code | ||
csharp_prefer_braces = true:suggestion | ||
|
||
# Prefer "var" everywhere | ||
csharp_style_var_for_built_in_types = true:suggestion | ||
csharp_style_var_when_type_is_apparent = true:suggestion | ||
csharp_style_var_elsewhere = true:suggestion | ||
|
||
# Prefer method-like constructs to have a block body | ||
csharp_style_expression_bodied_methods = false:none | ||
csharp_style_expression_bodied_constructors = false:none | ||
csharp_style_expression_bodied_operators = false:none | ||
|
||
# Prefer property-like constructs to have an expression-body | ||
csharp_style_expression_bodied_properties = true:none | ||
csharp_style_expression_bodied_indexers = true:none | ||
csharp_style_expression_bodied_accessors = true:none | ||
|
||
# Suggest more modern language features when available | ||
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion | ||
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion | ||
csharp_style_inlined_variable_declaration = true:suggestion | ||
csharp_style_throw_expression = true:suggestion | ||
csharp_style_conditional_delegate_call = true:suggestion | ||
csharp_prefer_simple_default_expression = true:suggestion | ||
csharp_style_deconstructed_variable_declaration = true:suggestion | ||
csharp_style_pattern_local_over_anonymous_function = true:suggestion | ||
|
||
# Newline settings | ||
csharp_new_line_before_open_brace = all | ||
csharp_new_line_before_else = true | ||
csharp_new_line_before_catch = true | ||
csharp_new_line_before_finally = true | ||
csharp_new_line_before_members_in_object_initializers = true | ||
csharp_new_line_before_members_in_anonymous_types = true | ||
csharp_new_line_between_query_expression_clauses = true | ||
|
||
csharp_indent_case_contents = true | ||
csharp_indent_switch_labels = true | ||
csharp_indent_labels = flush_left | ||
|
||
csharp_space_after_cast = false | ||
csharp_space_after_keywords_in_control_flow_statements = true | ||
csharp_space_between_method_declaration_parameter_list_parentheses = false | ||
csharp_space_between_method_call_parameter_list_parentheses = false | ||
csharp_space_between_parentheses = false | ||
|
||
csharp_preserve_single_line_statements = false | ||
csharp_preserve_single_line_blocks = true |
8 changes: 8 additions & 0 deletions
8
VirtoCommerce.WhatsAppNotification.Core/Gateway/IWhatsAppNotificationSendingGateway.cs
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,8 @@ | ||
using VirtoCommerce.Platform.Core.Notifications; | ||
|
||
namespace VirtoCommerce.WhatsAppNotification.Core.Gateway | ||
{ | ||
public interface IWhatsAppNotificationSendingGateway : INotificationSendingGateway | ||
{ | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
VirtoCommerce.WhatsAppNotification.Core/Notifications/WhatsAppNotification.cs
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,13 @@ | ||
using VirtoCommerce.Platform.Core.Notifications; | ||
using VirtoCommerce.WhatsAppNotification.Core.Gateway; | ||
|
||
namespace VirtoCommerce.WhatsAppNotification.Core.Notifications | ||
{ | ||
public class WhatsAppNotification : Notification | ||
{ | ||
public WhatsAppNotification(IWhatsAppNotificationSendingGateway notificationSendingGateway) | ||
: base(notificationSendingGateway) | ||
{ | ||
} | ||
} | ||
} |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" /> | ||
<package id="System.Collections.Immutable" version="1.4.0" targetFramework="net461" /> | ||
<package id="VirtoCommerce.Platform.Core" version="2.13.48" targetFramework="net461" /> | ||
</packages> |
4 changes: 4 additions & 0 deletions
4
VirtoCommerce.WhatsAppNotification.Data/Properties/AssemblyInfo.cs
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,4 @@ | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyTitle("VirtoCommerce.WhatsAppNotification.Data")] | ||
[assembly: AssemblyDescription("")] |
63 changes: 63 additions & 0 deletions
63
VirtoCommerce.WhatsAppNotification.Data/VirtoCommerce.WhatsAppNotification.Data.csproj
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,63 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{924E7BA3-9FE9-4020-B14C-E002A6D40083}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>VirtoCommerce.WhatsAppNotification.Data</RootNamespace> | ||
<AssemblyName>VirtoCommerce.WhatsAppNotification.Data</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Collections.Immutable, Version=1.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\System.Collections.Immutable.1.4.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="VirtoCommerce.Platform.Core, Version=2.13.48.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\VirtoCommerce.Platform.Core.2.13.48\lib\net461\VirtoCommerce.Platform.Core.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\CommonAssemblyInfo.cs"> | ||
<Link>Properties\CommonAssemblyInfo.cs</Link> | ||
</Compile> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="WhatsAppClient\WooWaClient.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
42 changes: 42 additions & 0 deletions
42
VirtoCommerce.WhatsAppNotification.Data/WhatsAppClient/WooWaClient.cs
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,42 @@ | ||
using System.Net; | ||
using System.Text; | ||
using VirtoCommerce.Platform.Core.Settings; | ||
|
||
namespace VirtoCommerce.WhatsAppNotification.Data.WhatsAppClient | ||
{ | ||
public class WooWaClient | ||
{ | ||
private readonly ISettingsManager _settingsManager; | ||
|
||
public WooWaClient(ISettingsManager settingsManager) | ||
{ | ||
_settingsManager = settingsManager; | ||
} | ||
|
||
public void SendMessage(string recipient, string message) | ||
{ | ||
var license = _settingsManager.GetValue("VirtoCommerce.WhatsApp.License", default(string)); | ||
var domain = _settingsManager.GetValue("VirtoCommerce.WhatsApp.Domain", default(string)); | ||
var apiEndpoint = _settingsManager.GetValue("VirtoCommerce.WhatsApp.APIEndpoint", default(string)); | ||
|
||
if (!string.IsNullOrEmpty(license) && !string.IsNullOrEmpty(domain) && !string.IsNullOrEmpty(apiEndpoint)) | ||
{ | ||
var request = (HttpWebRequest)WebRequest.Create($"{apiEndpoint}/send-message"); | ||
request.Method = "POST"; | ||
request.ContentType = "application/x-www-form-urlencoded"; | ||
|
||
var data = $"license={license}&domain={domain}&wa_number={recipient}&text={message}"; | ||
var byteArray = Encoding.UTF8.GetBytes(data); | ||
|
||
request.ContentLength = byteArray.Length; | ||
|
||
using (var dataStream = request.GetRequestStream()) | ||
{ | ||
dataStream.Write(byteArray, 0, byteArray.Length); | ||
} | ||
|
||
request.GetResponse(); | ||
} | ||
} | ||
} | ||
} |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" /> | ||
<package id="System.Collections.Immutable" version="1.4.0" targetFramework="net461" /> | ||
<package id="VirtoCommerce.Platform.Core" version="2.13.48" targetFramework="net461" /> | ||
</packages> |
33 changes: 33 additions & 0 deletions
33
VirtoCommerce.WhatsAppNotification.Web/Gateway/WhatsAppNotificationSendingGateway.cs
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,33 @@ | ||
using VirtoCommerce.Platform.Core.Notifications; | ||
using VirtoCommerce.WhatsAppNotification.Core.Gateway; | ||
using VirtoCommerce.WhatsAppNotification.Data.WhatsAppClient; | ||
|
||
namespace VirtoCommerce.WhatsAppNotification.Web.Gateway | ||
{ | ||
public class WhatsAppNotificationSendingGateway : IWhatsAppNotificationSendingGateway | ||
{ | ||
private readonly WooWaClient _client; | ||
|
||
public WhatsAppNotificationSendingGateway(WooWaClient client) | ||
{ | ||
_client = client; | ||
} | ||
|
||
public SendNotificationResult SendNotification(Notification notification) | ||
{ | ||
var result = new SendNotificationResult(); | ||
|
||
_client.SendMessage(notification.Recipient, notification.Body); | ||
|
||
result.IsSuccess = true; | ||
|
||
return result; | ||
} | ||
|
||
public bool ValidateNotification(Notification notification) | ||
{ | ||
return !string.IsNullOrEmpty(notification.Recipient) && | ||
!string.IsNullOrEmpty(notification.Body); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.