001package com.box.sdkgen.managers.integrationmappings; 002 003import static com.box.sdkgen.internal.utils.UtilsManager.convertToString; 004import static com.box.sdkgen.internal.utils.UtilsManager.entryOf; 005import static com.box.sdkgen.internal.utils.UtilsManager.mapOf; 006import static com.box.sdkgen.internal.utils.UtilsManager.mergeMaps; 007import static com.box.sdkgen.internal.utils.UtilsManager.prepareParams; 008 009import com.box.sdkgen.networking.auth.Authentication; 010import com.box.sdkgen.networking.fetchoptions.FetchOptions; 011import com.box.sdkgen.networking.fetchoptions.ResponseFormat; 012import com.box.sdkgen.networking.fetchresponse.FetchResponse; 013import com.box.sdkgen.networking.network.NetworkSession; 014import com.box.sdkgen.schemas.integrationmapping.IntegrationMapping; 015import com.box.sdkgen.schemas.integrationmappings.IntegrationMappings; 016import com.box.sdkgen.schemas.integrationmappingslackcreaterequest.IntegrationMappingSlackCreateRequest; 017import com.box.sdkgen.schemas.integrationmappingsteams.IntegrationMappingsTeams; 018import com.box.sdkgen.schemas.integrationmappingteams.IntegrationMappingTeams; 019import com.box.sdkgen.schemas.integrationmappingteamscreaterequest.IntegrationMappingTeamsCreateRequest; 020import com.box.sdkgen.serialization.json.JsonManager; 021import java.util.Map; 022 023public class IntegrationMappingsManager { 024 025 public Authentication auth; 026 027 public NetworkSession networkSession; 028 029 public IntegrationMappingsManager() { 030 this.networkSession = new NetworkSession(); 031 } 032 033 protected IntegrationMappingsManager(Builder builder) { 034 this.auth = builder.auth; 035 this.networkSession = builder.networkSession; 036 } 037 038 /** 039 * Lists [Slack integration 040 * mappings](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack) 041 * in a users' enterprise. 042 * 043 * <p>You need Admin or Co-Admin role to use this endpoint. 044 */ 045 public IntegrationMappings getSlackIntegrationMapping() { 046 return getSlackIntegrationMapping( 047 new GetSlackIntegrationMappingQueryParams(), new GetSlackIntegrationMappingHeaders()); 048 } 049 050 /** 051 * Lists [Slack integration 052 * mappings](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack) 053 * in a users' enterprise. 054 * 055 * <p>You need Admin or Co-Admin role to use this endpoint. 056 * 057 * @param queryParams Query parameters of getSlackIntegrationMapping method 058 */ 059 public IntegrationMappings getSlackIntegrationMapping( 060 GetSlackIntegrationMappingQueryParams queryParams) { 061 return getSlackIntegrationMapping(queryParams, new GetSlackIntegrationMappingHeaders()); 062 } 063 064 /** 065 * Lists [Slack integration 066 * mappings](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack) 067 * in a users' enterprise. 068 * 069 * <p>You need Admin or Co-Admin role to use this endpoint. 070 * 071 * @param headers Headers of getSlackIntegrationMapping method 072 */ 073 public IntegrationMappings getSlackIntegrationMapping(GetSlackIntegrationMappingHeaders headers) { 074 return getSlackIntegrationMapping(new GetSlackIntegrationMappingQueryParams(), headers); 075 } 076 077 /** 078 * Lists [Slack integration 079 * mappings](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack) 080 * in a users' enterprise. 081 * 082 * <p>You need Admin or Co-Admin role to use this endpoint. 083 * 084 * @param queryParams Query parameters of getSlackIntegrationMapping method 085 * @param headers Headers of getSlackIntegrationMapping method 086 */ 087 public IntegrationMappings getSlackIntegrationMapping( 088 GetSlackIntegrationMappingQueryParams queryParams, 089 GetSlackIntegrationMappingHeaders headers) { 090 Map<String, String> queryParamsMap = 091 prepareParams( 092 mapOf( 093 entryOf("marker", convertToString(queryParams.getMarker())), 094 entryOf("limit", convertToString(queryParams.getLimit())), 095 entryOf("partner_item_type", convertToString(queryParams.getPartnerItemType())), 096 entryOf("partner_item_id", convertToString(queryParams.getPartnerItemId())), 097 entryOf("box_item_id", convertToString(queryParams.getBoxItemId())), 098 entryOf("box_item_type", convertToString(queryParams.getBoxItemType())), 099 entryOf( 100 "is_manually_created", convertToString(queryParams.getIsManuallyCreated())))); 101 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 102 FetchResponse response = 103 this.networkSession 104 .getNetworkClient() 105 .fetch( 106 new FetchOptions.Builder( 107 String.join( 108 "", 109 this.networkSession.getBaseUrls().getBaseUrl(), 110 "/2.0/integration_mappings/slack"), 111 "GET") 112 .params(queryParamsMap) 113 .headers(headersMap) 114 .responseFormat(ResponseFormat.JSON) 115 .auth(this.auth) 116 .networkSession(this.networkSession) 117 .build()); 118 return JsonManager.deserialize(response.getData(), IntegrationMappings.class); 119 } 120 121 /** 122 * Creates a [Slack integration 123 * mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack) 124 * by mapping a Slack channel to a Box item. 125 * 126 * <p>You need Admin or Co-Admin role to use this endpoint. 127 * 128 * @param requestBody Request body of createSlackIntegrationMapping method 129 */ 130 public IntegrationMapping createSlackIntegrationMapping( 131 IntegrationMappingSlackCreateRequest requestBody) { 132 return createSlackIntegrationMapping(requestBody, new CreateSlackIntegrationMappingHeaders()); 133 } 134 135 /** 136 * Creates a [Slack integration 137 * mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack) 138 * by mapping a Slack channel to a Box item. 139 * 140 * <p>You need Admin or Co-Admin role to use this endpoint. 141 * 142 * @param requestBody Request body of createSlackIntegrationMapping method 143 * @param headers Headers of createSlackIntegrationMapping method 144 */ 145 public IntegrationMapping createSlackIntegrationMapping( 146 IntegrationMappingSlackCreateRequest requestBody, 147 CreateSlackIntegrationMappingHeaders headers) { 148 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 149 FetchResponse response = 150 this.networkSession 151 .getNetworkClient() 152 .fetch( 153 new FetchOptions.Builder( 154 String.join( 155 "", 156 this.networkSession.getBaseUrls().getBaseUrl(), 157 "/2.0/integration_mappings/slack"), 158 "POST") 159 .headers(headersMap) 160 .data(JsonManager.serialize(requestBody)) 161 .contentType("application/json") 162 .responseFormat(ResponseFormat.JSON) 163 .auth(this.auth) 164 .networkSession(this.networkSession) 165 .build()); 166 return JsonManager.deserialize(response.getData(), IntegrationMapping.class); 167 } 168 169 /** 170 * Updates a [Slack integration 171 * mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack). 172 * Supports updating the Box folder ID and options. 173 * 174 * <p>You need Admin or Co-Admin role to use this endpoint. 175 * 176 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 177 */ 178 public IntegrationMapping updateSlackIntegrationMappingById(String integrationMappingId) { 179 return updateSlackIntegrationMappingById( 180 integrationMappingId, 181 new UpdateSlackIntegrationMappingByIdRequestBody(), 182 new UpdateSlackIntegrationMappingByIdHeaders()); 183 } 184 185 /** 186 * Updates a [Slack integration 187 * mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack). 188 * Supports updating the Box folder ID and options. 189 * 190 * <p>You need Admin or Co-Admin role to use this endpoint. 191 * 192 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 193 * @param requestBody Request body of updateSlackIntegrationMappingById method 194 */ 195 public IntegrationMapping updateSlackIntegrationMappingById( 196 String integrationMappingId, UpdateSlackIntegrationMappingByIdRequestBody requestBody) { 197 return updateSlackIntegrationMappingById( 198 integrationMappingId, requestBody, new UpdateSlackIntegrationMappingByIdHeaders()); 199 } 200 201 /** 202 * Updates a [Slack integration 203 * mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack). 204 * Supports updating the Box folder ID and options. 205 * 206 * <p>You need Admin or Co-Admin role to use this endpoint. 207 * 208 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 209 * @param headers Headers of updateSlackIntegrationMappingById method 210 */ 211 public IntegrationMapping updateSlackIntegrationMappingById( 212 String integrationMappingId, UpdateSlackIntegrationMappingByIdHeaders headers) { 213 return updateSlackIntegrationMappingById( 214 integrationMappingId, new UpdateSlackIntegrationMappingByIdRequestBody(), headers); 215 } 216 217 /** 218 * Updates a [Slack integration 219 * mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack). 220 * Supports updating the Box folder ID and options. 221 * 222 * <p>You need Admin or Co-Admin role to use this endpoint. 223 * 224 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 225 * @param requestBody Request body of updateSlackIntegrationMappingById method 226 * @param headers Headers of updateSlackIntegrationMappingById method 227 */ 228 public IntegrationMapping updateSlackIntegrationMappingById( 229 String integrationMappingId, 230 UpdateSlackIntegrationMappingByIdRequestBody requestBody, 231 UpdateSlackIntegrationMappingByIdHeaders headers) { 232 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 233 FetchResponse response = 234 this.networkSession 235 .getNetworkClient() 236 .fetch( 237 new FetchOptions.Builder( 238 String.join( 239 "", 240 this.networkSession.getBaseUrls().getBaseUrl(), 241 "/2.0/integration_mappings/slack/", 242 convertToString(integrationMappingId)), 243 "PUT") 244 .headers(headersMap) 245 .data(JsonManager.serialize(requestBody)) 246 .contentType("application/json") 247 .responseFormat(ResponseFormat.JSON) 248 .auth(this.auth) 249 .networkSession(this.networkSession) 250 .build()); 251 return JsonManager.deserialize(response.getData(), IntegrationMapping.class); 252 } 253 254 /** 255 * Deletes a [Slack integration 256 * mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack). 257 * 258 * <p>You need Admin or Co-Admin role to use this endpoint. 259 * 260 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 261 */ 262 public void deleteSlackIntegrationMappingById(String integrationMappingId) { 263 deleteSlackIntegrationMappingById( 264 integrationMappingId, new DeleteSlackIntegrationMappingByIdHeaders()); 265 } 266 267 /** 268 * Deletes a [Slack integration 269 * mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack). 270 * 271 * <p>You need Admin or Co-Admin role to use this endpoint. 272 * 273 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 274 * @param headers Headers of deleteSlackIntegrationMappingById method 275 */ 276 public void deleteSlackIntegrationMappingById( 277 String integrationMappingId, DeleteSlackIntegrationMappingByIdHeaders headers) { 278 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 279 FetchResponse response = 280 this.networkSession 281 .getNetworkClient() 282 .fetch( 283 new FetchOptions.Builder( 284 String.join( 285 "", 286 this.networkSession.getBaseUrls().getBaseUrl(), 287 "/2.0/integration_mappings/slack/", 288 convertToString(integrationMappingId)), 289 "DELETE") 290 .headers(headersMap) 291 .responseFormat(ResponseFormat.NO_CONTENT) 292 .auth(this.auth) 293 .networkSession(this.networkSession) 294 .build()); 295 } 296 297 /** 298 * Lists [Teams integration 299 * mappings](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams) in a 300 * users' enterprise. You need Admin or Co-Admin role to use this endpoint. 301 */ 302 public IntegrationMappingsTeams getTeamsIntegrationMapping() { 303 return getTeamsIntegrationMapping( 304 new GetTeamsIntegrationMappingQueryParams(), new GetTeamsIntegrationMappingHeaders()); 305 } 306 307 /** 308 * Lists [Teams integration 309 * mappings](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams) in a 310 * users' enterprise. You need Admin or Co-Admin role to use this endpoint. 311 * 312 * @param queryParams Query parameters of getTeamsIntegrationMapping method 313 */ 314 public IntegrationMappingsTeams getTeamsIntegrationMapping( 315 GetTeamsIntegrationMappingQueryParams queryParams) { 316 return getTeamsIntegrationMapping(queryParams, new GetTeamsIntegrationMappingHeaders()); 317 } 318 319 /** 320 * Lists [Teams integration 321 * mappings](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams) in a 322 * users' enterprise. You need Admin or Co-Admin role to use this endpoint. 323 * 324 * @param headers Headers of getTeamsIntegrationMapping method 325 */ 326 public IntegrationMappingsTeams getTeamsIntegrationMapping( 327 GetTeamsIntegrationMappingHeaders headers) { 328 return getTeamsIntegrationMapping(new GetTeamsIntegrationMappingQueryParams(), headers); 329 } 330 331 /** 332 * Lists [Teams integration 333 * mappings](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams) in a 334 * users' enterprise. You need Admin or Co-Admin role to use this endpoint. 335 * 336 * @param queryParams Query parameters of getTeamsIntegrationMapping method 337 * @param headers Headers of getTeamsIntegrationMapping method 338 */ 339 public IntegrationMappingsTeams getTeamsIntegrationMapping( 340 GetTeamsIntegrationMappingQueryParams queryParams, 341 GetTeamsIntegrationMappingHeaders headers) { 342 Map<String, String> queryParamsMap = 343 prepareParams( 344 mapOf( 345 entryOf("partner_item_type", convertToString(queryParams.getPartnerItemType())), 346 entryOf("partner_item_id", convertToString(queryParams.getPartnerItemId())), 347 entryOf("box_item_id", convertToString(queryParams.getBoxItemId())), 348 entryOf("box_item_type", convertToString(queryParams.getBoxItemType())))); 349 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 350 FetchResponse response = 351 this.networkSession 352 .getNetworkClient() 353 .fetch( 354 new FetchOptions.Builder( 355 String.join( 356 "", 357 this.networkSession.getBaseUrls().getBaseUrl(), 358 "/2.0/integration_mappings/teams"), 359 "GET") 360 .params(queryParamsMap) 361 .headers(headersMap) 362 .responseFormat(ResponseFormat.JSON) 363 .auth(this.auth) 364 .networkSession(this.networkSession) 365 .build()); 366 return JsonManager.deserialize(response.getData(), IntegrationMappingsTeams.class); 367 } 368 369 /** 370 * Creates a [Teams integration 371 * mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams) by mapping 372 * a Teams channel to a Box item. You need Admin or Co-Admin role to use this endpoint. 373 * 374 * @param requestBody Request body of createTeamsIntegrationMapping method 375 */ 376 public IntegrationMappingTeams createTeamsIntegrationMapping( 377 IntegrationMappingTeamsCreateRequest requestBody) { 378 return createTeamsIntegrationMapping(requestBody, new CreateTeamsIntegrationMappingHeaders()); 379 } 380 381 /** 382 * Creates a [Teams integration 383 * mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams) by mapping 384 * a Teams channel to a Box item. You need Admin or Co-Admin role to use this endpoint. 385 * 386 * @param requestBody Request body of createTeamsIntegrationMapping method 387 * @param headers Headers of createTeamsIntegrationMapping method 388 */ 389 public IntegrationMappingTeams createTeamsIntegrationMapping( 390 IntegrationMappingTeamsCreateRequest requestBody, 391 CreateTeamsIntegrationMappingHeaders headers) { 392 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 393 FetchResponse response = 394 this.networkSession 395 .getNetworkClient() 396 .fetch( 397 new FetchOptions.Builder( 398 String.join( 399 "", 400 this.networkSession.getBaseUrls().getBaseUrl(), 401 "/2.0/integration_mappings/teams"), 402 "POST") 403 .headers(headersMap) 404 .data(JsonManager.serialize(requestBody)) 405 .contentType("application/json") 406 .responseFormat(ResponseFormat.JSON) 407 .auth(this.auth) 408 .networkSession(this.networkSession) 409 .build()); 410 return JsonManager.deserialize(response.getData(), IntegrationMappingTeams.class); 411 } 412 413 /** 414 * Updates a [Teams integration 415 * mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams). Supports 416 * updating the Box folder ID and options. You need Admin or Co-Admin role to use this endpoint. 417 * 418 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 419 */ 420 public IntegrationMappingTeams updateTeamsIntegrationMappingById(String integrationMappingId) { 421 return updateTeamsIntegrationMappingById( 422 integrationMappingId, 423 new UpdateTeamsIntegrationMappingByIdRequestBody(), 424 new UpdateTeamsIntegrationMappingByIdHeaders()); 425 } 426 427 /** 428 * Updates a [Teams integration 429 * mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams). Supports 430 * updating the Box folder ID and options. You need Admin or Co-Admin role to use this endpoint. 431 * 432 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 433 * @param requestBody Request body of updateTeamsIntegrationMappingById method 434 */ 435 public IntegrationMappingTeams updateTeamsIntegrationMappingById( 436 String integrationMappingId, UpdateTeamsIntegrationMappingByIdRequestBody requestBody) { 437 return updateTeamsIntegrationMappingById( 438 integrationMappingId, requestBody, new UpdateTeamsIntegrationMappingByIdHeaders()); 439 } 440 441 /** 442 * Updates a [Teams integration 443 * mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams). Supports 444 * updating the Box folder ID and options. You need Admin or Co-Admin role to use this endpoint. 445 * 446 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 447 * @param headers Headers of updateTeamsIntegrationMappingById method 448 */ 449 public IntegrationMappingTeams updateTeamsIntegrationMappingById( 450 String integrationMappingId, UpdateTeamsIntegrationMappingByIdHeaders headers) { 451 return updateTeamsIntegrationMappingById( 452 integrationMappingId, new UpdateTeamsIntegrationMappingByIdRequestBody(), headers); 453 } 454 455 /** 456 * Updates a [Teams integration 457 * mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams). Supports 458 * updating the Box folder ID and options. You need Admin or Co-Admin role to use this endpoint. 459 * 460 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 461 * @param requestBody Request body of updateTeamsIntegrationMappingById method 462 * @param headers Headers of updateTeamsIntegrationMappingById method 463 */ 464 public IntegrationMappingTeams updateTeamsIntegrationMappingById( 465 String integrationMappingId, 466 UpdateTeamsIntegrationMappingByIdRequestBody requestBody, 467 UpdateTeamsIntegrationMappingByIdHeaders headers) { 468 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 469 FetchResponse response = 470 this.networkSession 471 .getNetworkClient() 472 .fetch( 473 new FetchOptions.Builder( 474 String.join( 475 "", 476 this.networkSession.getBaseUrls().getBaseUrl(), 477 "/2.0/integration_mappings/teams/", 478 convertToString(integrationMappingId)), 479 "PUT") 480 .headers(headersMap) 481 .data(JsonManager.serialize(requestBody)) 482 .contentType("application/json") 483 .responseFormat(ResponseFormat.JSON) 484 .auth(this.auth) 485 .networkSession(this.networkSession) 486 .build()); 487 return JsonManager.deserialize(response.getData(), IntegrationMappingTeams.class); 488 } 489 490 /** 491 * Deletes a [Teams integration 492 * mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams). You need 493 * Admin or Co-Admin role to use this endpoint. 494 * 495 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 496 */ 497 public void deleteTeamsIntegrationMappingById(String integrationMappingId) { 498 deleteTeamsIntegrationMappingById( 499 integrationMappingId, new DeleteTeamsIntegrationMappingByIdHeaders()); 500 } 501 502 /** 503 * Deletes a [Teams integration 504 * mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams). You need 505 * Admin or Co-Admin role to use this endpoint. 506 * 507 * @param integrationMappingId An ID of an integration mapping. Example: "11235432" 508 * @param headers Headers of deleteTeamsIntegrationMappingById method 509 */ 510 public void deleteTeamsIntegrationMappingById( 511 String integrationMappingId, DeleteTeamsIntegrationMappingByIdHeaders headers) { 512 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 513 FetchResponse response = 514 this.networkSession 515 .getNetworkClient() 516 .fetch( 517 new FetchOptions.Builder( 518 String.join( 519 "", 520 this.networkSession.getBaseUrls().getBaseUrl(), 521 "/2.0/integration_mappings/teams/", 522 convertToString(integrationMappingId)), 523 "DELETE") 524 .headers(headersMap) 525 .responseFormat(ResponseFormat.NO_CONTENT) 526 .auth(this.auth) 527 .networkSession(this.networkSession) 528 .build()); 529 } 530 531 public Authentication getAuth() { 532 return auth; 533 } 534 535 public NetworkSession getNetworkSession() { 536 return networkSession; 537 } 538 539 public static class Builder { 540 541 protected Authentication auth; 542 543 protected NetworkSession networkSession; 544 545 public Builder() {} 546 547 public Builder auth(Authentication auth) { 548 this.auth = auth; 549 return this; 550 } 551 552 public Builder networkSession(NetworkSession networkSession) { 553 this.networkSession = networkSession; 554 return this; 555 } 556 557 public IntegrationMappingsManager build() { 558 if (this.networkSession == null) { 559 this.networkSession = new NetworkSession(); 560 } 561 return new IntegrationMappingsManager(this); 562 } 563 } 564}