-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
52 lines (45 loc) · 1.39 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using ScgApi;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace add_contact
{
class Program
{
static async Task AddContact(String firstName, String phone, SessionOptions opts)
{
using (var session = new Session(opts))
{
var contactRes = Contact.Resource(session);
String id = await contactRes.Create(new Contact()
{
FirstName = firstName,
PrimaryMdn = phone
});
Console.WriteLine("Added contact {0} with name {1}",
id, firstName, firstName);
}
}
static void Main(string[] args)
{
if (args.Length < 2)
{
Console.WriteLine("Usage: add_contact first-name phone [auth-file] [api-url]");
return;
}
var opts = new SessionOptions();
if (args.Length > 2)
opts.AuthFilePath = args[2];
if (args.Length > 3)
opts.BaseUrl = args[3];
try
{
AddContact(args[0], args[1], opts).Wait();
}
catch (Exception ex)
{
Console.WriteLine("Failed: {0}", ex.ToString());
}
}
}
}