GetServertime
زمان جاری سرور را برمیگرداند
{{:: 'controllers.documentation.chooseFramework' | translate }}
PM > Install-Package
NikSms.Library.Net
PM > Install-Package
NikSms.Library.NetCore
using NikSms.Library.Net.WebApi;
using NikSms.Library.Net.ViewModels;
using System.Threading.Tasks;
using System;
namespace AwesomeApplication
{
public class NikSmsApiV1Client
{
private readonly PublicApiV1 service;
public NikSmsApiV1Client(string username, string password, string culture = "fa")
{
service = new PublicApiV1(username, password, culture);
}
public async Task<string> GetServertime()
{
var result = await service.GetServertime();
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.WebApi
Imports NikSms.Library.Net.ViewModels
Imports System.Threading.Tasks
Imports System
Namespace AwesomeApplication
Public Class NikSmsApiV1Client
Private ReadOnly service As PublicApiV1
Public Sub New(ByVal username As String, ByVal password As String, ByVal Optional culture As String = "fa")
service = New PublicApiV1(username, password, culture)
End Sub
Public Async Function GetServertime() As Task(Of String)
Dim result = Await service.GetServertime()
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 {
ApiV1,
LibOperationResultStatus
} from 'niksms';
export default class NikSmsApiV1Client{
private service: ApiV1
constructor(username: string, password: string, culture: string = "fa"){
this.service = new ApiV1(username, password, culture);
}
public async GetServertime(): Promise<string> {
const result = await this.service.GetServertime();
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/fa/publicapi/GetServertime?username=[username]&password=[passsword]
// METHODS: GET, POST
// RESULT: DATETIME