Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Release 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zodt authored Mar 2, 2021
2 parents 33fe31d + 9d2d8e1 commit fe653db
Show file tree
Hide file tree
Showing 325 changed files with 2,559 additions and 577 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
*.nuget.props
*.nuget.targets
*.orig
*.DS_Store
*.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This method is available in both synchronous and asynchronous implementations.
## Response
| `Parameter` | `Description` | `The data type of the parameter` |
|:---------------------:|:---------------------------|:--------------------------------:|
| `Result` | Execution result | `IChatApiCreateInstanceResult`
| `Result` | Result of creating a Chat Api instance | `IChatApiCreateInstanceResult`

## Parameters of the `IChatApiCreateInstanceResult`
| `Parameter` | `Description` | `The data type of the parameter` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This method is available in both synchronous and asynchronous implementations.
| `PaidTill` | End date of the paid period | `DateTime`
| `Instance` | The unique identifier of the instance | `String`
| `IsActive` | An indicator of the activity instance | `Boolean`
| `TypeInstance` | Instance t ype | `ChatApiInstanceType`
| `TypeInstance` | Instance type | `ChatApiInstanceType`
| `PaymentsCount` | Number of paid months | `Integer`

## Example
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Updates the QR code after its expired
# Updates the QR code after its expired.
**<span style="color:green">Implementation notes</span>**<br/>
This method is available in both synchronous and asynchronous implementations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This method is available in both synchronous and asynchronous implementations.
## Response
| `Parameter` | `Description` | `The data type of the parameter` |
|:---------------------:|:--------------------------------------------------------|:--------------------------------:|
| `Read` | The status of the request. | `Boolean` |
| `Read` | Message readability indicator | `Boolean` |
| `ChatId` | Unique ID of the dialog. | `String` |
| `Message` | Dialog reading status | `String` |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ namespace ChatApiClient

var chatApiResponse = userInterfaceOperations.SendTypingStatus(request);
if (!chatApiResponse.IsSuccess) throw chatApiResponse.Exception!;

var response = chatApiResponse.GetResult();

Console.WriteLine(response?.PrintMembers());
}
}
Expand Down
File renamed without changes
89 changes: 56 additions & 33 deletions Src/ChatApi.Core/ChatApi.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,48 +1,71 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9</LangVersion>

<!-- Basic technical information about the project -->
<Nullable>enable</Nullable>
<LangVersion>9</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>

<!-- Generating a NuGet package (with docs) -->
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>

<!-- Information about the NuGet package -->
<Title>ChatApi.Core</Title>
<Authors>Roman Vorontsov</Authors>
<Description>ChatApi is an unofficial cross-platform libraries for interacting with the chat-api.com</Description>
<PackageLicenseUrl></PackageLicenseUrl>
<RepositoryUrl>https://github.com/Zodt/ChatApi</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<NeutralLanguage>en</NeutralLanguage>
<PackageIcon>ChatApi.png</PackageIcon>
<PackageVersion>1.0.1-alpha</PackageVersion>
<PackageTags>ChatApi, WhatsAppApi, WhatsApp-Api, WhatsApp</PackageTags>
<PackageProjectUrl></PackageProjectUrl>
<Description>
ChatApi is an unofficial cross-platform libraries for interacting with the chat-api.com
</Description>
<ReleaseNotes>
1. Refactoring code
2. Add xml doc
</ReleaseNotes>

<!-- NuGet Package license information -->
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageIcon>ChatApi.png</PackageIcon>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<!-- Information about the project repository -->
<RepositoryType>GitHub</RepositoryType>
<RepositoryUrl>https://github.com/Zodt/ChatApi</RepositoryUrl>

</PropertyGroup>

<ItemGroup>
<None Include="..\ChatApi.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>

<!-- References -->
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />

<!-- Resources -->
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>

<!-- NuGet project logo -->
<None Include="../../Images/ChatApi.png">
<Pack>True</Pack>
<PackagePath />
</None>

</ItemGroup>

