/modules/apps/commerce/headless/headless-commerce/headless-commerce-admin-account-client/src/main/java/com/liferay/headless/commerce/admin/account/client/resource/v1_0/AccountAddressResource.java

https://github.com/danielreuther/liferay-portal · Java · 1381 lines · 1038 code · 326 blank · 17 comment · 111 complexity · df74e7c85fd339a319a473fd45fa3098 MD5 · raw file

  1. /**
  2. * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 2.1 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  12. * details.
  13. */
  14. package com.liferay.headless.commerce.admin.account.client.resource.v1_0;
  15. import com.liferay.headless.commerce.admin.account.client.dto.v1_0.AccountAddress;
  16. import com.liferay.headless.commerce.admin.account.client.http.HttpInvoker;
  17. import com.liferay.headless.commerce.admin.account.client.pagination.Page;
  18. import com.liferay.headless.commerce.admin.account.client.pagination.Pagination;
  19. import com.liferay.headless.commerce.admin.account.client.problem.Problem;
  20. import com.liferay.headless.commerce.admin.account.client.serdes.v1_0.AccountAddressSerDes;
  21. import java.util.LinkedHashMap;
  22. import java.util.Locale;
  23. import java.util.Map;
  24. import java.util.logging.Level;
  25. import java.util.logging.Logger;
  26. import javax.annotation.Generated;
  27. /**
  28. * @author Alessio Antonio Rendina
  29. * @generated
  30. */
  31. @Generated("")
  32. public interface AccountAddressResource {
  33. public static Builder builder() {
  34. return new Builder();
  35. }
  36. public void deleteAccountAddressByExternalReferenceCode(
  37. String externalReferenceCode)
  38. throws Exception;
  39. public HttpInvoker.HttpResponse
  40. deleteAccountAddressByExternalReferenceCodeHttpResponse(
  41. String externalReferenceCode)
  42. throws Exception;
  43. public AccountAddress getAccountAddressByExternalReferenceCode(
  44. String externalReferenceCode)
  45. throws Exception;
  46. public HttpInvoker.HttpResponse
  47. getAccountAddressByExternalReferenceCodeHttpResponse(
  48. String externalReferenceCode)
  49. throws Exception;
  50. public void patchAccountAddressByExternalReferenceCode(
  51. String externalReferenceCode, AccountAddress accountAddress)
  52. throws Exception;
  53. public HttpInvoker.HttpResponse
  54. patchAccountAddressByExternalReferenceCodeHttpResponse(
  55. String externalReferenceCode, AccountAddress accountAddress)
  56. throws Exception;
  57. public void deleteAccountAddress(Long id) throws Exception;
  58. public HttpInvoker.HttpResponse deleteAccountAddressHttpResponse(Long id)
  59. throws Exception;
  60. public void deleteAccountAddressBatch(
  61. Long id, String callbackURL, Object object)
  62. throws Exception;
  63. public HttpInvoker.HttpResponse deleteAccountAddressBatchHttpResponse(
  64. Long id, String callbackURL, Object object)
  65. throws Exception;
  66. public AccountAddress getAccountAddress(Long id) throws Exception;
  67. public HttpInvoker.HttpResponse getAccountAddressHttpResponse(Long id)
  68. throws Exception;
  69. public AccountAddress patchAccountAddress(
  70. Long id, AccountAddress accountAddress)
  71. throws Exception;
  72. public HttpInvoker.HttpResponse patchAccountAddressHttpResponse(
  73. Long id, AccountAddress accountAddress)
  74. throws Exception;
  75. public AccountAddress putAccountAddress(
  76. Long id, AccountAddress accountAddress)
  77. throws Exception;
  78. public HttpInvoker.HttpResponse putAccountAddressHttpResponse(
  79. Long id, AccountAddress accountAddress)
  80. throws Exception;
  81. public void putAccountAddressBatch(
  82. Long id, String callbackURL, Object object)
  83. throws Exception;
  84. public HttpInvoker.HttpResponse putAccountAddressBatchHttpResponse(
  85. Long id, String callbackURL, Object object)
  86. throws Exception;
  87. public Page<AccountAddress>
  88. getAccountByExternalReferenceCodeAccountAddressesPage(
  89. String externalReferenceCode, Pagination pagination)
  90. throws Exception;
  91. public HttpInvoker.HttpResponse
  92. getAccountByExternalReferenceCodeAccountAddressesPageHttpResponse(
  93. String externalReferenceCode, Pagination pagination)
  94. throws Exception;
  95. public AccountAddress postAccountByExternalReferenceCodeAccountAddress(
  96. String externalReferenceCode, AccountAddress accountAddress)
  97. throws Exception;
  98. public HttpInvoker.HttpResponse
  99. postAccountByExternalReferenceCodeAccountAddressHttpResponse(
  100. String externalReferenceCode, AccountAddress accountAddress)
  101. throws Exception;
  102. public Page<AccountAddress> getAccountIdAccountAddressesPage(
  103. Long id, Pagination pagination)
  104. throws Exception;
  105. public HttpInvoker.HttpResponse
  106. getAccountIdAccountAddressesPageHttpResponse(
  107. Long id, Pagination pagination)
  108. throws Exception;
  109. public AccountAddress postAccountIdAccountAddress(
  110. Long id, AccountAddress accountAddress)
  111. throws Exception;
  112. public HttpInvoker.HttpResponse postAccountIdAccountAddressHttpResponse(
  113. Long id, AccountAddress accountAddress)
  114. throws Exception;
  115. public void postAccountIdAccountAddressBatch(
  116. Long id, String callbackURL, Object object)
  117. throws Exception;
  118. public HttpInvoker.HttpResponse
  119. postAccountIdAccountAddressBatchHttpResponse(
  120. Long id, String callbackURL, Object object)
  121. throws Exception;
  122. public static class Builder {
  123. public Builder authentication(String login, String password) {
  124. _login = login;
  125. _password = password;
  126. return this;
  127. }
  128. public AccountAddressResource build() {
  129. return new AccountAddressResourceImpl(this);
  130. }
  131. public Builder contextPath(String contextPath) {
  132. _contextPath = contextPath;
  133. return this;
  134. }
  135. public Builder endpoint(String host, int port, String scheme) {
  136. _host = host;
  137. _port = port;
  138. _scheme = scheme;
  139. return this;
  140. }
  141. public Builder header(String key, String value) {
  142. _headers.put(key, value);
  143. return this;
  144. }
  145. public Builder locale(Locale locale) {
  146. _locale = locale;
  147. return this;
  148. }
  149. public Builder parameter(String key, String value) {
  150. _parameters.put(key, value);
  151. return this;
  152. }
  153. public Builder parameters(String... parameters) {
  154. if ((parameters.length % 2) != 0) {
  155. throw new IllegalArgumentException(
  156. "Parameters length is not an even number");
  157. }
  158. for (int i = 0; i < parameters.length; i += 2) {
  159. String parameterName = String.valueOf(parameters[i]);
  160. String parameterValue = String.valueOf(parameters[i + 1]);
  161. _parameters.put(parameterName, parameterValue);
  162. }
  163. return this;
  164. }
  165. private Builder() {
  166. }
  167. private String _contextPath = "";
  168. private Map<String, String> _headers = new LinkedHashMap<>();
  169. private String _host = "localhost";
  170. private Locale _locale;
  171. private String _login = "";
  172. private String _password = "";
  173. private Map<String, String> _parameters = new LinkedHashMap<>();
  174. private int _port = 8080;
  175. private String _scheme = "http";
  176. }
  177. public static class AccountAddressResourceImpl
  178. implements AccountAddressResource {
  179. public void deleteAccountAddressByExternalReferenceCode(
  180. String externalReferenceCode)
  181. throws Exception {
  182. HttpInvoker.HttpResponse httpResponse =
  183. deleteAccountAddressByExternalReferenceCodeHttpResponse(
  184. externalReferenceCode);
  185. String content = httpResponse.getContent();
  186. if ((httpResponse.getStatusCode() / 100) != 2) {
  187. _logger.log(
  188. Level.WARNING,
  189. "Unable to process HTTP response content: " + content);
  190. _logger.log(
  191. Level.WARNING,
  192. "HTTP response message: " + httpResponse.getMessage());
  193. _logger.log(
  194. Level.WARNING,
  195. "HTTP response status code: " +
  196. httpResponse.getStatusCode());
  197. throw new Problem.ProblemException(Problem.toDTO(content));
  198. }
  199. else {
  200. _logger.fine("HTTP response content: " + content);
  201. _logger.fine(
  202. "HTTP response message: " + httpResponse.getMessage());
  203. _logger.fine(
  204. "HTTP response status code: " +
  205. httpResponse.getStatusCode());
  206. }
  207. }
  208. public HttpInvoker.HttpResponse
  209. deleteAccountAddressByExternalReferenceCodeHttpResponse(
  210. String externalReferenceCode)
  211. throws Exception {
  212. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  213. if (_builder._locale != null) {
  214. httpInvoker.header(
  215. "Accept-Language", _builder._locale.toLanguageTag());
  216. }
  217. for (Map.Entry<String, String> entry :
  218. _builder._headers.entrySet()) {
  219. httpInvoker.header(entry.getKey(), entry.getValue());
  220. }
  221. for (Map.Entry<String, String> entry :
  222. _builder._parameters.entrySet()) {
  223. httpInvoker.parameter(entry.getKey(), entry.getValue());
  224. }
  225. httpInvoker.httpMethod(HttpInvoker.HttpMethod.DELETE);
  226. httpInvoker.path(
  227. _builder._scheme + "://" + _builder._host + ":" +
  228. _builder._port + _builder._contextPath +
  229. "/o/headless-commerce-admin-account/v1.0/accountAddresses/by-externalReferenceCode/{externalReferenceCode}");
  230. httpInvoker.path("externalReferenceCode", externalReferenceCode);
  231. httpInvoker.userNameAndPassword(
  232. _builder._login + ":" + _builder._password);
  233. return httpInvoker.invoke();
  234. }
  235. public AccountAddress getAccountAddressByExternalReferenceCode(
  236. String externalReferenceCode)
  237. throws Exception {
  238. HttpInvoker.HttpResponse httpResponse =
  239. getAccountAddressByExternalReferenceCodeHttpResponse(
  240. externalReferenceCode);
  241. String content = httpResponse.getContent();
  242. if ((httpResponse.getStatusCode() / 100) != 2) {
  243. _logger.log(
  244. Level.WARNING,
  245. "Unable to process HTTP response content: " + content);
  246. _logger.log(
  247. Level.WARNING,
  248. "HTTP response message: " + httpResponse.getMessage());
  249. _logger.log(
  250. Level.WARNING,
  251. "HTTP response status code: " +
  252. httpResponse.getStatusCode());
  253. throw new Problem.ProblemException(Problem.toDTO(content));
  254. }
  255. else {
  256. _logger.fine("HTTP response content: " + content);
  257. _logger.fine(
  258. "HTTP response message: " + httpResponse.getMessage());
  259. _logger.fine(
  260. "HTTP response status code: " +
  261. httpResponse.getStatusCode());
  262. }
  263. try {
  264. return AccountAddressSerDes.toDTO(content);
  265. }
  266. catch (Exception e) {
  267. _logger.log(
  268. Level.WARNING,
  269. "Unable to process HTTP response: " + content, e);
  270. throw new Problem.ProblemException(Problem.toDTO(content));
  271. }
  272. }
  273. public HttpInvoker.HttpResponse
  274. getAccountAddressByExternalReferenceCodeHttpResponse(
  275. String externalReferenceCode)
  276. throws Exception {
  277. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  278. if (_builder._locale != null) {
  279. httpInvoker.header(
  280. "Accept-Language", _builder._locale.toLanguageTag());
  281. }
  282. for (Map.Entry<String, String> entry :
  283. _builder._headers.entrySet()) {
  284. httpInvoker.header(entry.getKey(), entry.getValue());
  285. }
  286. for (Map.Entry<String, String> entry :
  287. _builder._parameters.entrySet()) {
  288. httpInvoker.parameter(entry.getKey(), entry.getValue());
  289. }
  290. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  291. httpInvoker.path(
  292. _builder._scheme + "://" + _builder._host + ":" +
  293. _builder._port + _builder._contextPath +
  294. "/o/headless-commerce-admin-account/v1.0/accountAddresses/by-externalReferenceCode/{externalReferenceCode}");
  295. httpInvoker.path("externalReferenceCode", externalReferenceCode);
  296. httpInvoker.userNameAndPassword(
  297. _builder._login + ":" + _builder._password);
  298. return httpInvoker.invoke();
  299. }
  300. public void patchAccountAddressByExternalReferenceCode(
  301. String externalReferenceCode, AccountAddress accountAddress)
  302. throws Exception {
  303. HttpInvoker.HttpResponse httpResponse =
  304. patchAccountAddressByExternalReferenceCodeHttpResponse(
  305. externalReferenceCode, accountAddress);
  306. String content = httpResponse.getContent();
  307. if ((httpResponse.getStatusCode() / 100) != 2) {
  308. _logger.log(
  309. Level.WARNING,
  310. "Unable to process HTTP response content: " + content);
  311. _logger.log(
  312. Level.WARNING,
  313. "HTTP response message: " + httpResponse.getMessage());
  314. _logger.log(
  315. Level.WARNING,
  316. "HTTP response status code: " +
  317. httpResponse.getStatusCode());
  318. throw new Problem.ProblemException(Problem.toDTO(content));
  319. }
  320. else {
  321. _logger.fine("HTTP response content: " + content);
  322. _logger.fine(
  323. "HTTP response message: " + httpResponse.getMessage());
  324. _logger.fine(
  325. "HTTP response status code: " +
  326. httpResponse.getStatusCode());
  327. }
  328. }
  329. public HttpInvoker.HttpResponse
  330. patchAccountAddressByExternalReferenceCodeHttpResponse(
  331. String externalReferenceCode, AccountAddress accountAddress)
  332. throws Exception {
  333. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  334. httpInvoker.body(accountAddress.toString(), "application/json");
  335. if (_builder._locale != null) {
  336. httpInvoker.header(
  337. "Accept-Language", _builder._locale.toLanguageTag());
  338. }
  339. for (Map.Entry<String, String> entry :
  340. _builder._headers.entrySet()) {
  341. httpInvoker.header(entry.getKey(), entry.getValue());
  342. }
  343. for (Map.Entry<String, String> entry :
  344. _builder._parameters.entrySet()) {
  345. httpInvoker.parameter(entry.getKey(), entry.getValue());
  346. }
  347. httpInvoker.httpMethod(HttpInvoker.HttpMethod.PATCH);
  348. httpInvoker.path(
  349. _builder._scheme + "://" + _builder._host + ":" +
  350. _builder._port + _builder._contextPath +
  351. "/o/headless-commerce-admin-account/v1.0/accountAddresses/by-externalReferenceCode/{externalReferenceCode}");
  352. httpInvoker.path("externalReferenceCode", externalReferenceCode);
  353. httpInvoker.userNameAndPassword(
  354. _builder._login + ":" + _builder._password);
  355. return httpInvoker.invoke();
  356. }
  357. public void deleteAccountAddress(Long id) throws Exception {
  358. HttpInvoker.HttpResponse httpResponse =
  359. deleteAccountAddressHttpResponse(id);
  360. String content = httpResponse.getContent();
  361. if ((httpResponse.getStatusCode() / 100) != 2) {
  362. _logger.log(
  363. Level.WARNING,
  364. "Unable to process HTTP response content: " + content);
  365. _logger.log(
  366. Level.WARNING,
  367. "HTTP response message: " + httpResponse.getMessage());
  368. _logger.log(
  369. Level.WARNING,
  370. "HTTP response status code: " +
  371. httpResponse.getStatusCode());
  372. throw new Problem.ProblemException(Problem.toDTO(content));
  373. }
  374. else {
  375. _logger.fine("HTTP response content: " + content);
  376. _logger.fine(
  377. "HTTP response message: " + httpResponse.getMessage());
  378. _logger.fine(
  379. "HTTP response status code: " +
  380. httpResponse.getStatusCode());
  381. }
  382. }
  383. public HttpInvoker.HttpResponse deleteAccountAddressHttpResponse(
  384. Long id)
  385. throws Exception {
  386. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  387. if (_builder._locale != null) {
  388. httpInvoker.header(
  389. "Accept-Language", _builder._locale.toLanguageTag());
  390. }
  391. for (Map.Entry<String, String> entry :
  392. _builder._headers.entrySet()) {
  393. httpInvoker.header(entry.getKey(), entry.getValue());
  394. }
  395. for (Map.Entry<String, String> entry :
  396. _builder._parameters.entrySet()) {
  397. httpInvoker.parameter(entry.getKey(), entry.getValue());
  398. }
  399. httpInvoker.httpMethod(HttpInvoker.HttpMethod.DELETE);
  400. httpInvoker.path(
  401. _builder._scheme + "://" + _builder._host + ":" +
  402. _builder._port + _builder._contextPath +
  403. "/o/headless-commerce-admin-account/v1.0/accountAddresses/{id}");
  404. httpInvoker.path("id", id);
  405. httpInvoker.userNameAndPassword(
  406. _builder._login + ":" + _builder._password);
  407. return httpInvoker.invoke();
  408. }
  409. public void deleteAccountAddressBatch(
  410. Long id, String callbackURL, Object object)
  411. throws Exception {
  412. HttpInvoker.HttpResponse httpResponse =
  413. deleteAccountAddressBatchHttpResponse(id, callbackURL, object);
  414. String content = httpResponse.getContent();
  415. if ((httpResponse.getStatusCode() / 100) != 2) {
  416. _logger.log(
  417. Level.WARNING,
  418. "Unable to process HTTP response content: " + content);
  419. _logger.log(
  420. Level.WARNING,
  421. "HTTP response message: " + httpResponse.getMessage());
  422. _logger.log(
  423. Level.WARNING,
  424. "HTTP response status code: " +
  425. httpResponse.getStatusCode());
  426. throw new Problem.ProblemException(Problem.toDTO(content));
  427. }
  428. else {
  429. _logger.fine("HTTP response content: " + content);
  430. _logger.fine(
  431. "HTTP response message: " + httpResponse.getMessage());
  432. _logger.fine(
  433. "HTTP response status code: " +
  434. httpResponse.getStatusCode());
  435. }
  436. }
  437. public HttpInvoker.HttpResponse deleteAccountAddressBatchHttpResponse(
  438. Long id, String callbackURL, Object object)
  439. throws Exception {
  440. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  441. httpInvoker.body(object.toString(), "application/json");
  442. if (_builder._locale != null) {
  443. httpInvoker.header(
  444. "Accept-Language", _builder._locale.toLanguageTag());
  445. }
  446. for (Map.Entry<String, String> entry :
  447. _builder._headers.entrySet()) {
  448. httpInvoker.header(entry.getKey(), entry.getValue());
  449. }
  450. for (Map.Entry<String, String> entry :
  451. _builder._parameters.entrySet()) {
  452. httpInvoker.parameter(entry.getKey(), entry.getValue());
  453. }
  454. httpInvoker.httpMethod(HttpInvoker.HttpMethod.DELETE);
  455. if (callbackURL != null) {
  456. httpInvoker.parameter(
  457. "callbackURL", String.valueOf(callbackURL));
  458. }
  459. httpInvoker.path(
  460. _builder._scheme + "://" + _builder._host + ":" +
  461. _builder._port + _builder._contextPath +
  462. "/o/headless-commerce-admin-account/v1.0/accountAddresses/batch");
  463. httpInvoker.path("id", id);
  464. httpInvoker.userNameAndPassword(
  465. _builder._login + ":" + _builder._password);
  466. return httpInvoker.invoke();
  467. }
  468. public AccountAddress getAccountAddress(Long id) throws Exception {
  469. HttpInvoker.HttpResponse httpResponse =
  470. getAccountAddressHttpResponse(id);
  471. String content = httpResponse.getContent();
  472. if ((httpResponse.getStatusCode() / 100) != 2) {
  473. _logger.log(
  474. Level.WARNING,
  475. "Unable to process HTTP response content: " + content);
  476. _logger.log(
  477. Level.WARNING,
  478. "HTTP response message: " + httpResponse.getMessage());
  479. _logger.log(
  480. Level.WARNING,
  481. "HTTP response status code: " +
  482. httpResponse.getStatusCode());
  483. throw new Problem.ProblemException(Problem.toDTO(content));
  484. }
  485. else {
  486. _logger.fine("HTTP response content: " + content);
  487. _logger.fine(
  488. "HTTP response message: " + httpResponse.getMessage());
  489. _logger.fine(
  490. "HTTP response status code: " +
  491. httpResponse.getStatusCode());
  492. }
  493. try {
  494. return AccountAddressSerDes.toDTO(content);
  495. }
  496. catch (Exception e) {
  497. _logger.log(
  498. Level.WARNING,
  499. "Unable to process HTTP response: " + content, e);
  500. throw new Problem.ProblemException(Problem.toDTO(content));
  501. }
  502. }
  503. public HttpInvoker.HttpResponse getAccountAddressHttpResponse(Long id)
  504. throws Exception {
  505. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  506. if (_builder._locale != null) {
  507. httpInvoker.header(
  508. "Accept-Language", _builder._locale.toLanguageTag());
  509. }
  510. for (Map.Entry<String, String> entry :
  511. _builder._headers.entrySet()) {
  512. httpInvoker.header(entry.getKey(), entry.getValue());
  513. }
  514. for (Map.Entry<String, String> entry :
  515. _builder._parameters.entrySet()) {
  516. httpInvoker.parameter(entry.getKey(), entry.getValue());
  517. }
  518. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  519. httpInvoker.path(
  520. _builder._scheme + "://" + _builder._host + ":" +
  521. _builder._port + _builder._contextPath +
  522. "/o/headless-commerce-admin-account/v1.0/accountAddresses/{id}");
  523. httpInvoker.path("id", id);
  524. httpInvoker.userNameAndPassword(
  525. _builder._login + ":" + _builder._password);
  526. return httpInvoker.invoke();
  527. }
  528. public AccountAddress patchAccountAddress(
  529. Long id, AccountAddress accountAddress)
  530. throws Exception {
  531. HttpInvoker.HttpResponse httpResponse =
  532. patchAccountAddressHttpResponse(id, accountAddress);
  533. String content = httpResponse.getContent();
  534. if ((httpResponse.getStatusCode() / 100) != 2) {
  535. _logger.log(
  536. Level.WARNING,
  537. "Unable to process HTTP response content: " + content);
  538. _logger.log(
  539. Level.WARNING,
  540. "HTTP response message: " + httpResponse.getMessage());
  541. _logger.log(
  542. Level.WARNING,
  543. "HTTP response status code: " +
  544. httpResponse.getStatusCode());
  545. throw new Problem.ProblemException(Problem.toDTO(content));
  546. }
  547. else {
  548. _logger.fine("HTTP response content: " + content);
  549. _logger.fine(
  550. "HTTP response message: " + httpResponse.getMessage());
  551. _logger.fine(
  552. "HTTP response status code: " +
  553. httpResponse.getStatusCode());
  554. }
  555. try {
  556. return AccountAddressSerDes.toDTO(content);
  557. }
  558. catch (Exception e) {
  559. _logger.log(
  560. Level.WARNING,
  561. "Unable to process HTTP response: " + content, e);
  562. throw new Problem.ProblemException(Problem.toDTO(content));
  563. }
  564. }
  565. public HttpInvoker.HttpResponse patchAccountAddressHttpResponse(
  566. Long id, AccountAddress accountAddress)
  567. throws Exception {
  568. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  569. httpInvoker.body(accountAddress.toString(), "application/json");
  570. if (_builder._locale != null) {
  571. httpInvoker.header(
  572. "Accept-Language", _builder._locale.toLanguageTag());
  573. }
  574. for (Map.Entry<String, String> entry :
  575. _builder._headers.entrySet()) {
  576. httpInvoker.header(entry.getKey(), entry.getValue());
  577. }
  578. for (Map.Entry<String, String> entry :
  579. _builder._parameters.entrySet()) {
  580. httpInvoker.parameter(entry.getKey(), entry.getValue());
  581. }
  582. httpInvoker.httpMethod(HttpInvoker.HttpMethod.PATCH);
  583. httpInvoker.path(
  584. _builder._scheme + "://" + _builder._host + ":" +
  585. _builder._port + _builder._contextPath +
  586. "/o/headless-commerce-admin-account/v1.0/accountAddresses/{id}");
  587. httpInvoker.path("id", id);
  588. httpInvoker.userNameAndPassword(
  589. _builder._login + ":" + _builder._password);
  590. return httpInvoker.invoke();
  591. }
  592. public AccountAddress putAccountAddress(
  593. Long id, AccountAddress accountAddress)
  594. throws Exception {
  595. HttpInvoker.HttpResponse httpResponse =
  596. putAccountAddressHttpResponse(id, accountAddress);
  597. String content = httpResponse.getContent();
  598. if ((httpResponse.getStatusCode() / 100) != 2) {
  599. _logger.log(
  600. Level.WARNING,
  601. "Unable to process HTTP response content: " + content);
  602. _logger.log(
  603. Level.WARNING,
  604. "HTTP response message: " + httpResponse.getMessage());
  605. _logger.log(
  606. Level.WARNING,
  607. "HTTP response status code: " +
  608. httpResponse.getStatusCode());
  609. throw new Problem.ProblemException(Problem.toDTO(content));
  610. }
  611. else {
  612. _logger.fine("HTTP response content: " + content);
  613. _logger.fine(
  614. "HTTP response message: " + httpResponse.getMessage());
  615. _logger.fine(
  616. "HTTP response status code: " +
  617. httpResponse.getStatusCode());
  618. }
  619. try {
  620. return AccountAddressSerDes.toDTO(content);
  621. }
  622. catch (Exception e) {
  623. _logger.log(
  624. Level.WARNING,
  625. "Unable to process HTTP response: " + content, e);
  626. throw new Problem.ProblemException(Problem.toDTO(content));
  627. }
  628. }
  629. public HttpInvoker.HttpResponse putAccountAddressHttpResponse(
  630. Long id, AccountAddress accountAddress)
  631. throws Exception {
  632. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  633. httpInvoker.body(accountAddress.toString(), "application/json");
  634. if (_builder._locale != null) {
  635. httpInvoker.header(
  636. "Accept-Language", _builder._locale.toLanguageTag());
  637. }
  638. for (Map.Entry<String, String> entry :
  639. _builder._headers.entrySet()) {
  640. httpInvoker.header(entry.getKey(), entry.getValue());
  641. }
  642. for (Map.Entry<String, String> entry :
  643. _builder._parameters.entrySet()) {
  644. httpInvoker.parameter(entry.getKey(), entry.getValue());
  645. }
  646. httpInvoker.httpMethod(HttpInvoker.HttpMethod.PUT);
  647. httpInvoker.path(
  648. _builder._scheme + "://" + _builder._host + ":" +
  649. _builder._port + _builder._contextPath +
  650. "/o/headless-commerce-admin-account/v1.0/accountAddresses/{id}");
  651. httpInvoker.path("id", id);
  652. httpInvoker.userNameAndPassword(
  653. _builder._login + ":" + _builder._password);
  654. return httpInvoker.invoke();
  655. }
  656. public void putAccountAddressBatch(
  657. Long id, String callbackURL, Object object)
  658. throws Exception {
  659. HttpInvoker.HttpResponse httpResponse =
  660. putAccountAddressBatchHttpResponse(id, callbackURL, object);
  661. String content = httpResponse.getContent();
  662. if ((httpResponse.getStatusCode() / 100) != 2) {
  663. _logger.log(
  664. Level.WARNING,
  665. "Unable to process HTTP response content: " + content);
  666. _logger.log(
  667. Level.WARNING,
  668. "HTTP response message: " + httpResponse.getMessage());
  669. _logger.log(
  670. Level.WARNING,
  671. "HTTP response status code: " +
  672. httpResponse.getStatusCode());
  673. throw new Problem.ProblemException(Problem.toDTO(content));
  674. }
  675. else {
  676. _logger.fine("HTTP response content: " + content);
  677. _logger.fine(
  678. "HTTP response message: " + httpResponse.getMessage());
  679. _logger.fine(
  680. "HTTP response status code: " +
  681. httpResponse.getStatusCode());
  682. }
  683. }
  684. public HttpInvoker.HttpResponse putAccountAddressBatchHttpResponse(
  685. Long id, String callbackURL, Object object)
  686. throws Exception {
  687. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  688. httpInvoker.body(object.toString(), "application/json");
  689. if (_builder._locale != null) {
  690. httpInvoker.header(
  691. "Accept-Language", _builder._locale.toLanguageTag());
  692. }
  693. for (Map.Entry<String, String> entry :
  694. _builder._headers.entrySet()) {
  695. httpInvoker.header(entry.getKey(), entry.getValue());
  696. }
  697. for (Map.Entry<String, String> entry :
  698. _builder._parameters.entrySet()) {
  699. httpInvoker.parameter(entry.getKey(), entry.getValue());
  700. }
  701. httpInvoker.httpMethod(HttpInvoker.HttpMethod.PUT);
  702. if (callbackURL != null) {
  703. httpInvoker.parameter(
  704. "callbackURL", String.valueOf(callbackURL));
  705. }
  706. httpInvoker.path(
  707. _builder._scheme + "://" + _builder._host + ":" +
  708. _builder._port + _builder._contextPath +
  709. "/o/headless-commerce-admin-account/v1.0/accountAddresses/batch");
  710. httpInvoker.path("id", id);
  711. httpInvoker.userNameAndPassword(
  712. _builder._login + ":" + _builder._password);
  713. return httpInvoker.invoke();
  714. }
  715. public Page<AccountAddress>
  716. getAccountByExternalReferenceCodeAccountAddressesPage(
  717. String externalReferenceCode, Pagination pagination)
  718. throws Exception {
  719. HttpInvoker.HttpResponse httpResponse =
  720. getAccountByExternalReferenceCodeAccountAddressesPageHttpResponse(
  721. externalReferenceCode, pagination);
  722. String content = httpResponse.getContent();
  723. if ((httpResponse.getStatusCode() / 100) != 2) {
  724. _logger.log(
  725. Level.WARNING,
  726. "Unable to process HTTP response content: " + content);
  727. _logger.log(
  728. Level.WARNING,
  729. "HTTP response message: " + httpResponse.getMessage());
  730. _logger.log(
  731. Level.WARNING,
  732. "HTTP response status code: " +
  733. httpResponse.getStatusCode());
  734. throw new Problem.ProblemException(Problem.toDTO(content));
  735. }
  736. else {
  737. _logger.fine("HTTP response content: " + content);
  738. _logger.fine(
  739. "HTTP response message: " + httpResponse.getMessage());
  740. _logger.fine(
  741. "HTTP response status code: " +
  742. httpResponse.getStatusCode());
  743. }
  744. try {
  745. return Page.of(content, AccountAddressSerDes::toDTO);
  746. }
  747. catch (Exception e) {
  748. _logger.log(
  749. Level.WARNING,
  750. "Unable to process HTTP response: " + content, e);
  751. throw new Problem.ProblemException(Problem.toDTO(content));
  752. }
  753. }
  754. public HttpInvoker.HttpResponse
  755. getAccountByExternalReferenceCodeAccountAddressesPageHttpResponse(
  756. String externalReferenceCode, Pagination pagination)
  757. throws Exception {
  758. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  759. if (_builder._locale != null) {
  760. httpInvoker.header(
  761. "Accept-Language", _builder._locale.toLanguageTag());
  762. }
  763. for (Map.Entry<String, String> entry :
  764. _builder._headers.entrySet()) {
  765. httpInvoker.header(entry.getKey(), entry.getValue());
  766. }
  767. for (Map.Entry<String, String> entry :
  768. _builder._parameters.entrySet()) {
  769. httpInvoker.parameter(entry.getKey(), entry.getValue());
  770. }
  771. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  772. if (pagination != null) {
  773. httpInvoker.parameter(
  774. "page", String.valueOf(pagination.getPage()));
  775. httpInvoker.parameter(
  776. "pageSize", String.valueOf(pagination.getPageSize()));
  777. }
  778. httpInvoker.path(
  779. _builder._scheme + "://" + _builder._host + ":" +
  780. _builder._port + _builder._contextPath +
  781. "/o/headless-commerce-admin-account/v1.0/accounts/by-externalReferenceCode/{externalReferenceCode}/accountAddresses");
  782. httpInvoker.path("externalReferenceCode", externalReferenceCode);
  783. httpInvoker.userNameAndPassword(
  784. _builder._login + ":" + _builder._password);
  785. return httpInvoker.invoke();
  786. }
  787. public AccountAddress postAccountByExternalReferenceCodeAccountAddress(
  788. String externalReferenceCode, AccountAddress accountAddress)
  789. throws Exception {
  790. HttpInvoker.HttpResponse httpResponse =
  791. postAccountByExternalReferenceCodeAccountAddressHttpResponse(
  792. externalReferenceCode, accountAddress);
  793. String content = httpResponse.getContent();
  794. if ((httpResponse.getStatusCode() / 100) != 2) {
  795. _logger.log(
  796. Level.WARNING,
  797. "Unable to process HTTP response content: " + content);
  798. _logger.log(
  799. Level.WARNING,
  800. "HTTP response message: " + httpResponse.getMessage());
  801. _logger.log(
  802. Level.WARNING,
  803. "HTTP response status code: " +
  804. httpResponse.getStatusCode());
  805. throw new Problem.ProblemException(Problem.toDTO(content));
  806. }
  807. else {
  808. _logger.fine("HTTP response content: " + content);
  809. _logger.fine(
  810. "HTTP response message: " + httpResponse.getMessage());
  811. _logger.fine(
  812. "HTTP response status code: " +
  813. httpResponse.getStatusCode());
  814. }
  815. try {
  816. return AccountAddressSerDes.toDTO(content);
  817. }
  818. catch (Exception e) {
  819. _logger.log(
  820. Level.WARNING,
  821. "Unable to process HTTP response: " + content, e);
  822. throw new Problem.ProblemException(Problem.toDTO(content));
  823. }
  824. }
  825. public HttpInvoker.HttpResponse
  826. postAccountByExternalReferenceCodeAccountAddressHttpResponse(
  827. String externalReferenceCode, AccountAddress accountAddress)
  828. throws Exception {
  829. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  830. httpInvoker.body(accountAddress.toString(), "application/json");
  831. if (_builder._locale != null) {
  832. httpInvoker.header(
  833. "Accept-Language", _builder._locale.toLanguageTag());
  834. }
  835. for (Map.Entry<String, String> entry :
  836. _builder._headers.entrySet()) {
  837. httpInvoker.header(entry.getKey(), entry.getValue());
  838. }
  839. for (Map.Entry<String, String> entry :
  840. _builder._parameters.entrySet()) {
  841. httpInvoker.parameter(entry.getKey(), entry.getValue());
  842. }
  843. httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
  844. httpInvoker.path(
  845. _builder._scheme + "://" + _builder._host + ":" +
  846. _builder._port + _builder._contextPath +
  847. "/o/headless-commerce-admin-account/v1.0/accounts/by-externalReferenceCode/{externalReferenceCode}/accountAddresses");
  848. httpInvoker.path("externalReferenceCode", externalReferenceCode);
  849. httpInvoker.userNameAndPassword(
  850. _builder._login + ":" + _builder._password);
  851. return httpInvoker.invoke();
  852. }
  853. public Page<AccountAddress> getAccountIdAccountAddressesPage(
  854. Long id, Pagination pagination)
  855. throws Exception {
  856. HttpInvoker.HttpResponse httpResponse =
  857. getAccountIdAccountAddressesPageHttpResponse(id, pagination);
  858. String content = httpResponse.getContent();
  859. if ((httpResponse.getStatusCode() / 100) != 2) {
  860. _logger.log(
  861. Level.WARNING,
  862. "Unable to process HTTP response content: " + content);
  863. _logger.log(
  864. Level.WARNING,
  865. "HTTP response message: " + httpResponse.getMessage());
  866. _logger.log(
  867. Level.WARNING,
  868. "HTTP response status code: " +
  869. httpResponse.getStatusCode());
  870. throw new Problem.ProblemException(Problem.toDTO(content));
  871. }
  872. else {
  873. _logger.fine("HTTP response content: " + content);
  874. _logger.fine(
  875. "HTTP response message: " + httpResponse.getMessage());
  876. _logger.fine(
  877. "HTTP response status code: " +
  878. httpResponse.getStatusCode());
  879. }
  880. try {
  881. return Page.of(content, AccountAddressSerDes::toDTO);
  882. }
  883. catch (Exception e) {
  884. _logger.log(
  885. Level.WARNING,
  886. "Unable to process HTTP response: " + content, e);
  887. throw new Problem.ProblemException(Problem.toDTO(content));
  888. }
  889. }
  890. public HttpInvoker.HttpResponse
  891. getAccountIdAccountAddressesPageHttpResponse(
  892. Long id, Pagination pagination)
  893. throws Exception {
  894. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  895. if (_builder._locale != null) {
  896. httpInvoker.header(
  897. "Accept-Language", _builder._locale.toLanguageTag());
  898. }
  899. for (Map.Entry<String, String> entry :
  900. _builder._headers.entrySet()) {
  901. httpInvoker.header(entry.getKey(), entry.getValue());
  902. }
  903. for (Map.Entry<String, String> entry :
  904. _builder._parameters.entrySet()) {
  905. httpInvoker.parameter(entry.getKey(), entry.getValue());
  906. }
  907. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  908. if (pagination != null) {
  909. httpInvoker.parameter(
  910. "page", String.valueOf(pagination.getPage()));
  911. httpInvoker.parameter(
  912. "pageSize", String.valueOf(pagination.getPageSize()));
  913. }
  914. httpInvoker.path(
  915. _builder._scheme + "://" + _builder._host + ":" +
  916. _builder._port + _builder._contextPath +
  917. "/o/headless-commerce-admin-account/v1.0/accounts/{id}/accountAddresses");
  918. httpInvoker.path("id", id);
  919. httpInvoker.userNameAndPassword(
  920. _builder._login + ":" + _builder._password);
  921. return httpInvoker.invoke();
  922. }
  923. public AccountAddress postAccountIdAccountAddress(
  924. Long id, AccountAddress accountAddress)
  925. throws Exception {
  926. HttpInvoker.HttpResponse httpResponse =
  927. postAccountIdAccountAddressHttpResponse(id, accountAddress);
  928. String content = httpResponse.getContent();
  929. if ((httpResponse.getStatusCode() / 100) != 2) {
  930. _logger.log(
  931. Level.WARNING,
  932. "Unable to process HTTP response content: " + content);
  933. _logger.log(
  934. Level.WARNING,
  935. "HTTP response message: " + httpResponse.getMessage());
  936. _logger.log(
  937. Level.WARNING,
  938. "HTTP response status code: " +
  939. httpResponse.getStatusCode());
  940. throw new Problem.ProblemException(Problem.toDTO(content));
  941. }
  942. else {
  943. _logger.fine("HTTP response content: " + content);
  944. _logger.fine(
  945. "HTTP response message: " + httpResponse.getMessage());
  946. _logger.fine(
  947. "HTTP response status code: " +
  948. httpResponse.getStatusCode());
  949. }
  950. try {
  951. return AccountAddressSerDes.toDTO(content);
  952. }
  953. catch (Exception e) {
  954. _logger.log(
  955. Level.WARNING,
  956. "Unable to process HTTP response: " + content, e);
  957. throw new Problem.ProblemException(Problem.toDTO(content));
  958. }
  959. }
  960. public HttpInvoker.HttpResponse postAccountIdAccountAddressHttpResponse(
  961. Long id, AccountAddress accountAddress)
  962. throws Exception {
  963. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  964. httpInvoker.body(accountAddress.toString(), "application/json");
  965. if (_builder._locale != null) {
  966. httpInvoker.header(
  967. "Accept-Language", _builder._locale.toLanguageTag());
  968. }
  969. for (Map.Entry<String, String> entry :
  970. _builder._headers.entrySet()) {
  971. httpInvoker.header(entry.getKey(), entry.getValue());
  972. }
  973. for (Map.Entry<String, String> entry :
  974. _builder._parameters.entrySet()) {
  975. httpInvoker.parameter(entry.getKey(), entry.getValue());
  976. }
  977. httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
  978. httpInvoker.path(
  979. _builder._scheme + "://" + _builder._host + ":" +
  980. _builder._port + _builder._contextPath +
  981. "/o/headless-commerce-admin-account/v1.0/accounts/{id}/accountAddresses");
  982. httpInvoker.path("id", id);
  983. httpInvoker.userNameAndPassword(
  984. _builder._login + ":" + _builder._password);
  985. return httpInvoker.invoke();
  986. }
  987. public void postAccountIdAccountAddressBatch(
  988. Long id, String callbackURL, Object object)
  989. throws Exception {
  990. HttpInvoker.HttpResponse httpResponse =
  991. postAccountIdAccountAddressBatchHttpResponse(
  992. id, callbackURL, object);
  993. String content = httpResponse.getContent();
  994. if ((httpResponse.getStatusCode() / 100) != 2) {
  995. _logger.log(
  996. Level.WARNING,
  997. "Unable to process HTTP response content: " + content);
  998. _logger.log(
  999. Level.WARNING,
  1000. "HTTP response message: " + httpResponse.getMessage());
  1001. _logger.log(
  1002. Level.WARNING,
  1003. "HTTP response status code: " +
  1004. httpResponse.getStatusCode());
  1005. throw new Problem.ProblemException(Problem.toDTO(content));
  1006. }
  1007. else {
  1008. _logger.fine("HTTP response content: " + content);
  1009. _logger.fine(
  1010. "HTTP response message: " + httpResponse.getMessage());
  1011. _logger.fine(
  1012. "HTTP response status code: " +
  1013. httpResponse.getStatusCode());
  1014. }
  1015. }
  1016. public HttpInvoker.HttpResponse
  1017. postAccountIdAccountAddressBatchHttpResponse(
  1018. Long id, String callbackURL, Object object)
  1019. throws Exception {
  1020. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  1021. httpInvoker.body(object.toString(), "application/json");
  1022. if (_builder._locale != null) {
  1023. httpInvoker.header(
  1024. "Accept-Language", _builder._locale.toLanguageTag());
  1025. }
  1026. for (Map.Entry<String, String> entry :
  1027. _builder._headers.entrySet()) {
  1028. httpInvoker.header(entry.getKey(), entry.getValue());
  1029. }
  1030. for (Map.Entry<String, String> entry :
  1031. _builder._parameters.entrySet()) {
  1032. httpInvoker.parameter(entry.getKey(), entry.getValue());
  1033. }
  1034. httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
  1035. if (callbackURL != null) {
  1036. httpInvoker.parameter(
  1037. "callbackURL", String.valueOf(callbackURL));
  1038. }
  1039. httpInvoker.path(
  1040. _builder._scheme + "://" + _builder._host + ":" +
  1041. _builder._port + _builder._contextPath +
  1042. "/o/headless-commerce-admin-account/v1.0/accounts/accountAddresses/batch");
  1043. httpInvoker.path("id", id);
  1044. httpInvoker.userNameAndPassword(
  1045. _builder._login + ":" + _builder._password);
  1046. return httpInvoker.invoke();
  1047. }
  1048. private AccountAddressResourceImpl(Builder builder) {
  1049. _builder = builder;
  1050. }
  1051. private static final Logger _logger = Logger.getLogger(
  1052. AccountAddressResource.class.getName());
  1053. private Builder _builder;
  1054. }
  1055. }