Ejemplo n.º 1
0
 public void CrmCustomDataChangeOwnerV2Test()
 {
     var client = new FxiaokeClient();
     var result = client.Execute(new CrmCustomDataChangeOwnerV2Request
     {
         CorpAccessToken   = CorpAccessToken,
         CorpId            = CorpId,
         CurrentOpenUserId = "FSUID_FACEAA83D4F0EE9591CDB911563EECBC",
         Data = new CrmCustomDataChangeOwnerV2Request.CrmCustomDataChangeOwnerV2Data
         {
             DataObjectApiName = "object_0cpq5__c",
             DataList          = new List <CrmCustomDataChangeOwnerV2Request.CrmCustomDataChangeOwnerV2DataData>
             {
                 new CrmCustomDataChangeOwnerV2Request.CrmCustomDataChangeOwnerV2DataData
                 {
                     ObjectDataId = "5dc5316d706c7e0001ea2382",
                     OwnerId      = new List <string>
                     {
                         "FSUID_FACEAA83D4F0EE9591CDB911563EECBC"
                     }
                 }
             }
         }
     });
 }
Ejemplo n.º 2
0
 public void CrmDataChangeOwenrV2Test()
 {
     var client = new FxiaokeClient();
     var result = client.Execute(new CrmDataChangeOwnerV2Request
     {
         CorpAccessToken   = CorpAccessToken,
         CorpId            = CorpId,
         CurrentOpenUserId = "FSUID_FACEAA83D4F0EE9591CDB911563EECBC",
         Data = new CrmDataChangeOwnerV2Request.CrmDataChangeOwnerV2Data
         {
             DataObjectApiName = "LeadsObj",
             Data = new List <CrmDataChangeOwnerV2Request.CrmDataChangeOwnerV2DataData>
             {
                 new CrmDataChangeOwnerV2Request.CrmDataChangeOwnerV2DataData
                 {
                     ObjectDataId = "5dc4cefa038eaa0001c0586f",
                     OwnerId      = new List <string>
                     {
                         "FSUID_FACEAA83D4F0EE9591CDB911563EECBC"
                     }
                 }
             }
         }
     });
 }