</Project>
<!-- Copying a NuGet package to a specific directory -->
<Target Name="CopyCustomContent" AfterTargets="AfterBuild"
Condition="Exists('..\..\Src\$(ProjectName)\bin\$(Configuration)\$(ProjectName).$(PackageVersion).nupkg')">
<Copy SourceFiles="..\..\Src\$(ProjectName)\bin\$(Configuration)\$(ProjectName).$(PackageVersion).nupkg"
DestinationFolder="..\..\NuGet\$(PackageVersion)" SkipUnchangedFiles="false" ContinueOnError="true" />
</Target>

</Project>
89 changes: 73 additions & 16 deletions Src/ChatApi.Core/Collections/WhatsAppApiCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@

namespace ChatApi.Core.Collections
{
/// <summary>Provides the base class for a generic WhatsApp-collection.</summary>
/// <typeparam name="T">The type of elements in the collection.</typeparam>
public abstract class WhatsAppApiCollection<T> : Collection<T?>, IPrintableCollection, IEquatable<Collection<T?>?> where T : class, IEquatable<T?>
{
#region Overridden collection methods

/// <summary>
/// Adds an object to the end of the <see cref="T:System.Collections.ObjectModel.Collection`1"></see>.
/// </summary>
/// <param name="item">The object to be added to the end of the <see cref="T:System.Collections.ObjectModel.Collection`1"></see>. The value can be null for reference types.</param>
public new void Add(T item)
{
if (Items.Contains(item)) return;
Expand All @@ -22,39 +28,71 @@ public abstract class WhatsAppApiCollection<T> : Collection<T?>, IPrintableColle

#region AddRange

public void AddRange(IEnumerable<T> enumerable)
/// <summary>
/// Adds the elements of the specified collection to the end of the <see cref="T:System.Collections.Generic.IEnumerable`1"></see>.
/// </summary>
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="T:System.Collections.Generic.IEnumerable`1"></see>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection">collection</paramref> is null.</exception>
public void AddRange(IEnumerable<T> collection)
{
IList<T> list = enumerable.ToList();
if (collection is null) throw new ArgumentNullException(nameof(collection));

IList<T> list = collection.ToList();
// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 0; i < list.Count; i++)
if (!Items.Contains(list[i]))
base.Add(list[i]);
}
public void AddRange(IList<T> enumerable)

/// <summary>
/// Adds the elements of the specified collection to the end of the <see cref="T:System.Collections.Generic.IList`1"></see>.
/// </summary>
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="T:System.Collections.Generic.IList`1"></see>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection">collection</paramref> is null.</exception>
public void AddRange(IList<T>? collection)
{
if (collection is null) throw new ArgumentNullException(nameof(collection));

// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 0; i < enumerable.Count; i++)
if (!Items.Contains(enumerable[i]))
base.Add(enumerable[i]);
for (int i = 0; i < collection.Count; i++)
if (!Items.Contains(collection[i]))
base.Add(collection[i]);
}
public void AddRange(ICollection<T> enumerable)
/// <summary>
/// Adds the elements of the specified collection to the end of the <see cref="T:System.Collections.Generic.ICollection`1"></see>.
/// </summary>
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="T:System.Collections.Generic.ICollection`1"></see>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection">collection</paramref> is null.</exception>
public void AddRange(ICollection<T> collection)
{
IList<T> list = enumerable.ToList();
if (collection is null) throw new ArgumentNullException(nameof(collection));
IList<T> list = collection.ToList();
// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 0; i < list.Count; i++)
if (!Items.Contains(list[i]))
base.Add(list[i]);
}
public void AddRange(IReadOnlyList<T> enumerable)
/// <summary>
/// Adds the elements of the specified collection to the end of the <see cref="T:System.Collections.Generic.IReadOnlyList`1"></see>.
/// </summary>
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="T:System.Collections.Generic.IReadOnlyList`1"></see>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection">collection</paramref> is null.</exception>
public void AddRange(IReadOnlyList<T> collection)
{
if (collection is null) throw new ArgumentNullException(nameof(collection));
// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 0; i < enumerable.Count; i++)
if (!Items.Contains(enumerable[i]))
base.Add(enumerable[i]);
for (int i = 0; i < collection.Count; i++)
if (!Items.Contains(collection[i]))
base.Add(collection[i]);
}
public void AddRange(IReadOnlyCollection<T> enumerable)
/// <summary>
/// Adds the elements of the specified collection to the end of the <see cref="T:System.Collections.Generic.IReadOnlyCollection`1"></see>.
/// </summary>
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="T:System.Collections.Generic.IReadOnlyCollection`1"></see>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection">collection</paramref> is null.</exception>
public void AddRange(IReadOnlyCollection<T> collection)
{
IList<T> list = enumerable.ToList();
IList<T> list = collection.ToList();
// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 0; i < list.Count; i++)
if (!Items.Contains(list[i]))
Expand All @@ -68,6 +106,7 @@ public void AddRange(IReadOnlyCollection<T> enumerable)

#region Equatable

/// <inheritdoc />
public bool Equals(Collection<T?>? other)
{
if (other is null || other.Count != Count) return false;
Expand All @@ -88,6 +127,7 @@ public bool Equals(Collection<T?>? other)
return true;
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
Expand All @@ -102,8 +142,22 @@ public override int GetHashCode()
}
}

/// <inheritdoc />
public override bool Equals(object? obj) => ReferenceEquals(this, obj) || obj is Collection<T?> self && Equals(self);

/// <summary>
///
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
public static bool operator == (WhatsAppApiCollection<T>? left, WhatsAppApiCollection<T>? right) => EquatableHelper.IsEquatable(left, right);
/// <summary>
///
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
public static bool operator != (WhatsAppApiCollection<T>? left, WhatsAppApiCollection<T>? right) => !EquatableHelper.IsEquatable(left, right);

#endregion
Expand All @@ -128,6 +182,7 @@ private static string GetShift(int? shiftValue)
return stringBuilder.ToString();
}

/// <inheritdoc />
public string PrintMembers()
{
int shift = default;
Expand Down Expand Up @@ -155,6 +210,7 @@ public string PrintMembers()

return _stringBuilder.ToString();
}
/// <inheritdoc />
public string PrintMembers(int shift)
{
_stringBuilder.AppendLine("[");
Expand All @@ -167,11 +223,11 @@ public string PrintMembers(int shift)
int maxPrint = Count >= 3 ? 3 : Count;

string currentShift = GetShift(++shift);
if (this[0] is Printable)
if (this[0] is IPrintable)
for (int i = 0; i <= maxPrint - 1; i++)
_stringBuilder.AppendLine(string.Concat((this[i] as Printable)!.PrintMembers(shift-1), ", "));

else if (this[0] is string || !typeof(T).IsInterface)
else if (!typeof(T).IsInterface || !typeof(T).IsClass)
for (int i = 0; i <= maxPrint - 1; i++)
_stringBuilder.AppendLine(string.Concat(currentShift, this[i], ", "));

Expand All @@ -184,6 +240,7 @@ public string PrintMembers(int shift)
return _stringBuilder.ToString();
}

/// <inheritdoc />
public string PrintMembers(int countElementPrint, int shift)
{
_stringBuilder.AppendLine("[");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

namespace ChatApi.Core.Connect.Interfaces
{
/// <summary/>
public interface IChatApiInstanceConnect : IConnect, IChatApiKey { }
}
1 change: 1 addition & 0 deletions Src/ChatApi.Core/Connect/Interfaces/IConnect.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace ChatApi.Core.Connect.Interfaces
{
/// <summary/>
public interface IConnect { }
}
10 changes: 10 additions & 0 deletions Src/ChatApi.Core/Connect/Interfaces/IWhatsAppConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

namespace ChatApi.Core.Connect.Interfaces
{
/// <summary/>
public interface IWhatsAppConnect : IConnect, IEquatable<IWhatsAppConnect?>
{
/// <summary>
/// The unique identifier of the instance
/// </summary>
string? Token { get; }
/// <summary>
/// The prefix of the server. The old logic
/// </summary>
string? Server { get; }
/// <summary>
/// A unique token for accessing the server for this instance
/// </summary>
string? Instance { get; }
}
}
Loading

0 comments on commit fe653db

Please sign in to comment.