1
00:00:00,210 --> 00:00:02,160
-: The next part of the URL

2
00:00:02,160 --> 00:00:06,840
and this is also an optional part, is the sub entity.

3
00:00:06,840 --> 00:00:09,210
Now, what is sub entity?

4
00:00:09,210 --> 00:00:12,840
The sub entity is used for accessing entities

5
00:00:12,840 --> 00:00:16,110
that are dependent on other entities.

6
00:00:16,110 --> 00:00:19,020
And if this sounds a little bit complicated

7
00:00:19,020 --> 00:00:22,620
then I hope the example will help clear things up.

8
00:00:22,620 --> 00:00:27,620
So for example, get all the items of order no. 17.

9
00:00:28,560 --> 00:00:31,740
So in this case, the order is the entity

10
00:00:31,740 --> 00:00:35,670
and the items of the order are the sub entities.

11
00:00:35,670 --> 00:00:38,400
So we will need the URL to specify

12
00:00:38,400 --> 00:00:41,730
that we don't want to retrieve the order itself

13
00:00:41,730 --> 00:00:46,380
but the items of the order and let's see how it's done.

14
00:00:46,380 --> 00:00:49,410
But first let's see how it shouldn't be done.

15
00:00:49,410 --> 00:00:53,688
So a common mistake I see in a lot of organizations

16
00:00:53,688 --> 00:00:56,190
is something like this.

17
00:00:56,190 --> 00:00:57,450
So you see here the APIs

18
00:00:57,450 --> 00:01:01,290
the version and the entity is items in order.

19
00:01:01,290 --> 00:01:03,060
And the number of the order.

20
00:01:03,060 --> 00:01:05,337
This is a mistake and you should not implement

21
00:01:05,337 --> 00:01:06,870
the URL like this.

22
00:01:06,870 --> 00:01:09,840
Why? First it's not very readable.

23
00:01:09,840 --> 00:01:14,250
Notice how long the text part of the URL is.

24
00:01:14,250 --> 00:01:17,070
So you actually need to concentrate to

25
00:01:17,070 --> 00:01:20,370
understand what exactly is going to be retrieved here.

26
00:01:20,370 --> 00:01:22,980
And as a result, this is not simple,

27
00:01:22,980 --> 00:01:27,980
and we always try to make a URL as simple as possible.

28
00:01:27,990 --> 00:01:32,990
So what is the correct way to use the sub entity in the URL?

29
00:01:33,330 --> 00:01:37,470
So the sub entity should come after the ID parameter

30
00:01:37,470 --> 00:01:39,573
and it should look something like this.

31
00:01:40,770 --> 00:01:44,220
So you see here again the API, the version, the entity

32
00:01:44,220 --> 00:01:46,890
the ID parameter, and this is the ID

33
00:01:46,890 --> 00:01:51,780
of the entity and after the ID parameter, the sub entity

34
00:01:51,780 --> 00:01:53,820
the items, in this case.

35
00:01:53,820 --> 00:01:56,640
So when looking at the URL like this

36
00:01:56,640 --> 00:01:59,790
then we see that the URL is hierarchical

37
00:01:59,790 --> 00:02:03,450
and it is very easy to understand we are actually going

38
00:02:03,450 --> 00:02:08,009
from all the entities to a specific entity

39
00:02:08,009 --> 00:02:11,009
to the sub entities of the specific entity.

40
00:02:11,009 --> 00:02:14,160
So what we are having here is a very simple

41
00:02:14,160 --> 00:02:16,533
and very easy to understand URL.

42
00:02:18,090 --> 00:02:22,260
Now, same goes also for sub-sub-entity, etc.

43
00:02:22,260 --> 00:02:24,030
which is not a very common case, but

44
00:02:24,030 --> 00:02:26,940
in theory you can add another ID parameters

45
00:02:26,940 --> 00:02:30,360
after the sub entity and after this ID parameter,

46
00:02:30,360 --> 00:02:33,300
add sub-sub-entity, etc.

47
00:02:33,300 --> 00:02:36,480
Again, not very common, but can be used.

48
00:02:36,480 --> 00:02:38,550
So let's see how the sub entity fits

49
00:02:38,550 --> 00:02:40,503
in the URL that we are building.

50
00:02:41,820 --> 00:02:43,110
Back to our receptor.

51
00:02:43,110 --> 00:02:48,110
All we need to do is add forward slash and items.

52
00:02:50,400 --> 00:02:51,900
So look at what we have here.

53
00:02:51,900 --> 00:02:53,280
We have a GET.

54
00:02:53,280 --> 00:02:56,760
So we understand that this API should return something.

55
00:02:56,760 --> 00:03:00,140
It is retrieving something and what does it retrieve?

56
00:03:00,140 --> 00:03:04,680
It retrieve from the order it goes to order number 17.

57
00:03:04,680 --> 00:03:06,600
And for this specific order

58
00:03:06,600 --> 00:03:09,243
it should return all the items of the order.

