{{:: 'controllers.documentation.chooseFramework' | translate }}
PM > Install-Package NikSms.Library.Net
PM > Install-Package NikSms.Library.NetCore
using NikSms.Library.Net.ViewModels; using NikSms.Library.Net.WebApi; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace AwesomeApplication { public class NikSmsApiV2Client { private readonly PublicApiV2 service; public NikSmsApiV2Client(string username, string password) { service = new PublicApiV2(username, password); } public async Task<ApiV2ContactMember> ContactMemberCreate() { var result = await service.ContactMemberCreate(new ApiV2ContactMember { BirthDate = new DateTime(1986, 6, 13), Description = "test", Email = "nvd@kianfar.me", FullName = "Navid Kianfar", GroupId = 60078, Male = true, Married = false, Mobile = "989199219290", State = "تهران" }); switch (result.Status) { case LibOperationResultStatus.Success: return result.Data; case LibOperationResultStatus.InvalidModel: throw new Exception("Some required inputs are misssing..."); case LibOperationResultStatus.UnAuthorized: throw new Exception("Some thing is wrong with your account (call support!)"); case LibOperationResultStatus.Failed: throw new Exception("Ooops its our fault!"); default: throw new Exception("You sould not be here... :D"); } } } }
PM > Install-Package NikSms.Library.Net
PM > Install-Package NikSms.Library.NetCore
Imports NikSms.Library.Net.ViewModels Imports NikSms.Library.Net.WebApi Imports System Imports System.Collections.Generic Imports System.Threading.Tasks Namespace AwesomeApplication Public Class NikSmsApiV2Client Private ReadOnly service As PublicApiV2 Public Sub New(ByVal username As String, ByVal password As String) service = New PublicApiV2(username, password) End Sub Public Async Function ContactMemberCreate() As Task(Of ApiV2ContactMember) Dim result = Await service.ContactMemberCreate(New ApiV2ContactMember With { .BirthDate = New DateTime(1986, 6, 13), .Description = "test", .Email = "nvd@kianfar.me", .FullName = "Navid Kianfar", .GroupId = 60078, .Male = True, .Married = False, .Mobile = "989199219290", .State = "تهران" }) Select Case result.Status Case LibOperationResultStatus.Success Return result.Data Case LibOperationResultStatus.InvalidModel Throw New Exception("Some required inputs are misssing...") Case LibOperationResultStatus.UnAuthorized Throw New Exception("Some thing is wrong with your account (call support!)") Case LibOperationResultStatus.Failed Throw New Exception("Ooops its our fault!") Case Else Throw New Exception("You sould not be here... :D") End Select End Function End Class End Namespace
npm install --save niksms.library.javascript
import { ApiV2, ApiV2ContactMember, LibOperationResultStatus, } from 'niksms'; export default class NikSmsApiV2Client{ private service: ApiV2 constructor(username: string, password: string){ this.service = new ApiV2(username, password); } public async ContactMember(): Promise<ApiV2ContactMember> { const member = <ApiV2ContactMember>{ BirthDate: new Date(1986, 5, 13), Description: "test", Email: "nvd@kianfar.me", FullName: "Navid Kianfar", GroupId: 60078, Male: true, Married: false, Mobile: "989199219290", State: "تهران" }; const result = await this.service.ContactMemberCreate(member); switch (result.Status) { case LibOperationResultStatus.Success: return result.Data; case LibOperationResultStatus.InvalidModel: throw new Error("Some required inputs are misssing..."); case LibOperationResultStatus.UnAuthorized: throw new Error("Some thing is wrong with your account (call support!)"); case LibOperationResultStatus.Failed: throw new Error("Ooops its our fault!"); default: throw new Error("You sould not be here... :D"); } } }
// URL: https://niksms.com/api/v2/contact/members/create // PAY LOAD: { "Username": "989122399413", "Password": "*******", "GroupId": 61050512, "BirthDate": new Date(1986, 5, 13), "Description": "contact description", "Email": "nvd@kianfar.me", "FullName": "Navid Kianfar", "Male": true, "Married": false, "State": "تهران", "WeddingDate": null } // METHODS: GET, POST // RESULT: { "Data": { "BirthDate": "1986-05-13T00:00:00.000", "CreateDate": "2018-09-17T15:43:45.953", "CustomFields": {}, "Email": "nvd@kianfar.me", "FullName": "Navid Kianfar", "Male": true, "Married": false, "State": "تهران", "WeddingDate": null "GroupId": 60078, "Id": 61050512, "IsBlackList": false }, "Status": 4, "Exception": null }
{{:: 'controllers.documentation.titleTable' | translate }} {{:: 'controllers.documentation.mustDo' | translate }} {{:: 'controllers.documentation.typeTable' | translate }} ِ{{:: 'controllers.documentation.defualtValue' | translate }} ِ{{:: 'controllers.documentation.description' | translate }}
1 member بله Object public class ApiV2ContactMember { public DateTime? BirthDate { get; set; } public DateTime CreateDate { get; set; } public Dictionary<int, string> CustomFields { get; set; } public string Description { get; set; } public string Email { get; set; } public string FullName { get; set; } public long GroupId { get; set; } public long Id { get; set; } public bool IsBlackList { get; set; } public bool Male { get; set; } public bool Married { get; set; } public string Mobile { get; set; } public string State { get; set; } public DateTime? WeddingDate { get; set; } }
{{:: 'controllers.documentation.titleTable' | translate }} {{:: 'controllers.documentation.typeTable' | translate }} {{:: 'controllers.documentation.description' | translate }}
1
LibOperationResult<ApiV2ContactMember>
Object public class ApiV2ContactMember { public DateTime? BirthDate { get; set; } public DateTime CreateDate { get; set; } public Dictionary<int, string> CustomFields { get; set; } public string Description { get; set; } public string Email { get; set; } public string FullName { get; set; } public long GroupId { get; set; } public long Id { get; set; } public bool IsBlackList { get; set; } public bool Male { get; set; } public bool Married { get; set; } public string Mobile { get; set; } public string State { get; set; } public DateTime? WeddingDate { get; set; } }