Ejemplo n.º 3
0
        public void CrmCustomDataQueryV2Test()
        {
            var client = new FxiaokeClient();
            var result = client.Execute(new CrmCustomDataQueryV2Request
            {
                CorpAccessToken   = CorpAccessToken,
                CorpId            = CorpId,
                CurrentOpenUserId = "FSUID_FACEAA83D4F0EE9591CDB911563EECBC",
                Data = new CrmCustomDataQueryV2Request.CrmCustomDataQueryData
                {
                    DataObjectApiName = "object_ZBcAC__c",
                    Search_query_info = new CrmCustomDataQueryV2Request.CrmCustomDataSearchQueryInfo
                    {
                        Offset  = 0,
                        Limit   = 100,
                        Filters = new List <CrmCustomDataQueryV2Request.CrmCustomDataSearchQueryInfoFilter>
                        {
                        }
                    }
                }
            });
            var a = result.Response.Data.Total;

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 4
0
 public void CrmObjectListV2Test()
 {
     var client = new FxiaokeClient();
     var result = client.Execute(new CrmObjectListV2Request
     {
         CorpAccessToken   = CorpAccessToken,
         CorpId            = CorpId,
         CurrentOpenUserId = "FSUID_0642D2A6D0AC2FEDF2BF0930E9469F98"
     });
 }
Ejemplo n.º 5
0
        public void DepartmentListTest()
        {
            var client = new FxiaokeClient();
            var result = client.Execute(new DepartmentListRequest
            {
                CorpAccessToken = CorpAccessToken,
                CorpId          = CorpId,
            });

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 6
0
        public void MediaDeleteTest()
        {
            var client = new FxiaokeClient();
            var result = client.Execute(new MediaDeleteRequest
            {
                CorpAccessToken = CorpAccessToken,
                CorpId          = CorpId,
                MediaId         = "dd1b088b-f9ae-45ab-b2fd-3965a2a2ce1a",
            });

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 7
0
        public void CrmObjectDescribeTest()
        {
            var client = new FxiaokeClient();
            var result = client.Execute(new CrmObjectDescribeV2Request
            {
                CorpAccessToken   = CorpAccessToken,
                CorpId            = CorpId,
                ApiName           = "PaymentObj",
                CurrentOpenUserId = "FSUID_0642D2A6D0AC2FEDF2BF0930E9469F98"
            });

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 8
0
        public void GetUserTest()
        {
            var client  = new FxiaokeClient();
            var request = new UserGetRequest()
            {
                CorpAccessToken = CorpAccessToken,
                CorpId          = CorpId,
                OpenUserId      = "FSUID_0642D2A6D0AC2FEDF2BF0930E9469F98",
            };
            var json   = JsonConvert.SerializeObject(request);
            var result = client.Execute(request);

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 9
0
 public void CrmDataInvalidV2Test()
 {
     var client = new FxiaokeClient();
     var result = client.Execute(new CrmDataInvalidV2Request
     {
         CorpAccessToken   = CorpAccessToken,
         CorpId            = CorpId,
         CurrentOpenUserId = "FSUID_FACEAA83D4F0EE9591CDB911563EECBC",
         Data = new CrmDataInvalidV2Request.CrmDataInvalidV2Data
         {
             DataObjectApiName = "LeadsObj",
             Object_data_id    = "5dc4cefa038eaa0001c0586f"
         }
     });
 }
Ejemplo n.º 10
0
 public void CrmDateGetV2Test()
 {
     var client   = new FxiaokeClient();
     var response = client.Execute(new CrmDataGetV2Request
     {
         CorpAccessToken   = CorpAccessToken,
         CorpId            = CorpId,
         CurrentOpenUserId = "FSUID_FACEAA83D4F0EE9591CDB911563EECBC",
         Data = new CrmDataGetV2Request.CrmDataGetV2Data
         {
             DataObjectApiName = "LeadsObj",
             ObjectDataId      = "5dc4cefa038eaa0001c0586f"
         }
     });
     var name = response.Response.Data["name"];
 }
Ejemplo n.º 11
0
        public void CrmApprovalTaskActionTest()
        {
            var client  = new FxiaokeClient();
            var request = new CrmApprovalTaskActionRequest
            {
                CurrentOpenUserId = "FSUID_0642D2A6D0AC2FEDF2BF0930E9469F98",
                CorpAccessToken   = CorpAccessToken,
                CorpId            = CorpId,
                TaskId            = "5ba34e35cc9da3a0693d10fb",
                ActionType        = "agree",
                Opinion           = "同意"
            };
            var result = client.Execute(request);

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 12
0
        public void MediaDownloadTest()
        {
            var client = new FxiaokeClient();
            var result = client.Execute(new MediaDownloadRequest
            {
                CorpAccessToken = CorpAccessToken,
                CorpId          = CorpId,
                MediaId         = "07e9312c-253a-4c5c-8915-b7e384ae6534", //07e9312c-253a-4c5c-8915-b7e384ae6534
            });

            byte[] data = new byte[client.Response.ContentLength];
            result.Response.Read(data, 0, data.Count());
            File.Create("F://a.png").Write(data, 0, data.Count());

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 13
0
        public void ExecuteTest()
        {
            var jsonParam = new JObject
            {
                ["corpAccessToken"] = CorpAccessToken,
                ["corpId"]          = CorpId,
            };

            jsonParam["fetchChild"]   = false;
            jsonParam["departmentId"] = 999999;

            var client = new FxiaokeClient();
            var result = client.Execute("/cgi/user/simpleList", jsonParam.ToString());

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 14
0
        public void ChangeSaleStageTest()
        {
            var client = new FxiaokeClient();

            var request = new CrmDataChangeSalesStageRequest
            {
                CorpAccessToken   = CorpAccessToken,
                CorpId            = CorpId,
                ApiName           = "SaleActionObj",
                CurrentOpenUserId = "FSUID_0642D2A6D0AC2FEDF2BF0930E9469F98",
                OpportunityId     = "440a084a95774cc4bb81a6da73bbc647",
                DataId            = "df79c3f84c66455c88cae58ecb8f8464",
                NextSaleStageId   = "9e8bbec5b2284641aeaf5ec42b0ab2ed"
            };

            var reponse = client.Excute(request);
        }
Ejemplo n.º 15
0
        public void MediaUploadTest()
        {
            var contractUrl = "http://imgcache.mysodao.com/img3/M05/C8/1A/CgAPD1vBwy6XH_vBAAICT-xHJwc187-793b94a8.PNG";
            var data        = new HttpClient().GetByteArrayAsync(contractUrl).Result;

            var client = new FxiaokeClient();
            var result = client.Execute(new MediaUploadRequest
            {
                CorpAccessToken = CorpAccessToken,
                CorpId          = CorpId,
                Type            = "image",
                Media           = data,
                ExtName         = "png",
            }).Result;

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 16
0
        public void GetSalesOrderObjTest()
        {
            var client  = new FxiaokeClient();
            var request = new CrmDataQueryV2Request()
            {
                CorpAccessToken   = CorpAccessToken,
                CorpId            = CorpId,
                CurrentOpenUserId = "FSUID_0642D2A6D0AC2FEDF2BF0930E9469F98",
                Data = new CrmDataQueryV2Request.CrmDataQueryData
                {
                    DataObjectApiName = "SalesOrderObj",
                    Search_query_info = new CrmDataQueryV2Request.CrmDataSearchQueryInfo
                    {
                        Offset  = 0,
                        Limit   = 1000,
                        Filters = new List <CrmDataQueryV2Request.CrmDataSearchQueryInfoFilter>
                        {
                            new CrmDataQueryV2Request.CrmDataSearchQueryInfoFilter
                            {
                                Field_name   = "name",
                                Field_values = new List <string> {
                                    "O20180906-0007"
                                },
                                Operator = "EQ"
                            }
                        },
                        Orders = new List <CrmDataQueryV2Request.CrmDataSearchQueryInfoOrder>
                        {
                            new CrmDataQueryV2Request.CrmDataSearchQueryInfoOrder
                            {
                                IsAsc     = false,
                                FieldName = "create_time"
                            }
                        }
                    }
                }
            };
            var  json   = JsonConvert.SerializeObject(request);
            var  result = client.Execute(request);
            long asd    = 0;

            asd = long.Parse(result.Response.Data.DataList[0]["order_time"].ToString());
            var time = new DateTime(asd);

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 17
0
        public void CrmDataUpdateTest()
        {
            var client  = new FxiaokeClient();
            var request = new CrmDataUpdateV2Request()
            {
                CorpAccessToken   = CorpAccessToken,
                CorpId            = CorpId,
                CurrentOpenUserId = "FSUID_0642D2A6D0AC2FEDF2BF0930E9469F98",
                //ApiName = "AccountObj",
                //DataId = "433538f175e94e00ba9ec350bfc65fb6",
                //Data = new { owner = new List<string> { "FSUID_FACEAA83D4F0EE9591CDB911563EECBC" }, owner_department = "技术部" }
            };

            var result = client.Execute(request);

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 18
0
 public void CrmCustomDataUpdateV2Test()
 {
     var client = new FxiaokeClient();
     var result = client.Execute(new CrmCustomDataUpdateV2Request
     {
         CorpAccessToken   = CorpAccessToken,
         CorpId            = CorpId,
         CurrentOpenUserId = "FSUID_FACEAA83D4F0EE9591CDB911563EECBC",
         Data = new CrmCustomDataUpdateV2Request.CrmCustomDataUpdateData
         {
             Object_data = new JObject
             {
                 ["dataObjectApiName"] = "object_0cpq5__c",
                 ["_id"]  = "5dc5316d706c7e0001ea2382",
                 ["name"] = "测试数据勿删"
             }
         }
     });
 }
Ejemplo n.º 19
0
        public void Setup()
        {
            FxiaokeConfig.AppId         = "FSAID_1317cf4";
            FxiaokeConfig.AppSecret     = "7faded1267ba492aa3eafe1aae12e86e";
            FxiaokeConfig.PermanentCode = "4EB0845137A6411E69850DFC5A94BB1E";

            var client  = new FxiaokeClient();
            var result0 = client.Execute(new CorpAccessTokenGetRequest());

            Assert.IsTrue(result0.Success, result0.Message);

            var result1 = client.Execute(new AppAccessTokenGetRequest());

            Assert.IsTrue(result1.Success, result1.Message);

            AppAccessToken  = result1.Response.AppAccessToken;
            CorpAccessToken = result0.Response.CorpAccessToken;
            CorpId          = result0.Response.CorpId;
        }
Ejemplo n.º 20
0
 public void SendMessage()
 {
     var client  = new FxiaokeClient();
     var request = new AppMessageSendRequest
     {
         ServiceId       = "FSAID_bec70df",
         CorpAccessToken = CorpAccessToken,
         CorpId          = CorpId,
         ToUser          = new List <string>()
         {
             "FSUID_DEB7D1E884217C1868AC2128BF6F64FF"
         },
         MsgType = "text",
         Text    = new MessageSendRequest.MessageText
         {
             Content = "测试数据",
         },
     };
     var result = client.Execute(request);
 }
Ejemplo n.º 21
0
 public void CrmDataUpdateV2Test()
 {
     var client   = new FxiaokeClient();
     var response = client.Execute(new CrmDataUpdateV2Request
     {
         CorpAccessToken   = CorpAccessToken,
         CorpId            = CorpId,
         CurrentOpenUserId = "FSUID_FACEAA83D4F0EE9591CDB911563EECBC",
         Data = new CrmDataUpdateV2Request.CrmDataUpdateV2Data
         {
             Object_data = new JObject
             {
                 ["dataObjectApiName"] = "LeadsObj",
                 ["_id"]         = "5dc4cefa038eaa0001c0586f",
                 ["name"]        = "测试数据测试勿删",
                 ["record_type"] = "record_V417w__c"
             }
         }
     });
 }
Ejemplo n.º 22
0
        public void CrmDataQueryV2Test()
        {
            var client = new FxiaokeClient();
            var result = client.Execute(new CrmDataQueryV2Request
            {
                CorpAccessToken   = CorpAccessToken,
                CorpId            = CorpId,
                CurrentOpenUserId = "FSUID_FACEAA83D4F0EE9591CDB911563EECBC",
                Data = new CrmDataQueryV2Request.CrmDataQueryData
                {
                    DataObjectApiName = "LeadsObj",
                    Search_query_info = new CrmDataQueryV2Request.CrmDataSearchQueryInfo
                    {
                        Offset  = 0,
                        Limit   = 100,
                        Filters = new List <CrmDataQueryV2Request.CrmDataSearchQueryInfoFilter>
                        {
                            new CrmDataQueryV2Request.CrmDataSearchQueryInfoFilter
                            {
                                Field_name   = "name",
                                Field_values = new List <string> {
                                    "聚客通官网注册用户"
                                },
                                Operator = "EQ"
                            },
                            new CrmDataQueryV2Request.CrmDataSearchQueryInfoFilter
                            {
                                Field_name   = "company",
                                Field_values = new List <string> {
                                    "富裕"
                                },
                                Operator = "EQ"
                            }
                        }
                    }
                }
            });
            var department = result.Response.Data.DataList[0]["mobile"];

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 23
0
 public void CrmDataCreateV2Test()
 {
     var client = new FxiaokeClient();
     var result = client.Execute(new CrmDataCreateV2Request
     {
         CorpAccessToken   = CorpAccessToken,
         CorpId            = CorpId,
         CurrentOpenUserId = "FSUID_FACEAA83D4F0EE9591CDB911563EECBC",
         Data = new CrmDataCreateV2Request.CrmDataCreateData
         {
             Object_data = new JObject
             {
                 ["dataObjectApiName"] = "LeadsObj",
                 ["name"]          = "测试数据勿删",
                 ["leads_pool_id"] = "7a22188ad3ec408a86526c6850034106",
                 ["mobile"]        = "12346578900",
                 ["source"]        = "11"
             }
         }
     });
 }
Ejemplo n.º 24
0
 public void CrmCustomDataCreateV2Test()
 {
     var client = new FxiaokeClient();
     var result = client.Execute(new CrmCustomDataCreateV2Request
     {
         CorpAccessToken   = CorpAccessToken,
         CorpId            = CorpId,
         CurrentOpenUserId = "FSUID_FACEAA83D4F0EE9591CDB911563EECBC",
         Data = new CrmCustomDataCreateV2Request.CrmCustomDataCreateData
         {
             Object_data = new JObject
             {
                 ["dataObjectApiName"] = "object_0cpq5__c",
                 ["name"]  = "测试",
                 ["owner"] = new JArray()
                 {
                     "FSUID_FACEAA83D4F0EE9591CDB911563EECBC"
                 }
             }
         }
     });
 }
Ejemplo n.º 25
0
        public void MessageSendTest()
        {
            var dt = DateTime.Parse("2018年1月1日");

            var client  = new FxiaokeClient();
            var request = new AppMessageSendRequest
            {
                ServiceId       = "FSAID_bec70df",
                CorpAccessToken = CorpAccessToken,
                CorpId          = CorpId,
                ToUser          = new List <string> {
                    "FSUID_F3CFD1CDE9A5BCBA03D30CD150CDBFD7", "FSUID_0E31705CE1F0CF0D0F85DCE8FABD5D08"
                },
                MsgType = "text",
                Text    = new MessageSendRequest.MessageText
                {
                    Content = "子何 邀请您参加会议 【内部系统需求对接】,会议时间:2018-11-8,请准时参加,会议内容:对接会议室预约系统需求",
                },
            };
            var result = client.Execute(request);

            Assert.IsTrue(result.Success, result.Message);
        }
Ejemplo n.º 26
0
        public static void QueryAccount()
        {
            var relations = File.ReadAllLines("F://客户UID对应关系.csv").Select(x =>
            {
                var arr = x.Split(',');
                return(new { supplierid = arr[0], accountid = arr[1] });
            });
            var categories = File.ReadAllLines("F://客户类目分布.csv", Encoding.Default).Select(x =>
            {
                var arr = x.Split(',');
                return(new { category = arr[0], accountName = arr[1] });
            });

            System.Console.WriteLine(relations.Count());
            System.Console.WriteLine(categories.Count());

            var count      = 0;
            var client     = new FxiaokeClient();
            var accountRel = new List <Tuple <string, string, string> >();

            foreach (var x in categories)
            {
                if (count++ % 100 == 0)
                {
                    Init();
                    System.Console.WriteLine($"已执行{count}/{categories.Count()}个");
                }

                var request = new CrmDataQueryV2Request()
                {
                    CorpAccessToken   = CorpAccessToken,
                    CorpId            = CorpId,
                    CurrentOpenUserId = DefaultOpenUserId,
                    Data = new CrmDataQueryV2Request.CrmDataQueryData
                    {
                        DataObjectApiName = "AccountObj",
                        Search_query_info = new CrmDataQueryV2Request.CrmDataSearchQueryInfo
                        {
                            Offset  = 0,
                            Limit   = 10,
                            Filters = new List <CrmDataQueryV2Request.CrmDataSearchQueryInfoFilter>
                            {
                                new CrmDataQueryV2Request.CrmDataSearchQueryInfoFilter
                                {
                                    Field_name   = "name",
                                    Field_values = new List <string> {
                                        x.accountName
                                    },
                                    Operator = "EQ"
                                },
                                new CrmDataQueryV2Request.CrmDataSearchQueryInfoFilter
                                {
                                    Field_name   = "record_type",
                                    Field_values = new List <string> {
                                        "record_type"
                                    },
                                    Operator = "EQ"
                                }
                            }
                        }
                    }
                };
                var result = client.Execute(request);
                if (!result.Success)
                {
                    System.Console.WriteLine(x.accountName + "|" + result.Message);
                    File.AppendAllText("F://账号ID对应关系.csv", $"{x.category},{x.accountName},{result.Message}\r\n");
                    accountRel.Add(Tuple.Create(x.category, x.accountName, result.Message));
                }
                File.AppendAllText("F://账号ID对应关系.csv", $"{x.category},{x.accountName},{result.Response?.Data?.DataList?.FirstOrDefault()?["_id"]?.ToString()}\r\n");
                accountRel.Add(Tuple.Create(x.category, x.accountName, result.Response?.Data?.DataList?.FirstOrDefault()?["_id"]?.ToString()));
            }

            File.WriteAllLines("F://账号ID对应关系-copy.csv", accountRel.Select(x => $"{x.Item1},{x.Item2},{x.Item3}"));

            System.Console.WriteLine(accountRel.Count());
            var newxls = new List <string>();

            foreach (var item in accountRel)
            {
                newxls.Add($"{item.Item1},{item.Item2},{relations.FirstOrDefault(x => x.accountid == item.Item3)?.supplierid}");
            }

            File.WriteAllLines("F://类目商家ID统计.csv", newxls);
        }