/// <summary> /// 8.4.3. Метод для получения информации о полной иерархии вложенности третичной упаковки /// </summary> /// <param name="sscc">Идентификационный код третичной упаковки</param> /// <returns>Список КИЗ, непосредственно вложенных в указанную третичную упаковку</returns> public SsccFullHierarchyResponse <HierarchySsccInfo> GetSsccFullHierarchy(string sscc) { RequestRate(35); // 100, сказано 30 var result = Get <SsccFullHierarchyResponse <HierarchySsccInfoInternal> >("reestr/sscc/{sscc}/full-hierarchy", new[] { new Parameter("sscc", sscc, ParameterType.UrlSegment), }); // sort child records and convert to real HierarchySsccInfo items return(new SsccFullHierarchyResponse <HierarchySsccInfo> { Up = HierarchySsccInfoInternal.Convert(result.Up), Down = HierarchySsccInfoInternal.Convert(result.Down), }); }
/// <summary> /// 8.4.4. Метод для получения информации о полной иерархии /// вложенности третичной упаковки для нескольких SSCC /// </summary> /// <param name="ssccs">Список идентификационный код третичной упаковки</param> /// <returns>Список КИЗ, непосредственно вложенных в указанную третичную упаковку</returns> public SsccFullHierarchyResponse <HierarchySsccInfo>[] GetSsccFullHierarchy(string[] ssccs) { if (ssccs.IsNullOrEmpty()) { return(new SsccFullHierarchyResponse <HierarchySsccInfo> [0]); } RequestRate(35); // 101, сказано 30 var ssccList = string.Join(",", ssccs); var result = Get <SsccFullHierarchyResponse <HierarchySsccInfoInternal>[]>("reestr/sscc/full-hierarchy", new[] { new Parameter("sscc", ssccList, ParameterType.QueryString), }); // sort child records and convert to real HierarchySsccInfo items return(result.Select(r => new SsccFullHierarchyResponse <HierarchySsccInfo> { Up = HierarchySsccInfoInternal.Convert(r.Up), Down = HierarchySsccInfoInternal.Convert(r.Down), }) .ToArray()); }
public void DeserializeHierarchySsccInfo() { var json = @"{ ""up"": { ""sscc"": ""100000000000000100"", ""packing_date"": ""2020-02-14T15:04:08.059Z"", ""childs"": [{ ""sscc"": ""100000000000000200"", ""packing_date"": ""2020-02-14T15:04:08.059Z"" }] }, ""down"": { ""sscc"": ""100000000000000200"", ""packing_date"": ""2020-02-14T15:04:08.059Z"", ""childs"": [{ ""sscc"": ""100000000000000300"", ""packing_date"": ""2020-02-14T15:04:08.059Z"", ""childs"": [{ ""sgtin"": ""04601907002768TESTTEST00001"", ""sscc"": ""100000000000000300"", ""gtin"": ""04601907002768"", ""status"": ""paused_circulation"", ""expiration_date"": ""2025-02-02T00:00:00Z"", ""series_number"": ""BATCH101"", ""pause_decision_info"": { ""id"": ""9d1bd9c5-07aa-4a0e-b10d-061bb837584a"", ""date"": ""2018-08-21"", ""number"": ""AUTO 1534859443"" } }] }] } }"; Assert.NotNull(json); var sscc = Deserialize <SsccFullHierarchyResponse <HierarchySsccInfoInternal> >(json); Assert.NotNull(sscc); Assert.NotNull(sscc.Up); Assert.NotNull(sscc.Down); var info = sscc.Up; Assert.NotNull(info.Children); Assert.Null(info.ChildSgtins); Assert.Null(info.ChildSsccs); info = sscc.Down; Assert.NotNull(info.Children); Assert.Null(info.ChildSgtins); Assert.Null(info.ChildSsccs); info = info.Children[0]; Assert.NotNull(info.Children); Assert.Null(info.ChildSgtins); Assert.Null(info.ChildSsccs); info = info.Children[0]; Assert.Null(info.Children); Assert.Null(info.ChildSgtins); Assert.Null(info.ChildSsccs); // convert var up = HierarchySsccInfoInternal.Convert(sscc.Up); var down = HierarchySsccInfoInternal.Convert(sscc.Down); Assert.IsNotNull(up); var up0 = up; Assert.NotNull(up0); Assert.AreEqual("100000000000000100", up0.Sscc); Assert.NotNull(up0.ChildSgtins); Assert.AreEqual(0, up0.ChildSgtins.Length); Assert.NotNull(up0.ChildSsccs); Assert.AreEqual(1, up0.ChildSsccs.Length); var up1 = up0.ChildSsccs[0]; Assert.NotNull(up1); Assert.AreEqual("100000000000000200", up1.Sscc); Assert.NotNull(up1.ChildSgtins); Assert.AreEqual(0, up1.ChildSgtins.Length); Assert.NotNull(up1.ChildSsccs); Assert.AreEqual(0, up1.ChildSsccs.Length); Assert.IsNotNull(down); var down0 = down; Assert.NotNull(down0); Assert.AreEqual("100000000000000200", down0.Sscc); Assert.NotNull(down0.ChildSsccs); Assert.NotNull(down0.ChildSgtins); Assert.AreEqual(0, down0.ChildSgtins.Length); Assert.AreEqual(1, down0.ChildSsccs.Length); var down1 = down0.ChildSsccs[0]; Assert.NotNull(down1); Assert.AreEqual("100000000000000300", down1.Sscc); Assert.NotNull(down1.ChildSsccs); Assert.NotNull(down1.ChildSgtins); Assert.AreEqual(1, down1.ChildSgtins.Length); Assert.AreEqual(0, down1.ChildSsccs.Length); var down2 = down1.ChildSgtins[0]; Assert.NotNull(down2); Assert.AreEqual("100000000000000300", down2.Sscc); Assert.AreEqual("04601907002768TESTTEST00001", down2.Sgtin); Assert.AreEqual("04601907002768", down2.Gtin); }