1
+ // ------------------------------------------------------------------------------------------------
2
+ // Copyright (c) Microsoft Corporation. All rights reserved.
3
+ // Licensed under the MIT License. See License.txt in the project root for license information.
4
+ // ------------------------------------------------------------------------------------------------
5
+ namespace Microsoft. EServices. EDocumentConnector. Continia;
6
+ using System. Environment;
7
+
8
+ codeunit 6392 "API URL Mgt."
9
+ {
10
+ Access = Internal ;
11
+ internal procedure NetworkProfilesURL( Network: Enum "Network"; Page : Integer ; PageSize: Integer ) : Text
12
+ var
13
+ ProfilesUrlLbl: Label ' %1/networks/%2/profiles.xml?page=%3&page_size=%4' , Locked = true;
14
+ begin
15
+ exit ( StrSubstNo( ProfilesUrlLbl, CDNBaseURL() , GetNetworkNameAsText( Network) , Page , PageSize)) ;
16
+ end ;
17
+
18
+ internal procedure NetworkIdentifiersURL( Network: Enum "Network"; Page : Integer ; PageSize: Integer ) : Text
19
+ var
20
+ IdentifiersUrlLbl: Label ' %1/networks/%2/id_types.xml?page=%3&page_size=%4' , Locked = true;
21
+ begin
22
+ exit ( StrSubstNo( IdentifiersUrlLbl, CDNBaseURL() , GetNetworkNameAsText( Network) , Page , PageSize)) ;
23
+ end ;
24
+
25
+ internal procedure ParticipationURL( Network: Enum "Network") : Text
26
+ var
27
+ ParticipationUrlLbl: Label ' %1/networks/%2/participations.xml' , Locked = true;
28
+ begin
29
+ exit ( StrSubstNo( ParticipationUrlLbl, CDNBaseURL() , GetNetworkNameAsText( Network)))
30
+ end ;
31
+
32
+ internal procedure SingleParticipationURL( Network: Enum "Network"; ParticipationGUID: Guid ) : Text
33
+ var
34
+ SingleParticipationUrlLbl: Label ' %1/networks/%2/participations/%3.xml' , Locked = true;
35
+ begin
36
+ exit ( StrSubstNo( SingleParticipationUrlLbl, CDNBaseURL() , GetNetworkNameAsText( Network) , GetGUIDAsText( ParticipationGUID)))
37
+ end ;
38
+
39
+ internal procedure ParticipationProfilesURL( Network: Enum "Network"; ParticipationGUID: Guid ) : Text
40
+ var
41
+ ParticipationProfilesUrlLbl: Label ' %1/networks/%2/participations/%3/profiles.xml' , Locked = true;
42
+ begin
43
+ exit ( StrSubstNo( ParticipationProfilesUrlLbl, CDNBaseURL() , GetNetworkNameAsText( Network) , GetGUIDAsText( ParticipationGUID)))
44
+ end ;
45
+
46
+ internal procedure ParticipationProfilesURL( Network: Enum "Network"; ParticipationGUID: Guid ; Page : Integer ; PageSize: Integer ) : Text
47
+ var
48
+ ParticipationProfilesUrlPagesLbl: Label ' %1/networks/%2/participations/%3/profiles.xml?page=%4&page_size=%5' , Locked = true;
49
+ begin
50
+ exit ( StrSubstNo( ParticipationProfilesUrlPagesLbl, CDNBaseURL() , GetNetworkNameAsText( Network) , GetGUIDAsText( ParticipationGUID) , Page , PageSize))
51
+ end ;
52
+
53
+ internal procedure SingleParticipationProfileURL( Network: Enum "Network"; ParticipationGUID: Guid ; ProfileGUID: Guid ) : Text
54
+ var
55
+ SingleParticipationProfileUrlLbl: Label ' %1/networks/%2/participations/%3/profiles/%4.xml' , Locked = true;
56
+ begin
57
+ exit ( StrSubstNo( SingleParticipationProfileUrlLbl, CDNBaseURL() , GetNetworkNameAsText( Network) , GetGUIDAsText( ParticipationGUID) , GetGUIDAsText( ProfileGUID)))
58
+ end ;
59
+
60
+ internal procedure ParticipationLookupURL( Network: Enum "Network"; IdType: Text [4 ]; IdValue: Text [50 ]) : Text
61
+ var
62
+ ParticipationLookupUrlLbl: Label ' %1/networks/%2/participation_lookups.xml?id_type=%3&id_value=%4' , Locked = true;
63
+ begin
64
+ exit ( StrSubstNo( ParticipationLookupUrlLbl, CDNBaseURL() , GetNetworkNameAsText( Network) , IdType, IdValue))
65
+ end ;
66
+
67
+ internal procedure DocumentsForCompanyURL( CompanyGUID: Guid ; Page : Integer ; PageSize: Integer ; Incoming: Boolean ) : Text
68
+ var
69
+ DirectionQueryTxt: Text ;
70
+ DocumentsForCompanyUrlLbl: Label ' %1/documents.xml?business_central_company_code=%2&page=%3&page_size=%4&direction=%5' , Locked = true;
71
+ begin
72
+ if Incoming then
73
+ DirectionQueryTxt := ' IncomingEnum'
74
+ else
75
+ DirectionQueryTxt := ' OutgoingEnum' ;
76
+ exit ( StrSubstNo( DocumentsForCompanyUrlLbl, CDNBaseURL() , GetGUIDAsText( CompanyGUID) , Page , PageSize, DirectionQueryTxt))
77
+ end ;
78
+
79
+ internal procedure DocumentActionUrl( DocumentGUID: Guid ) : Text
80
+ var
81
+ DocumentActionUrlLbl: Label ' %1/documents/%2/action.xml' , Locked = true;
82
+ begin
83
+ exit ( StrSubstNo( DocumentActionUrlLbl, CDNBaseURL() , GetGUIDAsText( DocumentGUID)))
84
+ end ;
85
+
86
+ internal procedure PostDocumentsUrl( CompanyGUID: Guid ) : Text
87
+ var
88
+ PostDocumentsUrlLbl: Label ' %1/documents.xml?business_central_company_code=%2' , Locked = true;
89
+ begin
90
+ exit ( StrSubstNo( PostDocumentsUrlLbl, CDNBaseURL() , GetGUIDAsText( CompanyGUID)))
91
+ end ;
92
+
93
+ internal procedure TechnicalResponseURL( DocumentGUID: Guid ) : Text
94
+ var
95
+ TechnicalResponseUrlLbl: Label ' %1/documents/%2/technical_response.xml' , Locked = true;
96
+ begin
97
+ exit ( StrSubstNo( TechnicalResponseUrlLbl, CDNBaseURL() , GetGUIDAsText( DocumentGUID)))
98
+ end ;
99
+
100
+ internal procedure BusinessResponseURL( DocumentGUID: Guid ) : Text
101
+ var
102
+ BusinessResponseUrlLbl: Label ' %1/documents/%2/business_responses.xml' , Locked = true;
103
+ begin
104
+ exit ( StrSubstNo( BusinessResponseUrlLbl, CDNBaseURL() , GetGUIDAsText( DocumentGUID)))
105
+ end ;
106
+
107
+ internal procedure PartnerAccessTokenUrl() : Text
108
+ var
109
+ PartnerAccessTokenUrlLbl: Label ' %1/partner/PartnerZoneLogin' , Locked = true;
110
+ begin
111
+ exit ( StrSubstNo( PartnerAccessTokenUrlLbl, COBaseUrl())) ;
112
+ end ;
113
+
114
+ internal procedure PartnerZoneUrl() : Text
115
+ var
116
+ PartnerAccessTokenUrlLbl: Label ' %1/partner/PartnerZoneConnect' , Locked = true;
117
+ begin
118
+ exit ( StrSubstNo( PartnerAccessTokenUrlLbl, COBaseUrl())) ;
119
+ end ;
120
+
121
+ internal procedure ClientAccessTokenUrl() : Text
122
+ var
123
+ ClientAccessTokenUrlLbl: Label ' %1/oauth/token/' , Locked = true;
124
+ begin
125
+ exit ( StrSubstNo( ClientAccessTokenUrlLbl, COBaseUrl())) ;
126
+ end ;
127
+
128
+ internal procedure ClientEnvironmentInitializeUrl() : Text
129
+ var
130
+ ClientEnvironmentInitializeUrlLbl: Label ' %1/core/initializeV3' , Locked = true;
131
+ begin
132
+ exit ( StrSubstNo( ClientEnvironmentInitializeUrlLbl, COBaseUrl())) ;
133
+ end ;
134
+
135
+ internal procedure UpdateSubscriptionUrl() : Text
136
+ var
137
+ UpdateSubscriptionUrlLbl: Label ' %1/core/UpdateSubscription' , Locked = true;
138
+ begin
139
+ exit ( StrSubstNo( UpdateSubscriptionUrlLbl, COBaseUrl())) ;
140
+ end ;
141
+
142
+ internal procedure GetSubscriptionUrl() : Text
143
+ var
144
+ GetSubscriptionUrlLbl: Label ' %1/core/GetSubscriptions' , Locked = true;
145
+ begin
146
+ exit ( StrSubstNo( GetSubscriptionUrlLbl, COBaseUrl())) ;
147
+ end ;
148
+
149
+ internal procedure GetAcceptCompanyLicenseUrl() : Text
150
+ var
151
+ GetAcceptCompanyLicenseUrlLbl: Label ' %1/core/AcceptCompanyLicense' , Locked = true;
152
+ begin
153
+ exit ( StrSubstNo( GetAcceptCompanyLicenseUrlLbl, COBaseUrl())) ;
154
+ end ;
155
+
156
+ internal procedure GetUpdateCompanyInfoUrl() : Text
157
+ var
158
+ GetUpdateCompanyInfoUrlLbl: Label ' %1/core/UpdateInvoicingInformation' , Locked = true;
159
+ begin
160
+ exit ( StrSubstNo( GetUpdateCompanyInfoUrlLbl, COBaseUrl())) ;
161
+ end ;
162
+
163
+ local procedure COBaseUrl() URL: Text
164
+ var
165
+ Handled: Boolean ;
166
+ begin
167
+ OnGetCOBaseUrl( URL, Handled) ;
168
+ if Handled then
169
+ exit ( URL) ;
170
+
171
+ exit ( ' https://auth.continiaonline.com/api/v1' ) ;
172
+ end ;
173
+
174
+
175
+ internal procedure CDNBaseURL() URL: Text
176
+ var
177
+ EnvironmentInformation: Codeunit "Environment Information";
178
+ Handled: Boolean ;
179
+ LocalizedBaseUrl: Text ;
180
+ begin
181
+ OnGetCDNBaseUrl( URL, Handled) ;
182
+ if Handled then
183
+ exit ( URL) ;
184
+
185
+ LocalizedBaseUrl := GetBaseUrlForLocalization( EnvironmentInformation. GetApplicationFamily()) ;
186
+ if LocalizedBaseUrl <> ' ' then
187
+ exit ( LocalizedBaseUrl)
188
+ else
189
+ exit ( ' https://cdnapi.continiaonline.com/api/v1.0' ) ;
190
+
191
+ end ;
192
+
193
+ local procedure GetBaseUrlForLocalization( Localization: Text ) : Text
194
+ begin
195
+ OnBeforeGetBaseUrlForLocalization( Localization) ;
196
+
197
+ case Localization of
198
+ ' NZ' , ' AU' :
199
+ exit ( ' https://aue-cdnapi.continiaonline.com/api/v1.0/' ) ;
200
+ ' NL' :
201
+ exit ( ' https://weu-cdnapi.continiaonline.com/api/v1.0/' ) ;
202
+ end ;
203
+ end ;
204
+
205
+ internal procedure GetNetworkNameAsText( NetworkName: Enum "Network") : Text
206
+ begin
207
+ exit ( NetworkName. Names. Get( NetworkName. Ordinals. IndexOf( NetworkName. AsInteger()))) ;
208
+ end ;
209
+
210
+ internal procedure GetGUIDAsText( Value : Guid ) : Text [36 ]
211
+ begin
212
+ exit ( CopyStr( DelChr( Value , ' <>' , ' {}' ) , 1 , 36 ))
213
+ end ;
214
+
215
+
216
+ [IntegrationEvent( false, false) ]
217
+ local procedure OnGetCOBaseUrl( var ReturnUrl: Text ; var Handled: Boolean )
218
+ begin
219
+ end ;
220
+
221
+ [IntegrationEvent( false, false) ]
222
+ local procedure OnGetCDNBaseUrl( var ReturnUrl: Text ; var Handled: Boolean )
223
+ begin
224
+ end ;
225
+
226
+ [IntegrationEvent( false, false) ]
227
+ local procedure OnBeforeGetBaseUrlForLocalization( var Localization: Text )
228
+ begin
229
+ end ;
230
+
231
+ }
0 commit comments