diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 64f3489..66f67d2 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -192,6 +192,15 @@ namespace AyaNova.PlugIn.V8 return Map[id]; } + private enum RavenUserType : int + { + Service = 1, + NotService = 2, + Customer = 3, + HeadOffice = 4, + ServiceContractor = 5 + } + private Dictionary TagMap = new Dictionary(); private Dictionary LocaleMap = new Dictionary(); @@ -727,7 +736,61 @@ namespace AyaNova.PlugIn.V8 //contact created if (!string.IsNullOrWhiteSpace(c.Contact)) { - todo + //create user here + //-------------------------------- + + d = new JObject(); + d.name = GetUniqueName(c.Contact); + + progress.Op("Contact " + d.name); + d.userType=RavenUserType.Customer; + d.customerId=RavenId; + d.active = false;//all imported users are inactive to start + d.roles = 0;//todo: try to determine role from v7 member of group? or is that even possible? + d.login = util.RandomString(); + d.password = util.RandomString(); + + + + var rMainObject = await util.PostAsync("user", d.ToString()); + long RavenContactId = util.IdFromResponse(rMainObject); + + + //USER OPTIONS + /* + [Required] + public long TranslationId { get; set; } + + //------------- + //[EmailAddress] + public string EmailAddress { get; set; } + // [Phone] + public string Phone1 { get; set; } + //[Phone] + public string Phone2 { get; set; } + //in v7 this was pager address so not attributing it with Phone as not sure what would be in that field + public string Phone3 { get; set; } + */ + var rOptions = await util.GetAsync("user-option/" + RavenContactId.ToString()); + d = rOptions.ObjectResponse["data"]; + d.phone1 = c.Phone1; + d.phone2 = c.Phone2; + d.phone3 = c.Phone3; + + d.emailAddress = c.Email; + + + if (LocaleMap.ContainsKey(c.DefaultLanguage)) + d.translationId = LocaleMap[c.DefaultLanguage]; + else + d.translationId = 1; + + await util.PutAsync("user-option/" + RavenContactId.ToString(), d.ToString()); + + + + //---------------------------------- + }