Message-ID: <729350097.15723.1614957831379.JavaMail.confluence@wiki> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_15722_343308441.1614957831379" ------=_Part_15722_343308441.1614957831379 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html A few Simple Uses - C#

A few Simple Uses - C#

=20
=20
=20
=20

 

=20
=20
=20
=20
=20
=20
=20
=20 =20
=20
=20
using RestAPI;
using System;
namespace TestRestAPI.Examples {
    class SendSMS {
        static void Main(string[] args) {
            RestClient rClient =3D new RestClient("MyUser", "=
;MyPass", RestClient.ENV_PRODUCTION);
            try {
                rClient.sendSMS("Hello SMS World!", "3519397=
14724", "07860021976", 72, "", "", null)=
;
            } catch (RestClientException e) {
                Console.WriteLine(e.Message);
            }
        }
    }
}
=20
=20
=20
=20
=20
using System;
using RestAPI;
namespace TestRestAPI.Examples {
    class CheckBalance {
        static void Main(string[] args) {
            RestClient rClient =3D new RestClient("MyUser", "=
;MyPass", RestClient.ENV_PRODUCTION);
            try {
                int creditsAvailable =3D rClient.getCredits();
                Console.WriteLine("Account have {0} credits.", cr=
editsAvailable);
            }
            catch (RestClientException e) {
                Console.WriteLine(e.Message);
            }
        }
    }
}
=20
=20
=20
=20
=20
using System;
using RestAPI;
using System.Collections;
namespace TestRestAPI.Examples {
    class DeliveryReports {
        static void Main(string[] args) {
            RestClient rClient =3D new RestClient("MyUser", "=
;MyPass", RestClient.ENV_PRODUCTION);
            try {
                DeliveryReport[] reports =3D rClient.getDeliveryReport(&quo=
t;all");
                foreach (DeliveryReport report in reports) {
                    Console.WriteLine(report);
                    foreach (Hashtable row in report.Rows) {
                        Console.WriteLine("\tMessage ID: {0}", ro=
w["message_id"]);
                        Console.WriteLine("\tLast Updated: {0}", =
row["last_updated"]);
                        Console.WriteLine("\tMobile Number: {0}",=
 row["mobile_number"]);
                        Console.WriteLine("\tStatus: {0}", row[&q=
uot;status"]);
                        Console.WriteLine("\tCustom {0}", row[&qu=
ot;custom"]);
                    }
                }
            }
            catch (RestClientException e) {
                Console.WriteLine(e.Message);
            }
        }
    }
}
=20
=20
=20
=20
=20
using System;
using RestAPI;
namespace TestRestAPI.Examples {
    class CreateAccount {
        static void Main(string[] args) {
            RestClient rClient =3D new RestClient("MyUser", "=
;MyPass", RestClient.ENV_PRODUCTION);
            try {
                rClient.createSubAccount("My client", "44700=
0000000", null, null, null, null, false);
            }
            catch (RestClientException e) {
                Console.WriteLine(e.Message);
            }
        }
    }
}
=20
=20
=20
=20
=20
using System;
using RestAPI;
namespace TestRestAPI.Examples {
    class CreditTransfer {
        static void Main(string[] args) {
            RestClient rClient =3D new RestClient("MyUser", "=
;MyPass", RestClient.ENV_PRODUCTION);
            try {
                rClient.transferCreditsToUser(5000, "targetAPIusername=
", "targetAPIpassword");
            }
            catch (RestClientException e) {
                Console.WriteLine(e.Message);
            }
        }
    }
}
=20
=20
=20
=20 To complete your code you should a= dd some error handing, to catch exceptions. All you need to do is put the w= rapper function calls in a try-catch block as follows.

 

=20
using System;
using RestAPI;
using System.Collections;
namespace TestRestAPI.Examples {
    class ErrorCapture {
        static void Main(string[] args) {
            RestClient rClient =3D new RestClient("MyUser", "=
;MyPass", RestClient.ENV_PRODUCTION);
            try {
                rClient.sendSMS("Hello SMS World!", "3519397=
14724", "07860021976", 72, "", "", null)=
;
                // if the send fails, execution jumps to the start of the c=
atch-block
                int creditsAvailable =3D rClient.getCredits();
                Console.WriteLine("Account have {0} credits.", cr=
editsAvailable);
            }
            catch (RestClientException e) {
                Console.WriteLine(e.Message);
                foreach (DictionaryEntry de in rClient.getLastErrors())
                    Console.WriteLine("Error {0}: {1}", de.Key, d=
e.Value);
            }
        }
    }
}
=09
=20

It is up to you to decide how t= o handle the errors. We also recommend that you log them for debugging purp= oses.

 

=20
=20
=20
=20
=20
=20
=20
=20 =20
=20
=20

 

 

=20
=20
=20
=20

 

=20
=20
=20
=20
=20
=20
=20

You must know!

=20 =20

Our example code is an illustra= tion of how you might integrate with our systems and is not certified for p= roduction environments. You are responsible for testing and QA.

=20
=20
=20
=20
=20
------=_Part_15722_343308441.1614957831379--