Source: requests.js

  1. /*
  2. * (c) Miva Inc <https://www.miva.com/>
  3. *
  4. * For the full copyright and license information, please view the LICENSE
  5. * file that was distributed with this source code.
  6. *
  7. * $Id: requests.js 77296 2019-08-07 22:09:12Z gidriss $
  8. */
  9. const util = require('./util');
  10. const models = require('./models');
  11. const responses = require('./responses');
  12. const { Request } = require('./abstract');
  13. const { ListQueryRequest } = require('./listquery');
  14. /** @module Request */
  15. /**
  16. * Handles API Request AvailabilityGroupBusinessAccount_Update_Assigned. Scope: Store.
  17. * @see https://docs.miva.com/json-api/functions/availabilitygroupbusinessaccount_update_assigned
  18. */
  19. class AvailabilityGroupBusinessAccountUpdateAssigned extends Request {
  20. /**
  21. * AvailabilityGroupBusinessAccountUpdateAssigned Constructor.
  22. * @param {?Client} client
  23. * @param {?AvailabilityGroup} availabilityGroup
  24. */
  25. constructor(client, availabilityGroup = null) {
  26. super(client);
  27. this.function = 'AvailabilityGroupBusinessAccount_Update_Assigned';
  28. this.scope = Request.REQUEST_SCOPE_STORE;
  29. this.availabilityGroupId = null;
  30. this.editAvailabilityGroup = null;
  31. this.availabilityGroupName = null;
  32. this.businessAccountId = null;
  33. this.businessAccountTitle = null;
  34. this.assigned = null;
  35. if (util.isInstanceOf(availabilityGroup, models.AvailabilityGroup)) {
  36. if (availabilityGroup.getId()) {
  37. this.setAvailabilityGroupId(availabilityGroup.getId());
  38. } else if (availabilityGroup.getName()) {
  39. this.setEditAvailabilityGroup(availabilityGroup.getName());
  40. }
  41. }
  42. }
  43. /**
  44. * Get AvailabilityGroup_ID.
  45. * @returns {number}
  46. */
  47. getAvailabilityGroupId() {
  48. return this.availabilityGroupId;
  49. }
  50. /**
  51. * Get Edit_AvailabilityGroup.
  52. * @returns {string}
  53. */
  54. getEditAvailabilityGroup() {
  55. return this.editAvailabilityGroup;
  56. }
  57. /**
  58. * Get AvailabilityGroup_Name.
  59. * @returns {string}
  60. */
  61. getAvailabilityGroupName() {
  62. return this.availabilityGroupName;
  63. }
  64. /**
  65. * Get BusinessAccount_ID.
  66. * @returns {number}
  67. */
  68. getBusinessAccountId() {
  69. return this.businessAccountId;
  70. }
  71. /**
  72. * Get BusinessAccount_Title.
  73. * @returns {string}
  74. */
  75. getBusinessAccountTitle() {
  76. return this.businessAccountTitle;
  77. }
  78. /**
  79. * Get Assigned.
  80. * @returns {boolean}
  81. */
  82. getAssigned() {
  83. return this.assigned;
  84. }
  85. /**
  86. * Set AvailabilityGroup_ID.
  87. * @param {number} availabilityGroupId
  88. * @returns {AvailabilityGroupBusinessAccountUpdateAssigned}
  89. */
  90. setAvailabilityGroupId(availabilityGroupId) {
  91. this.availabilityGroupId = availabilityGroupId;
  92. return this;
  93. }
  94. /**
  95. * Set Edit_AvailabilityGroup.
  96. * @param {string} editAvailabilityGroup
  97. * @returns {AvailabilityGroupBusinessAccountUpdateAssigned}
  98. */
  99. setEditAvailabilityGroup(editAvailabilityGroup) {
  100. this.editAvailabilityGroup = editAvailabilityGroup;
  101. return this;
  102. }
  103. /**
  104. * Set AvailabilityGroup_Name.
  105. * @param {string} availabilityGroupName
  106. * @returns {AvailabilityGroupBusinessAccountUpdateAssigned}
  107. */
  108. setAvailabilityGroupName(availabilityGroupName) {
  109. this.availabilityGroupName = availabilityGroupName;
  110. return this;
  111. }
  112. /**
  113. * Set BusinessAccount_ID.
  114. * @param {number} businessAccountId
  115. * @returns {AvailabilityGroupBusinessAccountUpdateAssigned}
  116. */
  117. setBusinessAccountId(businessAccountId) {
  118. this.businessAccountId = businessAccountId;
  119. return this;
  120. }
  121. /**
  122. * Set BusinessAccount_Title.
  123. * @param {string} businessAccountTitle
  124. * @returns {AvailabilityGroupBusinessAccountUpdateAssigned}
  125. */
  126. setBusinessAccountTitle(businessAccountTitle) {
  127. this.businessAccountTitle = businessAccountTitle;
  128. return this;
  129. }
  130. /**
  131. * Set Assigned.
  132. * @param {boolean} assigned
  133. * @returns {AvailabilityGroupBusinessAccountUpdateAssigned}
  134. */
  135. setAssigned(assigned) {
  136. this.assigned = assigned;
  137. return this;
  138. }
  139. /**
  140. * Reduce the request to a an object.
  141. * @override
  142. * @returns {Object}
  143. */
  144. toObject() {
  145. var data = super.toObject();
  146. if (!util.isNullOrUndefined(this.availabilityGroupId)) {
  147. data['AvailabilityGroup_ID'] = this.availabilityGroupId;
  148. } else if (!util.isNullOrUndefined(this.editAvailabilityGroup)) {
  149. data['Edit_AvailabilityGroup'] = this.editAvailabilityGroup;
  150. } else if (!util.isNullOrUndefined(this.availabilityGroupName)) {
  151. data['AvailabilityGroup_Name'] = this.availabilityGroupName;
  152. }
  153. if (!util.isNullOrUndefined(this.businessAccountId)) {
  154. data['BusinessAccount_ID'] = this.businessAccountId;
  155. } else if (!util.isNullOrUndefined(this.businessAccountTitle)) {
  156. data['BusinessAccount_Title'] = this.businessAccountTitle;
  157. }
  158. if (!util.isNullOrUndefined(this.assigned)) {
  159. data['Assigned'] = this.assigned;
  160. }
  161. return data;
  162. }
  163. /**
  164. * Create a response object from the response data.
  165. * @override
  166. * @returns {Response}
  167. */
  168. createResponse(data) {
  169. return new responses.AvailabilityGroupBusinessAccountUpdateAssigned(this, data);
  170. }
  171. }
  172. /**
  173. * Handles API Request AvailabilityGroupCustomer_Update_Assigned. Scope: Store.
  174. * @see https://docs.miva.com/json-api/functions/availabilitygroupcustomer_update_assigned
  175. */
  176. class AvailabilityGroupCustomerUpdateAssigned extends Request {
  177. /**
  178. * AvailabilityGroupCustomerUpdateAssigned Constructor.
  179. * @param {?Client} client
  180. * @param {?AvailabilityGroup} availabilityGroup
  181. */
  182. constructor(client, availabilityGroup = null) {
  183. super(client);
  184. this.function = 'AvailabilityGroupCustomer_Update_Assigned';
  185. this.scope = Request.REQUEST_SCOPE_STORE;
  186. this.availabilityGroupId = null;
  187. this.editAvailabilityGroup = null;
  188. this.availabilityGroupName = null;
  189. this.customerId = null;
  190. this.editCustomer = null;
  191. this.customerLogin = null;
  192. this.assigned = null;
  193. if (util.isInstanceOf(availabilityGroup, models.AvailabilityGroup)) {
  194. if (availabilityGroup.getId()) {
  195. this.setAvailabilityGroupId(availabilityGroup.getId());
  196. } else if (availabilityGroup.getName()) {
  197. this.setEditAvailabilityGroup(availabilityGroup.getName());
  198. }
  199. }
  200. }
  201. /**
  202. * Get AvailabilityGroup_ID.
  203. * @returns {number}
  204. */
  205. getAvailabilityGroupId() {
  206. return this.availabilityGroupId;
  207. }
  208. /**
  209. * Get Edit_AvailabilityGroup.
  210. * @returns {string}
  211. */
  212. getEditAvailabilityGroup() {
  213. return this.editAvailabilityGroup;
  214. }
  215. /**
  216. * Get AvailabilityGroup_Name.
  217. * @returns {string}
  218. */
  219. getAvailabilityGroupName() {
  220. return this.availabilityGroupName;
  221. }
  222. /**
  223. * Get Customer_ID.
  224. * @returns {number}
  225. */
  226. getCustomerId() {
  227. return this.customerId;
  228. }
  229. /**
  230. * Get Edit_Customer.
  231. * @returns {string}
  232. */
  233. getEditCustomer() {
  234. return this.editCustomer;
  235. }
  236. /**
  237. * Get Customer_Login.
  238. * @returns {string}
  239. */
  240. getCustomerLogin() {
  241. return this.customerLogin;
  242. }
  243. /**
  244. * Get Assigned.
  245. * @returns {boolean}
  246. */
  247. getAssigned() {
  248. return this.assigned;
  249. }
  250. /**
  251. * Set AvailabilityGroup_ID.
  252. * @param {number} availabilityGroupId
  253. * @returns {AvailabilityGroupCustomerUpdateAssigned}
  254. */
  255. setAvailabilityGroupId(availabilityGroupId) {
  256. this.availabilityGroupId = availabilityGroupId;
  257. return this;
  258. }
  259. /**
  260. * Set Edit_AvailabilityGroup.
  261. * @param {string} editAvailabilityGroup
  262. * @returns {AvailabilityGroupCustomerUpdateAssigned}
  263. */
  264. setEditAvailabilityGroup(editAvailabilityGroup) {
  265. this.editAvailabilityGroup = editAvailabilityGroup;
  266. return this;
  267. }
  268. /**
  269. * Set AvailabilityGroup_Name.
  270. * @param {string} availabilityGroupName
  271. * @returns {AvailabilityGroupCustomerUpdateAssigned}
  272. */
  273. setAvailabilityGroupName(availabilityGroupName) {
  274. this.availabilityGroupName = availabilityGroupName;
  275. return this;
  276. }
  277. /**
  278. * Set Customer_ID.
  279. * @param {number} customerId
  280. * @returns {AvailabilityGroupCustomerUpdateAssigned}
  281. */
  282. setCustomerId(customerId) {
  283. this.customerId = customerId;
  284. return this;
  285. }
  286. /**
  287. * Set Edit_Customer.
  288. * @param {string} editCustomer
  289. * @returns {AvailabilityGroupCustomerUpdateAssigned}
  290. */
  291. setEditCustomer(editCustomer) {
  292. this.editCustomer = editCustomer;
  293. return this;
  294. }
  295. /**
  296. * Set Customer_Login.
  297. * @param {string} customerLogin
  298. * @returns {AvailabilityGroupCustomerUpdateAssigned}
  299. */
  300. setCustomerLogin(customerLogin) {
  301. this.customerLogin = customerLogin;
  302. return this;
  303. }
  304. /**
  305. * Set Assigned.
  306. * @param {boolean} assigned
  307. * @returns {AvailabilityGroupCustomerUpdateAssigned}
  308. */
  309. setAssigned(assigned) {
  310. this.assigned = assigned;
  311. return this;
  312. }
  313. /**
  314. * Reduce the request to a an object.
  315. * @override
  316. * @returns {Object}
  317. */
  318. toObject() {
  319. var data = super.toObject();
  320. if (!util.isNullOrUndefined(this.availabilityGroupId)) {
  321. data['AvailabilityGroup_ID'] = this.availabilityGroupId;
  322. } else if (!util.isNullOrUndefined(this.editAvailabilityGroup)) {
  323. data['Edit_AvailabilityGroup'] = this.editAvailabilityGroup;
  324. } else if (!util.isNullOrUndefined(this.availabilityGroupName)) {
  325. data['AvailabilityGroup_Name'] = this.availabilityGroupName;
  326. }
  327. if (!util.isNullOrUndefined(this.customerId)) {
  328. data['Customer_ID'] = this.customerId;
  329. } else if (!util.isNullOrUndefined(this.editCustomer)) {
  330. data['Edit_Customer'] = this.editCustomer;
  331. } else if (!util.isNullOrUndefined(this.customerLogin)) {
  332. data['Customer_Login'] = this.customerLogin;
  333. }
  334. if (!util.isNullOrUndefined(this.assigned)) {
  335. data['Assigned'] = this.assigned;
  336. }
  337. return data;
  338. }
  339. /**
  340. * Create a response object from the response data.
  341. * @override
  342. * @returns {Response}
  343. */
  344. createResponse(data) {
  345. return new responses.AvailabilityGroupCustomerUpdateAssigned(this, data);
  346. }
  347. }
  348. /**
  349. * Handles API Request AvailabilityGroupList_Load_Query. Scope: Store.
  350. * @see https://docs.miva.com/json-api/functions/availabilitygrouplist_load_query
  351. */
  352. class AvailabilityGroupListLoadQuery extends ListQueryRequest {
  353. /**
  354. * AvailabilityGroupListLoadQuery Constructor.
  355. * @param {?Client} client
  356. */
  357. constructor(client) {
  358. super(client);
  359. this.function = 'AvailabilityGroupList_Load_Query';
  360. this.scope = Request.REQUEST_SCOPE_STORE;
  361. this.availableSearchFields = [
  362. 'id',
  363. 'name'
  364. ];
  365. this.availableSortFields = [
  366. 'id',
  367. 'name'
  368. ];
  369. }
  370. /**
  371. * Create a response object from the response data.
  372. * @override
  373. * @returns {Response}
  374. */
  375. createResponse(data) {
  376. return new responses.AvailabilityGroupListLoadQuery(this, data);
  377. }
  378. }
  379. /**
  380. * Handles API Request AvailabilityGroupPaymentMethod_Update_Assigned. Scope: Store.
  381. * @see https://docs.miva.com/json-api/functions/availabilitygrouppaymentmethod_update_assigned
  382. */
  383. class AvailabilityGroupPaymentMethodUpdateAssigned extends Request {
  384. /**
  385. * AvailabilityGroupPaymentMethodUpdateAssigned Constructor.
  386. * @param {?Client} client
  387. * @param {?AvailabilityGroup} availabilityGroup
  388. */
  389. constructor(client, availabilityGroup = null) {
  390. super(client);
  391. this.function = 'AvailabilityGroupPaymentMethod_Update_Assigned';
  392. this.scope = Request.REQUEST_SCOPE_STORE;
  393. this.availabilityGroupId = null;
  394. this.editAvailabilityGroup = null;
  395. this.availabilityGroupName = null;
  396. this.moduleCode = null;
  397. this.methodCode = null;
  398. this.paymentCardTypeId = null;
  399. this.assigned = null;
  400. if (util.isInstanceOf(availabilityGroup, models.AvailabilityGroup)) {
  401. if (availabilityGroup.getId()) {
  402. this.setAvailabilityGroupId(availabilityGroup.getId());
  403. } else if (availabilityGroup.getName()) {
  404. this.setEditAvailabilityGroup(availabilityGroup.getName());
  405. }
  406. }
  407. }
  408. /**
  409. * Get AvailabilityGroup_ID.
  410. * @returns {number}
  411. */
  412. getAvailabilityGroupId() {
  413. return this.availabilityGroupId;
  414. }
  415. /**
  416. * Get Edit_AvailabilityGroup.
  417. * @returns {string}
  418. */
  419. getEditAvailabilityGroup() {
  420. return this.editAvailabilityGroup;
  421. }
  422. /**
  423. * Get AvailabilityGroup_Name.
  424. * @returns {string}
  425. */
  426. getAvailabilityGroupName() {
  427. return this.availabilityGroupName;
  428. }
  429. /**
  430. * Get Module_Code.
  431. * @returns {string}
  432. */
  433. getModuleCode() {
  434. return this.moduleCode;
  435. }
  436. /**
  437. * Get Method_Code.
  438. * @returns {string}
  439. */
  440. getMethodCode() {
  441. return this.methodCode;
  442. }
  443. /**
  444. * Get PaymentCardType_ID.
  445. * @returns {number}
  446. */
  447. getPaymentCardTypeId() {
  448. return this.paymentCardTypeId;
  449. }
  450. /**
  451. * Get Assigned.
  452. * @returns {boolean}
  453. */
  454. getAssigned() {
  455. return this.assigned;
  456. }
  457. /**
  458. * Set AvailabilityGroup_ID.
  459. * @param {number} availabilityGroupId
  460. * @returns {AvailabilityGroupPaymentMethodUpdateAssigned}
  461. */
  462. setAvailabilityGroupId(availabilityGroupId) {
  463. this.availabilityGroupId = availabilityGroupId;
  464. return this;
  465. }
  466. /**
  467. * Set Edit_AvailabilityGroup.
  468. * @param {string} editAvailabilityGroup
  469. * @returns {AvailabilityGroupPaymentMethodUpdateAssigned}
  470. */
  471. setEditAvailabilityGroup(editAvailabilityGroup) {
  472. this.editAvailabilityGroup = editAvailabilityGroup;
  473. return this;
  474. }
  475. /**
  476. * Set AvailabilityGroup_Name.
  477. * @param {string} availabilityGroupName
  478. * @returns {AvailabilityGroupPaymentMethodUpdateAssigned}
  479. */
  480. setAvailabilityGroupName(availabilityGroupName) {
  481. this.availabilityGroupName = availabilityGroupName;
  482. return this;
  483. }
  484. /**
  485. * Set Module_Code.
  486. * @param {string} moduleCode
  487. * @returns {AvailabilityGroupPaymentMethodUpdateAssigned}
  488. */
  489. setModuleCode(moduleCode) {
  490. this.moduleCode = moduleCode;
  491. return this;
  492. }
  493. /**
  494. * Set Method_Code.
  495. * @param {string} methodCode
  496. * @returns {AvailabilityGroupPaymentMethodUpdateAssigned}
  497. */
  498. setMethodCode(methodCode) {
  499. this.methodCode = methodCode;
  500. return this;
  501. }
  502. /**
  503. * Set PaymentCardType_ID.
  504. * @param {number} paymentCardTypeId
  505. * @returns {AvailabilityGroupPaymentMethodUpdateAssigned}
  506. */
  507. setPaymentCardTypeId(paymentCardTypeId) {
  508. this.paymentCardTypeId = paymentCardTypeId;
  509. return this;
  510. }
  511. /**
  512. * Set Assigned.
  513. * @param {boolean} assigned
  514. * @returns {AvailabilityGroupPaymentMethodUpdateAssigned}
  515. */
  516. setAssigned(assigned) {
  517. this.assigned = assigned;
  518. return this;
  519. }
  520. /**
  521. * Reduce the request to a an object.
  522. * @override
  523. * @returns {Object}
  524. */
  525. toObject() {
  526. var data = super.toObject();
  527. if (!util.isNullOrUndefined(this.availabilityGroupId)) {
  528. data['AvailabilityGroup_ID'] = this.availabilityGroupId;
  529. } else if (!util.isNullOrUndefined(this.editAvailabilityGroup)) {
  530. data['Edit_AvailabilityGroup'] = this.editAvailabilityGroup;
  531. } else if (!util.isNullOrUndefined(this.availabilityGroupName)) {
  532. data['AvailabilityGroup_Name'] = this.availabilityGroupName;
  533. }
  534. data['Module_Code'] = this.moduleCode;
  535. data['Method_Code'] = this.methodCode;
  536. if (!util.isNullOrUndefined(this.paymentCardTypeId)) {
  537. data['PaymentCardType_ID'] = this.paymentCardTypeId;
  538. }
  539. data['Assigned'] = this.assigned;
  540. return data;
  541. }
  542. /**
  543. * Create a response object from the response data.
  544. * @override
  545. * @returns {Response}
  546. */
  547. createResponse(data) {
  548. return new responses.AvailabilityGroupPaymentMethodUpdateAssigned(this, data);
  549. }
  550. }
  551. /**
  552. * Handles API Request AvailabilityGroupProduct_Update_Assigned. Scope: Store.
  553. * @see https://docs.miva.com/json-api/functions/availabilitygroupproduct_update_assigned
  554. */
  555. class AvailabilityGroupProductUpdateAssigned extends Request {
  556. /**
  557. * AvailabilityGroupProductUpdateAssigned Constructor.
  558. * @param {?Client} client
  559. * @param {?AvailabilityGroup} availabilityGroup
  560. */
  561. constructor(client, availabilityGroup = null) {
  562. super(client);
  563. this.function = 'AvailabilityGroupProduct_Update_Assigned';
  564. this.scope = Request.REQUEST_SCOPE_STORE;
  565. this.availabilityGroupId = null;
  566. this.editAvailabilityGroup = null;
  567. this.availabilityGroupName = null;
  568. this.productId = null;
  569. this.productCode = null;
  570. this.productSku = null;
  571. this.editProduct = null;
  572. this.assigned = null;
  573. if (util.isInstanceOf(availabilityGroup, models.AvailabilityGroup)) {
  574. if (availabilityGroup.getId()) {
  575. this.setAvailabilityGroupId(availabilityGroup.getId());
  576. } else if (availabilityGroup.getName()) {
  577. this.setEditAvailabilityGroup(availabilityGroup.getName());
  578. }
  579. }
  580. }
  581. /**
  582. * Get AvailabilityGroup_ID.
  583. * @returns {number}
  584. */
  585. getAvailabilityGroupId() {
  586. return this.availabilityGroupId;
  587. }
  588. /**
  589. * Get Edit_AvailabilityGroup.
  590. * @returns {string}
  591. */
  592. getEditAvailabilityGroup() {
  593. return this.editAvailabilityGroup;
  594. }
  595. /**
  596. * Get AvailabilityGroup_Name.
  597. * @returns {string}
  598. */
  599. getAvailabilityGroupName() {
  600. return this.availabilityGroupName;
  601. }
  602. /**
  603. * Get Product_ID.
  604. * @returns {number}
  605. */
  606. getProductId() {
  607. return this.productId;
  608. }
  609. /**
  610. * Get Product_Code.
  611. * @returns {string}
  612. */
  613. getProductCode() {
  614. return this.productCode;
  615. }
  616. /**
  617. * Get Product_SKU.
  618. * @returns {string}
  619. */
  620. getProductSku() {
  621. return this.productSku;
  622. }
  623. /**
  624. * Get Edit_Product.
  625. * @returns {string}
  626. */
  627. getEditProduct() {
  628. return this.editProduct;
  629. }
  630. /**
  631. * Get Assigned.
  632. * @returns {boolean}
  633. */
  634. getAssigned() {
  635. return this.assigned;
  636. }
  637. /**
  638. * Set AvailabilityGroup_ID.
  639. * @param {number} availabilityGroupId
  640. * @returns {AvailabilityGroupProductUpdateAssigned}
  641. */
  642. setAvailabilityGroupId(availabilityGroupId) {
  643. this.availabilityGroupId = availabilityGroupId;
  644. return this;
  645. }
  646. /**
  647. * Set Edit_AvailabilityGroup.
  648. * @param {string} editAvailabilityGroup
  649. * @returns {AvailabilityGroupProductUpdateAssigned}
  650. */
  651. setEditAvailabilityGroup(editAvailabilityGroup) {
  652. this.editAvailabilityGroup = editAvailabilityGroup;
  653. return this;
  654. }
  655. /**
  656. * Set AvailabilityGroup_Name.
  657. * @param {string} availabilityGroupName
  658. * @returns {AvailabilityGroupProductUpdateAssigned}
  659. */
  660. setAvailabilityGroupName(availabilityGroupName) {
  661. this.availabilityGroupName = availabilityGroupName;
  662. return this;
  663. }
  664. /**
  665. * Set Product_ID.
  666. * @param {number} productId
  667. * @returns {AvailabilityGroupProductUpdateAssigned}
  668. */
  669. setProductId(productId) {
  670. this.productId = productId;
  671. return this;
  672. }
  673. /**
  674. * Set Product_Code.
  675. * @param {string} productCode
  676. * @returns {AvailabilityGroupProductUpdateAssigned}
  677. */
  678. setProductCode(productCode) {
  679. this.productCode = productCode;
  680. return this;
  681. }
  682. /**
  683. * Set Product_SKU.
  684. * @param {string} productSku
  685. * @returns {AvailabilityGroupProductUpdateAssigned}
  686. */
  687. setProductSku(productSku) {
  688. this.productSku = productSku;
  689. return this;
  690. }
  691. /**
  692. * Set Edit_Product.
  693. * @param {string} editProduct
  694. * @returns {AvailabilityGroupProductUpdateAssigned}
  695. */
  696. setEditProduct(editProduct) {
  697. this.editProduct = editProduct;
  698. return this;
  699. }
  700. /**
  701. * Set Assigned.
  702. * @param {boolean} assigned
  703. * @returns {AvailabilityGroupProductUpdateAssigned}
  704. */
  705. setAssigned(assigned) {
  706. this.assigned = assigned;
  707. return this;
  708. }
  709. /**
  710. * Reduce the request to a an object.
  711. * @override
  712. * @returns {Object}
  713. */
  714. toObject() {
  715. var data = super.toObject();
  716. if (!util.isNullOrUndefined(this.availabilityGroupId)) {
  717. data['AvailabilityGroup_ID'] = this.availabilityGroupId;
  718. } else if (!util.isNullOrUndefined(this.editAvailabilityGroup)) {
  719. data['Edit_AvailabilityGroup'] = this.editAvailabilityGroup;
  720. } else if (!util.isNullOrUndefined(this.availabilityGroupName)) {
  721. data['AvailabilityGroup_Name'] = this.availabilityGroupName;
  722. }
  723. if (!util.isNullOrUndefined(this.productId)) {
  724. data['Product_ID'] = this.productId;
  725. } else if (!util.isNullOrUndefined(this.editProduct)) {
  726. data['Edit_Product'] = this.editProduct;
  727. } else if (!util.isNullOrUndefined(this.productCode)) {
  728. data['Product_Code'] = this.productCode;
  729. } else if (!util.isNullOrUndefined(this.productSku)) {
  730. data['Product_SKU'] = this.productSku;
  731. }
  732. data['Assigned'] = this.assigned;
  733. return data;
  734. }
  735. /**
  736. * Create a response object from the response data.
  737. * @override
  738. * @returns {Response}
  739. */
  740. createResponse(data) {
  741. return new responses.AvailabilityGroupProductUpdateAssigned(this, data);
  742. }
  743. }
  744. /**
  745. * Handles API Request AvailabilityGroupShippingMethod_Update_Assigned. Scope: Store.
  746. * @see https://docs.miva.com/json-api/functions/availabilitygroupshippingmethod_update_assigned
  747. */
  748. class AvailabilityGroupShippingMethodUpdateAssigned extends Request {
  749. /**
  750. * AvailabilityGroupShippingMethodUpdateAssigned Constructor.
  751. * @param {?Client} client
  752. * @param {?AvailabilityGroup} availabilityGroup
  753. */
  754. constructor(client, availabilityGroup = null) {
  755. super(client);
  756. this.function = 'AvailabilityGroupShippingMethod_Update_Assigned';
  757. this.scope = Request.REQUEST_SCOPE_STORE;
  758. this.availabilityGroupId = null;
  759. this.editAvailabilityGroup = null;
  760. this.availabilityGroupName = null;
  761. this.moduleCode = null;
  762. this.methodCode = null;
  763. this.assigned = null;
  764. if (util.isInstanceOf(availabilityGroup, models.AvailabilityGroup)) {
  765. if (availabilityGroup.getId()) {
  766. this.setAvailabilityGroupId(availabilityGroup.getId());
  767. } else if (availabilityGroup.getName()) {
  768. this.setEditAvailabilityGroup(availabilityGroup.getName());
  769. }
  770. }
  771. }
  772. /**
  773. * Get AvailabilityGroup_ID.
  774. * @returns {number}
  775. */
  776. getAvailabilityGroupId() {
  777. return this.availabilityGroupId;
  778. }
  779. /**
  780. * Get Edit_AvailabilityGroup.
  781. * @returns {string}
  782. */
  783. getEditAvailabilityGroup() {
  784. return this.editAvailabilityGroup;
  785. }
  786. /**
  787. * Get AvailabilityGroup_Name.
  788. * @returns {string}
  789. */
  790. getAvailabilityGroupName() {
  791. return this.availabilityGroupName;
  792. }
  793. /**
  794. * Get Module_Code.
  795. * @returns {string}
  796. */
  797. getModuleCode() {
  798. return this.moduleCode;
  799. }
  800. /**
  801. * Get Method_Code.
  802. * @returns {string}
  803. */
  804. getMethodCode() {
  805. return this.methodCode;
  806. }
  807. /**
  808. * Get Assigned.
  809. * @returns {boolean}
  810. */
  811. getAssigned() {
  812. return this.assigned;
  813. }
  814. /**
  815. * Set AvailabilityGroup_ID.
  816. * @param {number} availabilityGroupId
  817. * @returns {AvailabilityGroupShippingMethodUpdateAssigned}
  818. */
  819. setAvailabilityGroupId(availabilityGroupId) {
  820. this.availabilityGroupId = availabilityGroupId;
  821. return this;
  822. }
  823. /**
  824. * Set Edit_AvailabilityGroup.
  825. * @param {string} editAvailabilityGroup
  826. * @returns {AvailabilityGroupShippingMethodUpdateAssigned}
  827. */
  828. setEditAvailabilityGroup(editAvailabilityGroup) {
  829. this.editAvailabilityGroup = editAvailabilityGroup;
  830. return this;
  831. }
  832. /**
  833. * Set AvailabilityGroup_Name.
  834. * @param {string} availabilityGroupName
  835. * @returns {AvailabilityGroupShippingMethodUpdateAssigned}
  836. */
  837. setAvailabilityGroupName(availabilityGroupName) {
  838. this.availabilityGroupName = availabilityGroupName;
  839. return this;
  840. }
  841. /**
  842. * Set Module_Code.
  843. * @param {string} moduleCode
  844. * @returns {AvailabilityGroupShippingMethodUpdateAssigned}
  845. */
  846. setModuleCode(moduleCode) {
  847. this.moduleCode = moduleCode;
  848. return this;
  849. }
  850. /**
  851. * Set Method_Code.
  852. * @param {string} methodCode
  853. * @returns {AvailabilityGroupShippingMethodUpdateAssigned}
  854. */
  855. setMethodCode(methodCode) {
  856. this.methodCode = methodCode;
  857. return this;
  858. }
  859. /**
  860. * Set Assigned.
  861. * @param {boolean} assigned
  862. * @returns {AvailabilityGroupShippingMethodUpdateAssigned}
  863. */
  864. setAssigned(assigned) {
  865. this.assigned = assigned;
  866. return this;
  867. }
  868. /**
  869. * Reduce the request to a an object.
  870. * @override
  871. * @returns {Object}
  872. */
  873. toObject() {
  874. var data = super.toObject();
  875. if (!util.isNullOrUndefined(this.availabilityGroupId)) {
  876. data['AvailabilityGroup_ID'] = this.availabilityGroupId;
  877. } else if (!util.isNullOrUndefined(this.editAvailabilityGroup)) {
  878. data['Edit_AvailabilityGroup'] = this.editAvailabilityGroup;
  879. } else if (!util.isNullOrUndefined(this.availabilityGroupName)) {
  880. data['AvailabilityGroup_Name'] = this.availabilityGroupName;
  881. }
  882. data['Module_Code'] = this.moduleCode;
  883. data['Method_Code'] = this.methodCode;
  884. data['Assigned'] = this.assigned;
  885. return data;
  886. }
  887. /**
  888. * Create a response object from the response data.
  889. * @override
  890. * @returns {Response}
  891. */
  892. createResponse(data) {
  893. return new responses.AvailabilityGroupShippingMethodUpdateAssigned(this, data);
  894. }
  895. }
  896. /**
  897. * Handles API Request CategoryList_Load_Parent. Scope: Store.
  898. * @see https://docs.miva.com/json-api/functions/categorylist_load_parent
  899. */
  900. class CategoryListLoadParent extends Request {
  901. /**
  902. * CategoryListLoadParent Constructor.
  903. * @param {?Client} client
  904. * @param {?Category} category
  905. */
  906. constructor(client, category = null) {
  907. super(client);
  908. this.function = 'CategoryList_Load_Parent';
  909. this.scope = Request.REQUEST_SCOPE_STORE;
  910. this.parentId = null;
  911. if (util.isInstanceOf(category, models.Category)) {
  912. this.setParentId(category.getId());
  913. }
  914. }
  915. /**
  916. * Get Parent_ID.
  917. * @returns {number}
  918. */
  919. getParentId() {
  920. return this.parentId;
  921. }
  922. /**
  923. * Set Parent_ID.
  924. * @param {number} parentId
  925. * @returns {CategoryListLoadParent}
  926. */
  927. setParentId(parentId) {
  928. this.parentId = parentId;
  929. return this;
  930. }
  931. /**
  932. * Reduce the request to a an object.
  933. * @override
  934. * @returns {Object}
  935. */
  936. toObject() {
  937. var data = super.toObject();
  938. data['Parent_ID'] = this.getParentId();
  939. return data;
  940. }
  941. /**
  942. * Create a response object from the response data.
  943. * @override
  944. * @returns {Response}
  945. */
  946. createResponse(data) {
  947. return new responses.CategoryListLoadParent(this, data);
  948. }
  949. }
  950. /** CATEGORY_SHOW constants. */
  951. /** @ignore */
  952. const CATEGORY_SHOW_ALL = 'All';
  953. /** @ignore */
  954. const CATEGORY_SHOW_ACTIVE = 'Active';
  955. /**
  956. * Handles API Request CategoryList_Load_Query. Scope: Store.
  957. * @see https://docs.miva.com/json-api/functions/categorylist_load_query
  958. */
  959. class CategoryListLoadQuery extends ListQueryRequest {
  960. /**
  961. * CategoryListLoadQuery Constructor.
  962. * @param {?Client} client
  963. */
  964. constructor(client) {
  965. super(client);
  966. this.function = 'CategoryList_Load_Query';
  967. this.scope = Request.REQUEST_SCOPE_STORE;
  968. this.availableSearchFields = [
  969. 'id',
  970. 'code',
  971. 'name',
  972. 'page_title',
  973. 'parent_category',
  974. 'page_code',
  975. 'dt_created',
  976. 'dt_updated',
  977. 'depth'
  978. ];
  979. this.availableSortFields = [
  980. 'id',
  981. 'code',
  982. 'name',
  983. 'page_title',
  984. 'active',
  985. 'page_code',
  986. 'parent_category',
  987. 'disp_order',
  988. 'dt_created',
  989. 'dt_updated',
  990. 'depth'
  991. ];
  992. this.availableCustomFilters = {
  993. Category_Show : [
  994. CATEGORY_SHOW_ALL,
  995. CATEGORY_SHOW_ACTIVE
  996. ],
  997. };
  998. }
  999. /**
  1000. * Constant CATEGORY_SHOW_ALL
  1001. * @returns {string}
  1002. * @const
  1003. * @static
  1004. */
  1005. static get CATEGORY_SHOW_ALL() {
  1006. return CATEGORY_SHOW_ALL;
  1007. }
  1008. /**
  1009. * Constant CATEGORY_SHOW_ACTIVE
  1010. * @returns {string}
  1011. * @const
  1012. * @static
  1013. */
  1014. static get CATEGORY_SHOW_ACTIVE() {
  1015. return CATEGORY_SHOW_ACTIVE;
  1016. }
  1017. /**
  1018. * Create a response object from the response data.
  1019. * @override
  1020. * @returns {Response}
  1021. */
  1022. createResponse(data) {
  1023. return new responses.CategoryListLoadQuery(this, data);
  1024. }
  1025. }
  1026. /**
  1027. * Handles API Request CategoryProduct_Update_Assigned. Scope: Store.
  1028. * @see https://docs.miva.com/json-api/functions/categoryproduct_update_assigned
  1029. */
  1030. class CategoryProductUpdateAssigned extends Request {
  1031. /**
  1032. * CategoryProductUpdateAssigned Constructor.
  1033. * @param {?Client} client
  1034. * @param {?Category} category
  1035. */
  1036. constructor(client, category = null) {
  1037. super(client);
  1038. this.function = 'CategoryProduct_Update_Assigned';
  1039. this.scope = Request.REQUEST_SCOPE_STORE;
  1040. this.categoryId = null;
  1041. this.editCategory = null;
  1042. this.categoryCode = null;
  1043. this.productId = null;
  1044. this.editProduct = null;
  1045. this.productCode = null;
  1046. this.productSku = null;
  1047. this.assigned = null;
  1048. if (util.isInstanceOf(category, models.Category)) {
  1049. if (category.getId()) {
  1050. this.setCategoryId(category.getId());
  1051. } else if (category.getCode()) {
  1052. this.setEditCategory(category.getCode());
  1053. }
  1054. }
  1055. }
  1056. /**
  1057. * Get Category_ID.
  1058. * @returns {number}
  1059. */
  1060. getCategoryId() {
  1061. return this.categoryId;
  1062. }
  1063. /**
  1064. * Get Edit_Category.
  1065. * @returns {string}
  1066. */
  1067. getEditCategory() {
  1068. return this.editCategory;
  1069. }
  1070. /**
  1071. * Get Category_Code.
  1072. * @returns {string}
  1073. */
  1074. getCategoryCode() {
  1075. return this.categoryCode;
  1076. }
  1077. /**
  1078. * Get Product_ID.
  1079. * @returns {number}
  1080. */
  1081. getProductId() {
  1082. return this.productId;
  1083. }
  1084. /**
  1085. * Get Edit_Product.
  1086. * @returns {string}
  1087. */
  1088. getEditProduct() {
  1089. return this.editProduct;
  1090. }
  1091. /**
  1092. * Get Product_Code.
  1093. * @returns {string}
  1094. */
  1095. getProductCode() {
  1096. return this.productCode;
  1097. }
  1098. /**
  1099. * Get Product_SKU.
  1100. * @returns {string}
  1101. */
  1102. getProductSku() {
  1103. return this.productSku;
  1104. }
  1105. /**
  1106. * Get Assigned.
  1107. * @returns {boolean}
  1108. */
  1109. getAssigned() {
  1110. return this.assigned;
  1111. }
  1112. /**
  1113. * Set Category_ID.
  1114. * @param {number} categoryId
  1115. * @returns {CategoryProductUpdateAssigned}
  1116. */
  1117. setCategoryId(categoryId) {
  1118. this.categoryId = categoryId;
  1119. return this;
  1120. }
  1121. /**
  1122. * Set Edit_Category.
  1123. * @param {string} editCategory
  1124. * @returns {CategoryProductUpdateAssigned}
  1125. */
  1126. setEditCategory(editCategory) {
  1127. this.editCategory = editCategory;
  1128. return this;
  1129. }
  1130. /**
  1131. * Set Category_Code.
  1132. * @param {string} categoryCode
  1133. * @returns {CategoryProductUpdateAssigned}
  1134. */
  1135. setCategoryCode(categoryCode) {
  1136. this.categoryCode = categoryCode;
  1137. return this;
  1138. }
  1139. /**
  1140. * Set Product_ID.
  1141. * @param {number} productId
  1142. * @returns {CategoryProductUpdateAssigned}
  1143. */
  1144. setProductId(productId) {
  1145. this.productId = productId;
  1146. return this;
  1147. }
  1148. /**
  1149. * Set Edit_Product.
  1150. * @param {string} editProduct
  1151. * @returns {CategoryProductUpdateAssigned}
  1152. */
  1153. setEditProduct(editProduct) {
  1154. this.editProduct = editProduct;
  1155. return this;
  1156. }
  1157. /**
  1158. * Set Product_Code.
  1159. * @param {string} productCode
  1160. * @returns {CategoryProductUpdateAssigned}
  1161. */
  1162. setProductCode(productCode) {
  1163. this.productCode = productCode;
  1164. return this;
  1165. }
  1166. /**
  1167. * Set Product_SKU.
  1168. * @param {string} productSku
  1169. * @returns {CategoryProductUpdateAssigned}
  1170. */
  1171. setProductSku(productSku) {
  1172. this.productSku = productSku;
  1173. return this;
  1174. }
  1175. /**
  1176. * Set Assigned.
  1177. * @param {boolean} assigned
  1178. * @returns {CategoryProductUpdateAssigned}
  1179. */
  1180. setAssigned(assigned) {
  1181. this.assigned = assigned;
  1182. return this;
  1183. }
  1184. /**
  1185. * Reduce the request to a an object.
  1186. * @override
  1187. * @returns {Object}
  1188. */
  1189. toObject() {
  1190. var data = super.toObject();
  1191. if (!util.isNullOrUndefined(this.categoryId)) {
  1192. data['Category_ID'] = this.categoryId;
  1193. } else if (!util.isNullOrUndefined(this.editCategory)) {
  1194. data['Edit_Category'] = this.editCategory;
  1195. } else if (!util.isNullOrUndefined(this.categoryCode)) {
  1196. data['Category_Code'] = this.categoryCode;
  1197. }
  1198. if (!util.isNullOrUndefined(this.productId)) {
  1199. data['Product_ID'] = this.productId;
  1200. } else if (!util.isNullOrUndefined(this.editProduct)) {
  1201. data['Edit_Product'] = this.editProduct;
  1202. } else if (!util.isNullOrUndefined(this.productCode)) {
  1203. data['Product_Code'] = this.productCode;
  1204. } else if (!util.isNullOrUndefined(this.productSku)) {
  1205. data['Product_SKU'] = this.productSku;
  1206. }
  1207. data['Assigned'] = this.assigned;
  1208. return data;
  1209. }
  1210. /**
  1211. * Create a response object from the response data.
  1212. * @override
  1213. * @returns {Response}
  1214. */
  1215. createResponse(data) {
  1216. return new responses.CategoryProductUpdateAssigned(this, data);
  1217. }
  1218. }
  1219. /**
  1220. * Handles API Request Category_Insert. Scope: Store.
  1221. * @see https://docs.miva.com/json-api/functions/category_insert
  1222. */
  1223. class CategoryInsert extends Request {
  1224. /**
  1225. * CategoryInsert Constructor.
  1226. * @param {?Client} client
  1227. * @param {?Category} category
  1228. */
  1229. constructor(client, category = null) {
  1230. super(client);
  1231. this.function = 'Category_Insert';
  1232. this.scope = Request.REQUEST_SCOPE_STORE;
  1233. this.categoryCode = null;
  1234. this.categoryName = null;
  1235. this.categoryActive = null;
  1236. this.categoryPageTitle = null;
  1237. this.categoryParentCategory = null;
  1238. this.categoryAlternateDisplayPage = null;
  1239. this.customFieldValues = new models.CustomFieldValues();
  1240. if (util.isInstanceOf(category, models.Category)) {
  1241. this.setCategoryCode(category.getCode());
  1242. this.setCategoryName(category.getName());
  1243. this.setCategoryActive(category.getActive());
  1244. this.setCategoryPageTitle(category.getPageTitle());
  1245. this.setCategoryAlternateDisplayPage(category.getPageCode());
  1246. if (category.getCustomFieldValues()) {
  1247. this.setCustomFieldValues(category.getCustomFieldValues());
  1248. }
  1249. }
  1250. }
  1251. /**
  1252. * Get Category_Code.
  1253. * @returns {string}
  1254. */
  1255. getCategoryCode() {
  1256. return this.categoryCode;
  1257. }
  1258. /**
  1259. * Get Category_Name.
  1260. * @returns {string}
  1261. */
  1262. getCategoryName() {
  1263. return this.categoryName;
  1264. }
  1265. /**
  1266. * Get Category_Active.
  1267. * @returns {boolean}
  1268. */
  1269. getCategoryActive() {
  1270. return this.categoryActive;
  1271. }
  1272. /**
  1273. * Get Category_Page_Title.
  1274. * @returns {string}
  1275. */
  1276. getCategoryPageTitle() {
  1277. return this.categoryPageTitle;
  1278. }
  1279. /**
  1280. * Get Category_Parent_Category.
  1281. * @returns {string}
  1282. */
  1283. getCategoryParentCategory() {
  1284. return this.categoryParentCategory;
  1285. }
  1286. /**
  1287. * Get Category_Alternate_Display_Page.
  1288. * @returns {string}
  1289. */
  1290. getCategoryAlternateDisplayPage() {
  1291. return this.categoryAlternateDisplayPage;
  1292. }
  1293. /**
  1294. * Get CustomField_Values.
  1295. * @returns {?CustomFieldValues}
  1296. */
  1297. getCustomFieldValues() {
  1298. return this.customFieldValues;
  1299. }
  1300. /**
  1301. * Set Category_Code.
  1302. * @param {string} categoryCode
  1303. * @returns {CategoryInsert}
  1304. */
  1305. setCategoryCode(categoryCode) {
  1306. this.categoryCode = categoryCode;
  1307. return this;
  1308. }
  1309. /**
  1310. * Set Category_Name.
  1311. * @param {string} categoryName
  1312. * @returns {CategoryInsert}
  1313. */
  1314. setCategoryName(categoryName) {
  1315. this.categoryName = categoryName;
  1316. return this;
  1317. }
  1318. /**
  1319. * Set Category_Active.
  1320. * @param {boolean} categoryActive
  1321. * @returns {CategoryInsert}
  1322. */
  1323. setCategoryActive(categoryActive) {
  1324. this.categoryActive = categoryActive;
  1325. return this;
  1326. }
  1327. /**
  1328. * Set Category_Page_Title.
  1329. * @param {string} categoryPageTitle
  1330. * @returns {CategoryInsert}
  1331. */
  1332. setCategoryPageTitle(categoryPageTitle) {
  1333. this.categoryPageTitle = categoryPageTitle;
  1334. return this;
  1335. }
  1336. /**
  1337. * Set Category_Parent_Category.
  1338. * @param {string} categoryParentCategory
  1339. * @returns {CategoryInsert}
  1340. */
  1341. setCategoryParentCategory(categoryParentCategory) {
  1342. this.categoryParentCategory = categoryParentCategory;
  1343. return this;
  1344. }
  1345. /**
  1346. * Set Category_Alternate_Display_Page.
  1347. * @param {string} categoryAlternateDisplayPage
  1348. * @returns {CategoryInsert}
  1349. */
  1350. setCategoryAlternateDisplayPage(categoryAlternateDisplayPage) {
  1351. this.categoryAlternateDisplayPage = categoryAlternateDisplayPage;
  1352. return this;
  1353. }
  1354. /**
  1355. * Set CustomField_Values.
  1356. * @param {?CustomFieldValues} customFieldValues
  1357. * @throws {Error}
  1358. * @returns {CategoryInsert}
  1359. */
  1360. setCustomFieldValues(customFieldValues) {
  1361. if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues) && util.isObject(customFieldValues)) {
  1362. customFieldValues = new models.CustomFieldValues(customFieldValues);
  1363. } else if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues)) {
  1364. throw new Error(util.format('Expected instance of CustomFieldValues or an Object but got %s',
  1365. typeof customFieldValues));
  1366. }
  1367. this.customFieldValues = customFieldValues;
  1368. return this;
  1369. }
  1370. /**
  1371. * Reduce the request to a an object.
  1372. * @override
  1373. * @returns {Object}
  1374. */
  1375. toObject() {
  1376. var data = super.toObject();
  1377. data['Category_Code'] = this.categoryCode;
  1378. data['Category_Name'] = this.categoryName;
  1379. if (!util.isNullOrUndefined(this.categoryActive)) {
  1380. data['Category_Active'] = this.categoryActive;
  1381. }
  1382. if (!util.isNullOrUndefined(this.categoryPageTitle)) {
  1383. data['Category_Page_Title'] = this.categoryPageTitle;
  1384. }
  1385. if (!util.isNullOrUndefined(this.categoryParentCategory)) {
  1386. data['Category_Parent_Category'] = this.categoryParentCategory;
  1387. }
  1388. if (!util.isNullOrUndefined(this.categoryAlternateDisplayPage)) {
  1389. data['Category_Alternate_Display_Page'] = this.categoryAlternateDisplayPage;
  1390. }
  1391. if (this.customFieldValues && util.isObject(this.customFieldValues)) {
  1392. data['CustomField_Values'] = this.customFieldValues.toObject();
  1393. }
  1394. return data;
  1395. }
  1396. /**
  1397. * Create a response object from the response data.
  1398. * @override
  1399. * @returns {Response}
  1400. */
  1401. createResponse(data) {
  1402. return new responses.CategoryInsert(this, data);
  1403. }
  1404. }
  1405. /**
  1406. * Handles API Request Category_Delete. Scope: Store.
  1407. * @see https://docs.miva.com/json-api/functions/category_delete
  1408. */
  1409. class CategoryDelete extends Request {
  1410. /**
  1411. * CategoryDelete Constructor.
  1412. * @param {?Client} client
  1413. * @param {?Category} category
  1414. */
  1415. constructor(client, category = null) {
  1416. super(client);
  1417. this.function = 'Category_Delete';
  1418. this.scope = Request.REQUEST_SCOPE_STORE;
  1419. this.categoryId = null;
  1420. this.editCategory = null;
  1421. this.categoryCode = null;
  1422. if (util.isInstanceOf(category, models.Category)) {
  1423. if (category.getId()) {
  1424. this.setCategoryId(category.getId());
  1425. } else if (category.getCode()) {
  1426. this.setEditCategory(category.getCode());
  1427. }
  1428. }
  1429. }
  1430. /**
  1431. * Get Category_ID.
  1432. * @returns {number}
  1433. */
  1434. getCategoryId() {
  1435. return this.categoryId;
  1436. }
  1437. /**
  1438. * Get Edit_Category.
  1439. * @returns {string}
  1440. */
  1441. getEditCategory() {
  1442. return this.editCategory;
  1443. }
  1444. /**
  1445. * Get Category_Code.
  1446. * @returns {string}
  1447. */
  1448. getCategoryCode() {
  1449. return this.categoryCode;
  1450. }
  1451. /**
  1452. * Set Category_ID.
  1453. * @param {number} categoryId
  1454. * @returns {CategoryDelete}
  1455. */
  1456. setCategoryId(categoryId) {
  1457. this.categoryId = categoryId;
  1458. return this;
  1459. }
  1460. /**
  1461. * Set Edit_Category.
  1462. * @param {string} editCategory
  1463. * @returns {CategoryDelete}
  1464. */
  1465. setEditCategory(editCategory) {
  1466. this.editCategory = editCategory;
  1467. return this;
  1468. }
  1469. /**
  1470. * Set Category_Code.
  1471. * @param {string} categoryCode
  1472. * @returns {CategoryDelete}
  1473. */
  1474. setCategoryCode(categoryCode) {
  1475. this.categoryCode = categoryCode;
  1476. return this;
  1477. }
  1478. /**
  1479. * Reduce the request to a an object.
  1480. * @override
  1481. * @returns {Object}
  1482. */
  1483. toObject() {
  1484. var data = super.toObject();
  1485. if (!util.isNullOrUndefined(this.categoryId)) {
  1486. data['Category_ID'] = this.categoryId;
  1487. } else if (!util.isNullOrUndefined(this.editCategory)) {
  1488. data['Edit_Category'] = this.editCategory;
  1489. } else if (!util.isNullOrUndefined(this.categoryCode)) {
  1490. data['Category_Code'] = this.categoryCode;
  1491. }
  1492. return data;
  1493. }
  1494. /**
  1495. * Create a response object from the response data.
  1496. * @override
  1497. * @returns {Response}
  1498. */
  1499. createResponse(data) {
  1500. return new responses.CategoryDelete(this, data);
  1501. }
  1502. }
  1503. /**
  1504. * Handles API Request Category_Update. Scope: Store.
  1505. * @see https://docs.miva.com/json-api/functions/category_update
  1506. */
  1507. class CategoryUpdate extends Request {
  1508. /**
  1509. * CategoryUpdate Constructor.
  1510. * @param {?Client} client
  1511. * @param {?Category} category
  1512. */
  1513. constructor(client, category = null) {
  1514. super(client);
  1515. this.function = 'Category_Update';
  1516. this.scope = Request.REQUEST_SCOPE_STORE;
  1517. this.categoryId = null;
  1518. this.categoryCode = null;
  1519. this.editCategory = null;
  1520. this.categoryName = null;
  1521. this.categoryPageTitle = null;
  1522. this.categoryActive = null;
  1523. this.categoryParentCategory = null;
  1524. this.categoryAlternateDisplayPage = null;
  1525. this.customFieldValues = new models.CustomFieldValues();
  1526. if (util.isInstanceOf(category, models.Category)) {
  1527. if (category.getId()) {
  1528. this.setCategoryId(category.getId());
  1529. } else if (category.getCode()) {
  1530. this.setEditCategory(category.getCode());
  1531. }
  1532. this.setCategoryCode(category.getCode());
  1533. this.setCategoryName(category.getName());
  1534. this.setCategoryPageTitle(category.getPageTitle());
  1535. this.setCategoryActive(category.getActive());
  1536. this.setCategoryParentCategory(category.getParentCategory());
  1537. this.setCategoryAlternateDisplayPage(category.getPageCode());
  1538. if (category.getCustomFieldValues()) {
  1539. this.setCustomFieldValues(category.getCustomFieldValues());
  1540. }
  1541. }
  1542. }
  1543. /**
  1544. * Get Category_ID.
  1545. * @returns {number}
  1546. */
  1547. getCategoryId() {
  1548. return this.categoryId;
  1549. }
  1550. /**
  1551. * Get Category_Code.
  1552. * @returns {string}
  1553. */
  1554. getCategoryCode() {
  1555. return this.categoryCode;
  1556. }
  1557. /**
  1558. * Get Edit_Category.
  1559. * @returns {string}
  1560. */
  1561. getEditCategory() {
  1562. return this.editCategory;
  1563. }
  1564. /**
  1565. * Get Category_Name.
  1566. * @returns {string}
  1567. */
  1568. getCategoryName() {
  1569. return this.categoryName;
  1570. }
  1571. /**
  1572. * Get Category_Page_Title.
  1573. * @returns {string}
  1574. */
  1575. getCategoryPageTitle() {
  1576. return this.categoryPageTitle;
  1577. }
  1578. /**
  1579. * Get Category_Active.
  1580. * @returns {boolean}
  1581. */
  1582. getCategoryActive() {
  1583. return this.categoryActive;
  1584. }
  1585. /**
  1586. * Get Category_Parent_Category.
  1587. * @returns {string}
  1588. */
  1589. getCategoryParentCategory() {
  1590. return this.categoryParentCategory;
  1591. }
  1592. /**
  1593. * Get Category_Alternate_Display_Page.
  1594. * @returns {string}
  1595. */
  1596. getCategoryAlternateDisplayPage() {
  1597. return this.categoryAlternateDisplayPage;
  1598. }
  1599. /**
  1600. * Get CustomField_Values.
  1601. * @returns {?CustomFieldValues}
  1602. */
  1603. getCustomFieldValues() {
  1604. return this.customFieldValues;
  1605. }
  1606. /**
  1607. * Set Category_ID.
  1608. * @param {number} categoryId
  1609. * @returns {CategoryUpdate}
  1610. */
  1611. setCategoryId(categoryId) {
  1612. this.categoryId = categoryId;
  1613. return this;
  1614. }
  1615. /**
  1616. * Set Category_Code.
  1617. * @param {string} categoryCode
  1618. * @returns {CategoryUpdate}
  1619. */
  1620. setCategoryCode(categoryCode) {
  1621. this.categoryCode = categoryCode;
  1622. return this;
  1623. }
  1624. /**
  1625. * Set Edit_Category.
  1626. * @param {string} editCategory
  1627. * @returns {CategoryUpdate}
  1628. */
  1629. setEditCategory(editCategory) {
  1630. this.editCategory = editCategory;
  1631. return this;
  1632. }
  1633. /**
  1634. * Set Category_Name.
  1635. * @param {string} categoryName
  1636. * @returns {CategoryUpdate}
  1637. */
  1638. setCategoryName(categoryName) {
  1639. this.categoryName = categoryName;
  1640. return this;
  1641. }
  1642. /**
  1643. * Set Category_Page_Title.
  1644. * @param {string} categoryPageTitle
  1645. * @returns {CategoryUpdate}
  1646. */
  1647. setCategoryPageTitle(categoryPageTitle) {
  1648. this.categoryPageTitle = categoryPageTitle;
  1649. return this;
  1650. }
  1651. /**
  1652. * Set Category_Active.
  1653. * @param {boolean} categoryActive
  1654. * @returns {CategoryUpdate}
  1655. */
  1656. setCategoryActive(categoryActive) {
  1657. this.categoryActive = categoryActive;
  1658. return this;
  1659. }
  1660. /**
  1661. * Set Category_Parent_Category.
  1662. * @param {string} categoryParentCategory
  1663. * @returns {CategoryUpdate}
  1664. */
  1665. setCategoryParentCategory(categoryParentCategory) {
  1666. this.categoryParentCategory = categoryParentCategory;
  1667. return this;
  1668. }
  1669. /**
  1670. * Set Category_Alternate_Display_Page.
  1671. * @param {string} categoryAlternateDisplayPage
  1672. * @returns {CategoryUpdate}
  1673. */
  1674. setCategoryAlternateDisplayPage(categoryAlternateDisplayPage) {
  1675. this.categoryAlternateDisplayPage = categoryAlternateDisplayPage;
  1676. return this;
  1677. }
  1678. /**
  1679. * Set CustomField_Values.
  1680. * @param {?CustomFieldValues} customFieldValues
  1681. * @throws {Error}
  1682. * @returns {CategoryUpdate}
  1683. */
  1684. setCustomFieldValues(customFieldValues) {
  1685. if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues) && util.isObject(customFieldValues)) {
  1686. customFieldValues = new models.CustomFieldValues(customFieldValues);
  1687. } else if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues)) {
  1688. throw new Error(util.format('Expected instance of CustomFieldValues or an Object but got %s',
  1689. typeof customFieldValues));
  1690. }
  1691. this.customFieldValues = customFieldValues;
  1692. return this;
  1693. }
  1694. /**
  1695. * Reduce the request to a an object.
  1696. * @override
  1697. * @returns {Object}
  1698. */
  1699. toObject() {
  1700. var data = super.toObject();
  1701. if (!util.isNullOrUndefined(this.categoryId)) {
  1702. data['Category_ID'] = this.categoryId;
  1703. } else if (!util.isNullOrUndefined(this.editCategory)) {
  1704. data['Edit_Category'] = this.editCategory;
  1705. }
  1706. if (!util.isNullOrUndefined(this.categoryCode)) {
  1707. data['Category_Code'] = this.categoryCode;
  1708. }
  1709. if (!util.isNullOrUndefined(this.categoryName)) {
  1710. data['Category_Name'] = this.categoryName;
  1711. }
  1712. if (!util.isNullOrUndefined(this.categoryPageTitle)) {
  1713. data['Category_Page_Title'] = this.categoryPageTitle;
  1714. }
  1715. if (!util.isNullOrUndefined(this.categoryActive)) {
  1716. data['Category_Active'] = this.categoryActive;
  1717. }
  1718. if (!util.isNullOrUndefined(this.categoryParentCategory)) {
  1719. data['Category_Parent_Category'] = this.categoryParentCategory;
  1720. }
  1721. if (!util.isNullOrUndefined(this.categoryAlternateDisplayPage)) {
  1722. data['Category_Alternate_Display_Page'] = this.categoryAlternateDisplayPage;
  1723. }
  1724. if (this.customFieldValues && util.isObject(this.customFieldValues)) {
  1725. data['CustomField_Values'] = this.customFieldValues.toObject();
  1726. }
  1727. return data;
  1728. }
  1729. /**
  1730. * Create a response object from the response data.
  1731. * @override
  1732. * @returns {Response}
  1733. */
  1734. createResponse(data) {
  1735. return new responses.CategoryUpdate(this, data);
  1736. }
  1737. }
  1738. /**
  1739. * Handles API Request CouponList_Delete. Scope: Store.
  1740. * @see https://docs.miva.com/json-api/functions/couponlist_delete
  1741. */
  1742. class CouponListDelete extends Request {
  1743. /**
  1744. * CouponListDelete Constructor.
  1745. * @param {?Client} client
  1746. */
  1747. constructor(client) {
  1748. super(client);
  1749. this.function = 'CouponList_Delete';
  1750. this.scope = Request.REQUEST_SCOPE_STORE;
  1751. this.couponIds = [];
  1752. }
  1753. /**
  1754. * Get Coupon_IDs.
  1755. * @returns {Array}
  1756. */
  1757. getCouponIds() {
  1758. return this.couponIds;
  1759. }
  1760. /**
  1761. * Add Coupon_IDs.
  1762. * @param {number} couponId
  1763. * @returns {CouponListDelete}
  1764. */
  1765. addCouponId(couponId) {
  1766. this.couponIds.push(couponId);
  1767. return this;
  1768. }
  1769. /**
  1770. * Add Coupon model.
  1771. * @param {Coupon} coupon
  1772. * @throws {Error}
  1773. * @returns {CouponListDelete}
  1774. */
  1775. addCoupon(coupon) {
  1776. if (!util.isInstanceOf(coupon, models.Coupon)) {
  1777. throw new Error(util.format('Expected instance of Coupon but got %s',
  1778. typeof coupon));
  1779. }
  1780. if (coupon.getId()) {
  1781. this.couponIds.push(coupon.getId());
  1782. }
  1783. return this;
  1784. }
  1785. /**
  1786. * Reduce the request to a an object.
  1787. * @override
  1788. * @returns {Object}
  1789. */
  1790. toObject() {
  1791. var data = super.toObject();
  1792. data['Coupon_IDs'] = this.couponIds;
  1793. return data;
  1794. }
  1795. /**
  1796. * Create a response object from the response data.
  1797. * @override
  1798. * @returns {Response}
  1799. */
  1800. createResponse(data) {
  1801. return new responses.CouponListDelete(this, data);
  1802. }
  1803. }
  1804. /**
  1805. * Handles API Request CouponList_Load_Query. Scope: Store.
  1806. * @see https://docs.miva.com/json-api/functions/couponlist_load_query
  1807. */
  1808. class CouponListLoadQuery extends ListQueryRequest {
  1809. /**
  1810. * CouponListLoadQuery Constructor.
  1811. * @param {?Client} client
  1812. */
  1813. constructor(client) {
  1814. super(client);
  1815. this.function = 'CouponList_Load_Query';
  1816. this.scope = Request.REQUEST_SCOPE_STORE;
  1817. this.availableSearchFields = [
  1818. 'id',
  1819. 'code',
  1820. 'descrip',
  1821. 'custscope',
  1822. 'dt_start',
  1823. 'dt_end',
  1824. 'max_use',
  1825. 'max_per',
  1826. 'active',
  1827. 'use_count'
  1828. ];
  1829. this.availableSortFields = [
  1830. 'id',
  1831. 'code',
  1832. 'descrip',
  1833. 'custscope',
  1834. 'dt_start',
  1835. 'dt_end',
  1836. 'max_use',
  1837. 'max_per',
  1838. 'active',
  1839. 'use_count'
  1840. ];
  1841. }
  1842. /**
  1843. * Create a response object from the response data.
  1844. * @override
  1845. * @returns {Response}
  1846. */
  1847. createResponse(data) {
  1848. return new responses.CouponListLoadQuery(this, data);
  1849. }
  1850. }
  1851. /**
  1852. * Handles API Request CouponPriceGroup_Update_Assigned. Scope: Store.
  1853. * @see https://docs.miva.com/json-api/functions/couponpricegroup_update_assigned
  1854. */
  1855. class CouponPriceGroupUpdateAssigned extends Request {
  1856. /**
  1857. * CouponPriceGroupUpdateAssigned Constructor.
  1858. * @param {?Client} client
  1859. * @param {?Coupon} coupon
  1860. */
  1861. constructor(client, coupon = null) {
  1862. super(client);
  1863. this.function = 'CouponPriceGroup_Update_Assigned';
  1864. this.scope = Request.REQUEST_SCOPE_STORE;
  1865. this.couponId = null;
  1866. this.editCoupon = null;
  1867. this.couponCode = null;
  1868. this.priceGroupId = null;
  1869. this.priceGroupName = null;
  1870. this.assigned = null;
  1871. if (util.isInstanceOf(coupon, models.Coupon)) {
  1872. if (coupon.getId()) {
  1873. this.setCouponId(coupon.getId());
  1874. } else if (coupon.getCode()) {
  1875. this.setEditCoupon(coupon.getCode());
  1876. }
  1877. }
  1878. }
  1879. /**
  1880. * Get Coupon_ID.
  1881. * @returns {number}
  1882. */
  1883. getCouponId() {
  1884. return this.couponId;
  1885. }
  1886. /**
  1887. * Get Edit_Coupon.
  1888. * @returns {string}
  1889. */
  1890. getEditCoupon() {
  1891. return this.editCoupon;
  1892. }
  1893. /**
  1894. * Get Coupon_Code.
  1895. * @returns {string}
  1896. */
  1897. getCouponCode() {
  1898. return this.couponCode;
  1899. }
  1900. /**
  1901. * Get PriceGroup_ID.
  1902. * @returns {number}
  1903. */
  1904. getPriceGroupId() {
  1905. return this.priceGroupId;
  1906. }
  1907. /**
  1908. * Get PriceGroup_Name.
  1909. * @returns {string}
  1910. */
  1911. getPriceGroupName() {
  1912. return this.priceGroupName;
  1913. }
  1914. /**
  1915. * Get Assigned.
  1916. * @returns {boolean}
  1917. */
  1918. getAssigned() {
  1919. return this.assigned;
  1920. }
  1921. /**
  1922. * Set Coupon_ID.
  1923. * @param {number} couponId
  1924. * @returns {CouponPriceGroupUpdateAssigned}
  1925. */
  1926. setCouponId(couponId) {
  1927. this.couponId = couponId;
  1928. return this;
  1929. }
  1930. /**
  1931. * Set Edit_Coupon.
  1932. * @param {string} editCoupon
  1933. * @returns {CouponPriceGroupUpdateAssigned}
  1934. */
  1935. setEditCoupon(editCoupon) {
  1936. this.editCoupon = editCoupon;
  1937. return this;
  1938. }
  1939. /**
  1940. * Set Coupon_Code.
  1941. * @param {string} couponCode
  1942. * @returns {CouponPriceGroupUpdateAssigned}
  1943. */
  1944. setCouponCode(couponCode) {
  1945. this.couponCode = couponCode;
  1946. return this;
  1947. }
  1948. /**
  1949. * Set PriceGroup_ID.
  1950. * @param {number} priceGroupId
  1951. * @returns {CouponPriceGroupUpdateAssigned}
  1952. */
  1953. setPriceGroupId(priceGroupId) {
  1954. this.priceGroupId = priceGroupId;
  1955. return this;
  1956. }
  1957. /**
  1958. * Set PriceGroup_Name.
  1959. * @param {string} priceGroupName
  1960. * @returns {CouponPriceGroupUpdateAssigned}
  1961. */
  1962. setPriceGroupName(priceGroupName) {
  1963. this.priceGroupName = priceGroupName;
  1964. return this;
  1965. }
  1966. /**
  1967. * Set Assigned.
  1968. * @param {boolean} assigned
  1969. * @returns {CouponPriceGroupUpdateAssigned}
  1970. */
  1971. setAssigned(assigned) {
  1972. this.assigned = assigned;
  1973. return this;
  1974. }
  1975. /**
  1976. * Reduce the request to a an object.
  1977. * @override
  1978. * @returns {Object}
  1979. */
  1980. toObject() {
  1981. var data = super.toObject();
  1982. if (!util.isNullOrUndefined(this.couponId)) {
  1983. data['Coupon_ID'] = this.couponId;
  1984. } else if (!util.isNullOrUndefined(this.editCoupon)) {
  1985. data['Edit_Coupon'] = this.editCoupon;
  1986. } else if (!util.isNullOrUndefined(this.couponCode)) {
  1987. data['Coupon_Code'] = this.couponCode;
  1988. }
  1989. if (!util.isNullOrUndefined(this.priceGroupId)) {
  1990. data['PriceGroup_ID'] = this.priceGroupId;
  1991. } else if (!util.isNullOrUndefined(this.priceGroupName)) {
  1992. data['PriceGroup_Name'] = this.priceGroupName;
  1993. }
  1994. data['Assigned'] = this.assigned;
  1995. return data;
  1996. }
  1997. /**
  1998. * Create a response object from the response data.
  1999. * @override
  2000. * @returns {Response}
  2001. */
  2002. createResponse(data) {
  2003. return new responses.CouponPriceGroupUpdateAssigned(this, data);
  2004. }
  2005. }
  2006. /**
  2007. * Handles API Request Coupon_Insert. Scope: Store.
  2008. * @see https://docs.miva.com/json-api/functions/coupon_insert
  2009. */
  2010. class CouponInsert extends Request {
  2011. /**
  2012. * CouponInsert Constructor.
  2013. * @param {?Client} client
  2014. * @param {?Coupon} coupon
  2015. */
  2016. constructor(client, coupon = null) {
  2017. super(client);
  2018. this.function = 'Coupon_Insert';
  2019. this.scope = Request.REQUEST_SCOPE_STORE;
  2020. this.code = null;
  2021. this.description = null;
  2022. this.customerScope = null;
  2023. this.dateTimeStart = null;
  2024. this.dateTimeEnd = null;
  2025. this.maxUse = null;
  2026. this.maxPer = null;
  2027. this.active = null;
  2028. this.priceGroupId = null;
  2029. if (util.isInstanceOf(coupon, models.Coupon)) {
  2030. this.setCode(coupon.getCode());
  2031. this.setDescription(coupon.getDescription());
  2032. this.setCustomerScope(coupon.getCustomerScope());
  2033. this.setDateTimeStart(coupon.getDateTimeStart());
  2034. this.setDateTimeEnd(coupon.getDateTimeEnd());
  2035. this.setMaxUse(coupon.getMaxUse());
  2036. this.setMaxPer(coupon.getMaxPer());
  2037. this.setActive(coupon.getActive());
  2038. }
  2039. }
  2040. /**
  2041. * Get Code.
  2042. * @returns {string}
  2043. */
  2044. getCode() {
  2045. return this.code;
  2046. }
  2047. /**
  2048. * Get Description.
  2049. * @returns {string}
  2050. */
  2051. getDescription() {
  2052. return this.description;
  2053. }
  2054. /**
  2055. * Get CustomerScope.
  2056. * @returns {string}
  2057. */
  2058. getCustomerScope() {
  2059. return this.customerScope;
  2060. }
  2061. /**
  2062. * Get DateTime_Start.
  2063. * @returns {number}
  2064. */
  2065. getDateTimeStart() {
  2066. return this.dateTimeStart;
  2067. }
  2068. /**
  2069. * Get DateTime_End.
  2070. * @returns {number}
  2071. */
  2072. getDateTimeEnd() {
  2073. return this.dateTimeEnd;
  2074. }
  2075. /**
  2076. * Get Max_Use.
  2077. * @returns {number}
  2078. */
  2079. getMaxUse() {
  2080. return this.maxUse;
  2081. }
  2082. /**
  2083. * Get Max_Per.
  2084. * @returns {number}
  2085. */
  2086. getMaxPer() {
  2087. return this.maxPer;
  2088. }
  2089. /**
  2090. * Get Active.
  2091. * @returns {boolean}
  2092. */
  2093. getActive() {
  2094. return this.active;
  2095. }
  2096. /**
  2097. * Get PriceGroup_ID.
  2098. * @returns {number}
  2099. */
  2100. getPriceGroupId() {
  2101. return this.priceGroupId;
  2102. }
  2103. /**
  2104. * Set Code.
  2105. * @param {string} code
  2106. * @returns {CouponInsert}
  2107. */
  2108. setCode(code) {
  2109. this.code = code;
  2110. return this;
  2111. }
  2112. /**
  2113. * Set Description.
  2114. * @param {string} description
  2115. * @returns {CouponInsert}
  2116. */
  2117. setDescription(description) {
  2118. this.description = description;
  2119. return this;
  2120. }
  2121. /**
  2122. * Set CustomerScope.
  2123. * @param {string} customerScope
  2124. * @returns {CouponInsert}
  2125. */
  2126. setCustomerScope(customerScope) {
  2127. this.customerScope = customerScope;
  2128. return this;
  2129. }
  2130. /**
  2131. * Set DateTime_Start.
  2132. * @param {number|Date} dateTimeStart
  2133. * @returns {CouponInsert}
  2134. */
  2135. setDateTimeStart(dateTimeStart) {
  2136. if (util.isDate(dateTimeStart)) {
  2137. this.dateTimeStart = Math.floor(dateTimeStart.getTime()/1000);
  2138. } else {
  2139. this.dateTimeStart = dateTimeStart;
  2140. }
  2141. return this;
  2142. }
  2143. /**
  2144. * Set DateTime_End.
  2145. * @param {number|Date} dateTimeEnd
  2146. * @returns {CouponInsert}
  2147. */
  2148. setDateTimeEnd(dateTimeEnd) {
  2149. if (util.isDate(dateTimeEnd)) {
  2150. this.dateTimeEnd = Math.floor(dateTimeEnd.getTime()/1000);
  2151. } else {
  2152. this.dateTimeEnd = dateTimeEnd;
  2153. }
  2154. return this;
  2155. }
  2156. /**
  2157. * Set Max_Use.
  2158. * @param {number} maxUse
  2159. * @returns {CouponInsert}
  2160. */
  2161. setMaxUse(maxUse) {
  2162. this.maxUse = maxUse;
  2163. return this;
  2164. }
  2165. /**
  2166. * Set Max_Per.
  2167. * @param {number} maxPer
  2168. * @returns {CouponInsert}
  2169. */
  2170. setMaxPer(maxPer) {
  2171. this.maxPer = maxPer;
  2172. return this;
  2173. }
  2174. /**
  2175. * Set Active.
  2176. * @param {boolean} active
  2177. * @returns {CouponInsert}
  2178. */
  2179. setActive(active) {
  2180. this.active = active;
  2181. return this;
  2182. }
  2183. /**
  2184. * Set PriceGroup_ID.
  2185. * @param {number} priceGroupId
  2186. * @returns {CouponInsert}
  2187. */
  2188. setPriceGroupId(priceGroupId) {
  2189. this.priceGroupId = priceGroupId;
  2190. return this;
  2191. }
  2192. /**
  2193. * Reduce the request to a an object.
  2194. * @override
  2195. * @returns {Object}
  2196. */
  2197. toObject() {
  2198. var data = super.toObject();
  2199. data['Code'] = this.code;
  2200. if (!util.isNullOrUndefined(this.description)) {
  2201. data['Description'] = this.description;
  2202. }
  2203. if (!util.isNullOrUndefined(this.customerScope)) {
  2204. data['CustomerScope'] = this.customerScope;
  2205. }
  2206. if (!util.isNullOrUndefined(this.dateTimeStart)) {
  2207. data['DateTime_Start'] = this.dateTimeStart;
  2208. }
  2209. if (!util.isNullOrUndefined(this.dateTimeEnd)) {
  2210. data['DateTime_End'] = this.dateTimeEnd;
  2211. }
  2212. if (!util.isNullOrUndefined(this.maxUse)) {
  2213. data['Max_Use'] = this.maxUse;
  2214. }
  2215. if (!util.isNullOrUndefined(this.maxPer)) {
  2216. data['Max_Per'] = this.maxPer;
  2217. }
  2218. if (!util.isNullOrUndefined(this.active)) {
  2219. data['Active'] = this.active;
  2220. }
  2221. if (!util.isNullOrUndefined(this.priceGroupId)) {
  2222. data['PriceGroup_ID'] = this.priceGroupId;
  2223. }
  2224. return data;
  2225. }
  2226. /**
  2227. * Create a response object from the response data.
  2228. * @override
  2229. * @returns {Response}
  2230. */
  2231. createResponse(data) {
  2232. return new responses.CouponInsert(this, data);
  2233. }
  2234. }
  2235. /**
  2236. * Handles API Request Coupon_Update. Scope: Store.
  2237. * @see https://docs.miva.com/json-api/functions/coupon_update
  2238. */
  2239. class CouponUpdate extends Request {
  2240. /**
  2241. * CouponUpdate Constructor.
  2242. * @param {?Client} client
  2243. * @param {?Coupon} coupon
  2244. */
  2245. constructor(client, coupon = null) {
  2246. super(client);
  2247. this.function = 'Coupon_Update';
  2248. this.scope = Request.REQUEST_SCOPE_STORE;
  2249. this.couponId = null;
  2250. this.couponCode = null;
  2251. this.editCoupon = null;
  2252. this.code = null;
  2253. this.description = null;
  2254. this.customerScope = null;
  2255. this.dateTimeStart = null;
  2256. this.dateTimeEnd = null;
  2257. this.maxUse = null;
  2258. this.maxPer = null;
  2259. this.active = null;
  2260. if (util.isInstanceOf(coupon, models.Coupon)) {
  2261. if (coupon.getId()) {
  2262. this.setCouponId(coupon.getId());
  2263. } else if (coupon.getCode()) {
  2264. this.setEditCoupon(coupon.getCode());
  2265. }
  2266. this.setCouponCode(coupon.getCode());
  2267. this.setCode(coupon.getCode());
  2268. this.setDescription(coupon.getDescription());
  2269. this.setCustomerScope(coupon.getCustomerScope());
  2270. this.setDateTimeStart(coupon.getDateTimeStart());
  2271. this.setDateTimeEnd(coupon.getDateTimeEnd());
  2272. this.setMaxUse(coupon.getMaxUse());
  2273. this.setMaxPer(coupon.getMaxPer());
  2274. this.setActive(coupon.getActive());
  2275. }
  2276. }
  2277. /**
  2278. * Get Coupon_ID.
  2279. * @returns {number}
  2280. */
  2281. getCouponId() {
  2282. return this.couponId;
  2283. }
  2284. /**
  2285. * Get Coupon_Code.
  2286. * @returns {string}
  2287. */
  2288. getCouponCode() {
  2289. return this.couponCode;
  2290. }
  2291. /**
  2292. * Get Edit_Coupon.
  2293. * @returns {string}
  2294. */
  2295. getEditCoupon() {
  2296. return this.editCoupon;
  2297. }
  2298. /**
  2299. * Get Code.
  2300. * @returns {string}
  2301. */
  2302. getCode() {
  2303. return this.code;
  2304. }
  2305. /**
  2306. * Get Description.
  2307. * @returns {string}
  2308. */
  2309. getDescription() {
  2310. return this.description;
  2311. }
  2312. /**
  2313. * Get CustomerScope.
  2314. * @returns {string}
  2315. */
  2316. getCustomerScope() {
  2317. return this.customerScope;
  2318. }
  2319. /**
  2320. * Get DateTime_Start.
  2321. * @returns {number}
  2322. */
  2323. getDateTimeStart() {
  2324. return this.dateTimeStart;
  2325. }
  2326. /**
  2327. * Get DateTime_End.
  2328. * @returns {number}
  2329. */
  2330. getDateTimeEnd() {
  2331. return this.dateTimeEnd;
  2332. }
  2333. /**
  2334. * Get Max_Use.
  2335. * @returns {number}
  2336. */
  2337. getMaxUse() {
  2338. return this.maxUse;
  2339. }
  2340. /**
  2341. * Get Max_Per.
  2342. * @returns {number}
  2343. */
  2344. getMaxPer() {
  2345. return this.maxPer;
  2346. }
  2347. /**
  2348. * Get Active.
  2349. * @returns {boolean}
  2350. */
  2351. getActive() {
  2352. return this.active;
  2353. }
  2354. /**
  2355. * Set Coupon_ID.
  2356. * @param {number} couponId
  2357. * @returns {CouponUpdate}
  2358. */
  2359. setCouponId(couponId) {
  2360. this.couponId = couponId;
  2361. return this;
  2362. }
  2363. /**
  2364. * Set Coupon_Code.
  2365. * @param {string} couponCode
  2366. * @returns {CouponUpdate}
  2367. */
  2368. setCouponCode(couponCode) {
  2369. this.couponCode = couponCode;
  2370. return this;
  2371. }
  2372. /**
  2373. * Set Edit_Coupon.
  2374. * @param {string} editCoupon
  2375. * @returns {CouponUpdate}
  2376. */
  2377. setEditCoupon(editCoupon) {
  2378. this.editCoupon = editCoupon;
  2379. return this;
  2380. }
  2381. /**
  2382. * Set Code.
  2383. * @param {string} code
  2384. * @returns {CouponUpdate}
  2385. */
  2386. setCode(code) {
  2387. this.code = code;
  2388. return this;
  2389. }
  2390. /**
  2391. * Set Description.
  2392. * @param {string} description
  2393. * @returns {CouponUpdate}
  2394. */
  2395. setDescription(description) {
  2396. this.description = description;
  2397. return this;
  2398. }
  2399. /**
  2400. * Set CustomerScope.
  2401. * @param {string} customerScope
  2402. * @returns {CouponUpdate}
  2403. */
  2404. setCustomerScope(customerScope) {
  2405. this.customerScope = customerScope;
  2406. return this;
  2407. }
  2408. /**
  2409. * Set DateTime_Start.
  2410. * @param {number|Date} dateTimeStart
  2411. * @returns {CouponUpdate}
  2412. */
  2413. setDateTimeStart(dateTimeStart) {
  2414. if (util.isDate(dateTimeStart)) {
  2415. this.dateTimeStart = Math.floor(dateTimeStart.getTime()/1000);
  2416. } else {
  2417. this.dateTimeStart = dateTimeStart;
  2418. }
  2419. return this;
  2420. }
  2421. /**
  2422. * Set DateTime_End.
  2423. * @param {number|Date} dateTimeEnd
  2424. * @returns {CouponUpdate}
  2425. */
  2426. setDateTimeEnd(dateTimeEnd) {
  2427. if (util.isDate(dateTimeEnd)) {
  2428. this.dateTimeEnd = Math.floor(dateTimeEnd.getTime()/1000);
  2429. } else {
  2430. this.dateTimeEnd = dateTimeEnd;
  2431. }
  2432. return this;
  2433. }
  2434. /**
  2435. * Set Max_Use.
  2436. * @param {number} maxUse
  2437. * @returns {CouponUpdate}
  2438. */
  2439. setMaxUse(maxUse) {
  2440. this.maxUse = maxUse;
  2441. return this;
  2442. }
  2443. /**
  2444. * Set Max_Per.
  2445. * @param {number} maxPer
  2446. * @returns {CouponUpdate}
  2447. */
  2448. setMaxPer(maxPer) {
  2449. this.maxPer = maxPer;
  2450. return this;
  2451. }
  2452. /**
  2453. * Set Active.
  2454. * @param {boolean} active
  2455. * @returns {CouponUpdate}
  2456. */
  2457. setActive(active) {
  2458. this.active = active;
  2459. return this;
  2460. }
  2461. /**
  2462. * Reduce the request to a an object.
  2463. * @override
  2464. * @returns {Object}
  2465. */
  2466. toObject() {
  2467. var data = super.toObject();
  2468. if (!util.isNullOrUndefined(this.couponId)) {
  2469. data['Coupon_ID'] = this.couponId;
  2470. } else if (!util.isNullOrUndefined(this.editCoupon)) {
  2471. data['Edit_Coupon'] = this.editCoupon;
  2472. }
  2473. if (!util.isNullOrUndefined(this.couponCode)) {
  2474. data['Coupon_Code'] = this.couponCode;
  2475. }
  2476. if (!util.isNullOrUndefined(this.code)) {
  2477. data['Code'] = this.code;
  2478. }
  2479. if (!util.isNullOrUndefined(this.description)) {
  2480. data['Description'] = this.description;
  2481. }
  2482. if (!util.isNullOrUndefined(this.customerScope)) {
  2483. data['CustomerScope'] = this.customerScope;
  2484. }
  2485. if (!util.isNullOrUndefined(this.dateTimeStart)) {
  2486. data['DateTime_Start'] = this.dateTimeStart;
  2487. }
  2488. if (!util.isNullOrUndefined(this.dateTimeEnd)) {
  2489. data['DateTime_End'] = this.dateTimeEnd;
  2490. }
  2491. if (!util.isNullOrUndefined(this.maxUse)) {
  2492. data['Max_Use'] = this.maxUse;
  2493. }
  2494. if (!util.isNullOrUndefined(this.maxPer)) {
  2495. data['Max_Per'] = this.maxPer;
  2496. }
  2497. if (!util.isNullOrUndefined(this.active)) {
  2498. data['Active'] = this.active;
  2499. }
  2500. return data;
  2501. }
  2502. /**
  2503. * Create a response object from the response data.
  2504. * @override
  2505. * @returns {Response}
  2506. */
  2507. createResponse(data) {
  2508. return new responses.CouponUpdate(this, data);
  2509. }
  2510. }
  2511. /**
  2512. * Handles API Request CustomerList_Load_Query. Scope: Store.
  2513. * @see https://docs.miva.com/json-api/functions/customerlist_load_query
  2514. */
  2515. class CustomerListLoadQuery extends ListQueryRequest {
  2516. /**
  2517. * CustomerListLoadQuery Constructor.
  2518. * @param {?Client} client
  2519. */
  2520. constructor(client) {
  2521. super(client);
  2522. this.function = 'CustomerList_Load_Query';
  2523. this.scope = Request.REQUEST_SCOPE_STORE;
  2524. this.availableSearchFields = [
  2525. 'id',
  2526. 'login',
  2527. 'pw_email',
  2528. 'ship_fname',
  2529. 'ship_lname',
  2530. 'ship_email',
  2531. 'ship_comp',
  2532. 'ship_phone',
  2533. 'ship_fax',
  2534. 'ship_addr1',
  2535. 'ship_addr2',
  2536. 'ship_city',
  2537. 'ship_state',
  2538. 'ship_zip',
  2539. 'ship_cntry',
  2540. 'ship_res',
  2541. 'bill_fname',
  2542. 'bill_lname',
  2543. 'bill_email',
  2544. 'bill_comp',
  2545. 'bill_phone',
  2546. 'bill_fax',
  2547. 'bill_addr1',
  2548. 'bill_addr2',
  2549. 'bill_city',
  2550. 'bill_state',
  2551. 'bill_zip',
  2552. 'bill_cntry',
  2553. 'business_title',
  2554. 'note_count',
  2555. 'dt_created',
  2556. 'dt_login',
  2557. 'credit'
  2558. ];
  2559. this.availableSortFields = [
  2560. 'id',
  2561. 'login',
  2562. 'pw_email',
  2563. 'ship_fname',
  2564. 'ship_lname',
  2565. 'ship_email',
  2566. 'ship_comp',
  2567. 'ship_phone',
  2568. 'ship_fax',
  2569. 'ship_addr1',
  2570. 'ship_addr2',
  2571. 'ship_city',
  2572. 'ship_state',
  2573. 'ship_zip',
  2574. 'ship_cntry',
  2575. 'ship_res',
  2576. 'bill_fname',
  2577. 'bill_lname',
  2578. 'bill_email',
  2579. 'bill_comp',
  2580. 'bill_phone',
  2581. 'bill_fax',
  2582. 'bill_addr1',
  2583. 'bill_addr2',
  2584. 'bill_city',
  2585. 'bill_state',
  2586. 'bill_zip',
  2587. 'bill_cntry',
  2588. 'business_title',
  2589. 'note_count',
  2590. 'dt_created',
  2591. 'dt_login',
  2592. 'credit'
  2593. ];
  2594. }
  2595. /**
  2596. * Create a response object from the response data.
  2597. * @override
  2598. * @returns {Response}
  2599. */
  2600. createResponse(data) {
  2601. return new responses.CustomerListLoadQuery(this, data);
  2602. }
  2603. }
  2604. /**
  2605. * Handles API Request Customer_Delete. Scope: Store.
  2606. * @see https://docs.miva.com/json-api/functions/customer_delete
  2607. */
  2608. class CustomerDelete extends Request {
  2609. /**
  2610. * CustomerDelete Constructor.
  2611. * @param {?Client} client
  2612. * @param {?Customer} customer
  2613. */
  2614. constructor(client, customer = null) {
  2615. super(client);
  2616. this.function = 'Customer_Delete';
  2617. this.scope = Request.REQUEST_SCOPE_STORE;
  2618. this.customerId = null;
  2619. this.customerLogin = null;
  2620. this.editCustomer = null;
  2621. if (util.isInstanceOf(customer, models.Customer)) {
  2622. if (customer.getId()) {
  2623. this.setCustomerId(customer.getId());
  2624. } else if (customer.getLogin()) {
  2625. this.setEditCustomer(customer.getLogin());
  2626. }
  2627. }
  2628. }
  2629. /**
  2630. * Get Customer_ID.
  2631. * @returns {number}
  2632. */
  2633. getCustomerId() {
  2634. return this.customerId;
  2635. }
  2636. /**
  2637. * Get Customer_Login.
  2638. * @returns {string}
  2639. */
  2640. getCustomerLogin() {
  2641. return this.customerLogin;
  2642. }
  2643. /**
  2644. * Get Edit_Customer.
  2645. * @returns {string}
  2646. */
  2647. getEditCustomer() {
  2648. return this.editCustomer;
  2649. }
  2650. /**
  2651. * Set Customer_ID.
  2652. * @param {number} customerId
  2653. * @returns {CustomerDelete}
  2654. */
  2655. setCustomerId(customerId) {
  2656. this.customerId = customerId;
  2657. return this;
  2658. }
  2659. /**
  2660. * Set Customer_Login.
  2661. * @param {string} customerLogin
  2662. * @returns {CustomerDelete}
  2663. */
  2664. setCustomerLogin(customerLogin) {
  2665. this.customerLogin = customerLogin;
  2666. return this;
  2667. }
  2668. /**
  2669. * Set Edit_Customer.
  2670. * @param {string} editCustomer
  2671. * @returns {CustomerDelete}
  2672. */
  2673. setEditCustomer(editCustomer) {
  2674. this.editCustomer = editCustomer;
  2675. return this;
  2676. }
  2677. /**
  2678. * Reduce the request to a an object.
  2679. * @override
  2680. * @returns {Object}
  2681. */
  2682. toObject() {
  2683. var data = super.toObject();
  2684. if (!util.isNullOrUndefined(this.customerId)) {
  2685. data['Customer_ID'] = this.customerId;
  2686. } else if (!util.isNullOrUndefined(this.customerLogin)) {
  2687. data['Customer_Login'] = this.customerLogin;
  2688. } else if (!util.isNullOrUndefined(this.editCustomer)) {
  2689. data['Edit_Customer'] = this.editCustomer;
  2690. }
  2691. return data;
  2692. }
  2693. /**
  2694. * Create a response object from the response data.
  2695. * @override
  2696. * @returns {Response}
  2697. */
  2698. createResponse(data) {
  2699. return new responses.CustomerDelete(this, data);
  2700. }
  2701. }
  2702. /**
  2703. * Handles API Request Customer_Insert. Scope: Store.
  2704. * @see https://docs.miva.com/json-api/functions/customer_insert
  2705. */
  2706. class CustomerInsert extends Request {
  2707. /**
  2708. * CustomerInsert Constructor.
  2709. * @param {?Client} client
  2710. * @param {?Customer} customer
  2711. */
  2712. constructor(client, customer = null) {
  2713. super(client);
  2714. this.function = 'Customer_Insert';
  2715. this.scope = Request.REQUEST_SCOPE_STORE;
  2716. this.customerLogin = null;
  2717. this.customerPasswordEmail = null;
  2718. this.customerPassword = null;
  2719. this.customerShipResidential = null;
  2720. this.customerShipFirstName = null;
  2721. this.customerShipLastName = null;
  2722. this.customerShipEmail = null;
  2723. this.customerShipCompany = null;
  2724. this.customerShipPhone = null;
  2725. this.customerShipFax = null;
  2726. this.customerShipAddress1 = null;
  2727. this.customerShipAddress2 = null;
  2728. this.customerShipCity = null;
  2729. this.customerShipState = null;
  2730. this.customerShipZip = null;
  2731. this.customerShipCountry = null;
  2732. this.customerBillFirstName = null;
  2733. this.customerBillLastName = null;
  2734. this.customerBillEmail = null;
  2735. this.customerBillCompany = null;
  2736. this.customerBillPhone = null;
  2737. this.customerBillFax = null;
  2738. this.customerBillAddress1 = null;
  2739. this.customerBillAddress2 = null;
  2740. this.customerBillCity = null;
  2741. this.customerBillState = null;
  2742. this.customerBillZip = null;
  2743. this.customerBillCountry = null;
  2744. this.customerTaxExempt = null;
  2745. this.customerBusinessAccount = null;
  2746. this.customFieldValues = new models.CustomFieldValues();
  2747. if (util.isInstanceOf(customer, models.Customer)) {
  2748. this.setCustomerLogin(customer.getLogin());
  2749. this.setCustomerPasswordEmail(customer.getPasswordEmail());
  2750. this.setCustomerShipResidential(customer.getShippingResidential());
  2751. this.setCustomerShipFirstName(customer.getShipFirstName());
  2752. this.setCustomerShipLastName(customer.getShipLastName());
  2753. this.setCustomerShipEmail(customer.getShipEmail());
  2754. this.setCustomerShipCompany(customer.getShipCompany());
  2755. this.setCustomerShipPhone(customer.getShipPhone());
  2756. this.setCustomerShipFax(customer.getShipFax());
  2757. this.setCustomerShipAddress1(customer.getShipAddress1());
  2758. this.setCustomerShipAddress2(customer.getShipAddress2());
  2759. this.setCustomerShipCity(customer.getShipCity());
  2760. this.setCustomerShipState(customer.getShipState());
  2761. this.setCustomerShipZip(customer.getShipZip());
  2762. this.setCustomerShipCountry(customer.getShipCountry());
  2763. this.setCustomerBillFirstName(customer.getBillFirstName());
  2764. this.setCustomerBillLastName(customer.getBillLastName());
  2765. this.setCustomerBillEmail(customer.getBillEmail());
  2766. this.setCustomerBillCompany(customer.getBillCompany());
  2767. this.setCustomerBillPhone(customer.getBillPhone());
  2768. this.setCustomerBillFax(customer.getBillFax());
  2769. this.setCustomerBillAddress1(customer.getBillAddress1());
  2770. this.setCustomerBillAddress2(customer.getBillAddress2());
  2771. this.setCustomerBillCity(customer.getBillCity());
  2772. this.setCustomerBillState(customer.getBillState());
  2773. this.setCustomerBillZip(customer.getBillZip());
  2774. this.setCustomerBillCountry(customer.getBillCountry());
  2775. this.setCustomerBusinessAccount(customer.getBusinessTitle());
  2776. if (customer.getCustomFieldValues()) {
  2777. this.setCustomFieldValues(customer.getCustomFieldValues());
  2778. }
  2779. }
  2780. }
  2781. /**
  2782. * Get Customer_Login.
  2783. * @returns {string}
  2784. */
  2785. getCustomerLogin() {
  2786. return this.customerLogin;
  2787. }
  2788. /**
  2789. * Get Customer_PasswordEmail.
  2790. * @returns {string}
  2791. */
  2792. getCustomerPasswordEmail() {
  2793. return this.customerPasswordEmail;
  2794. }
  2795. /**
  2796. * Get Customer_Password.
  2797. * @returns {string}
  2798. */
  2799. getCustomerPassword() {
  2800. return this.customerPassword;
  2801. }
  2802. /**
  2803. * Get Customer_ShipResidential.
  2804. * @returns {boolean}
  2805. */
  2806. getCustomerShipResidential() {
  2807. return this.customerShipResidential;
  2808. }
  2809. /**
  2810. * Get Customer_ShipFirstName.
  2811. * @returns {string}
  2812. */
  2813. getCustomerShipFirstName() {
  2814. return this.customerShipFirstName;
  2815. }
  2816. /**
  2817. * Get Customer_ShipLastName.
  2818. * @returns {string}
  2819. */
  2820. getCustomerShipLastName() {
  2821. return this.customerShipLastName;
  2822. }
  2823. /**
  2824. * Get Customer_ShipEmail.
  2825. * @returns {string}
  2826. */
  2827. getCustomerShipEmail() {
  2828. return this.customerShipEmail;
  2829. }
  2830. /**
  2831. * Get Customer_ShipCompany.
  2832. * @returns {string}
  2833. */
  2834. getCustomerShipCompany() {
  2835. return this.customerShipCompany;
  2836. }
  2837. /**
  2838. * Get Customer_ShipPhone.
  2839. * @returns {string}
  2840. */
  2841. getCustomerShipPhone() {
  2842. return this.customerShipPhone;
  2843. }
  2844. /**
  2845. * Get Customer_ShipFax.
  2846. * @returns {string}
  2847. */
  2848. getCustomerShipFax() {
  2849. return this.customerShipFax;
  2850. }
  2851. /**
  2852. * Get Customer_ShipAddress1.
  2853. * @returns {string}
  2854. */
  2855. getCustomerShipAddress1() {
  2856. return this.customerShipAddress1;
  2857. }
  2858. /**
  2859. * Get Customer_ShipAddress2.
  2860. * @returns {string}
  2861. */
  2862. getCustomerShipAddress2() {
  2863. return this.customerShipAddress2;
  2864. }
  2865. /**
  2866. * Get Customer_ShipCity.
  2867. * @returns {string}
  2868. */
  2869. getCustomerShipCity() {
  2870. return this.customerShipCity;
  2871. }
  2872. /**
  2873. * Get Customer_ShipState.
  2874. * @returns {string}
  2875. */
  2876. getCustomerShipState() {
  2877. return this.customerShipState;
  2878. }
  2879. /**
  2880. * Get Customer_ShipZip.
  2881. * @returns {string}
  2882. */
  2883. getCustomerShipZip() {
  2884. return this.customerShipZip;
  2885. }
  2886. /**
  2887. * Get Customer_ShipCountry.
  2888. * @returns {string}
  2889. */
  2890. getCustomerShipCountry() {
  2891. return this.customerShipCountry;
  2892. }
  2893. /**
  2894. * Get Customer_BillFirstName.
  2895. * @returns {string}
  2896. */
  2897. getCustomerBillFirstName() {
  2898. return this.customerBillFirstName;
  2899. }
  2900. /**
  2901. * Get Customer_BillLastName.
  2902. * @returns {string}
  2903. */
  2904. getCustomerBillLastName() {
  2905. return this.customerBillLastName;
  2906. }
  2907. /**
  2908. * Get Customer_BillEmail.
  2909. * @returns {string}
  2910. */
  2911. getCustomerBillEmail() {
  2912. return this.customerBillEmail;
  2913. }
  2914. /**
  2915. * Get Customer_BillCompany.
  2916. * @returns {string}
  2917. */
  2918. getCustomerBillCompany() {
  2919. return this.customerBillCompany;
  2920. }
  2921. /**
  2922. * Get Customer_BillPhone.
  2923. * @returns {string}
  2924. */
  2925. getCustomerBillPhone() {
  2926. return this.customerBillPhone;
  2927. }
  2928. /**
  2929. * Get Customer_BillFax.
  2930. * @returns {string}
  2931. */
  2932. getCustomerBillFax() {
  2933. return this.customerBillFax;
  2934. }
  2935. /**
  2936. * Get Customer_BillAddress1.
  2937. * @returns {string}
  2938. */
  2939. getCustomerBillAddress1() {
  2940. return this.customerBillAddress1;
  2941. }
  2942. /**
  2943. * Get Customer_BillAddress2.
  2944. * @returns {string}
  2945. */
  2946. getCustomerBillAddress2() {
  2947. return this.customerBillAddress2;
  2948. }
  2949. /**
  2950. * Get Customer_BillCity.
  2951. * @returns {string}
  2952. */
  2953. getCustomerBillCity() {
  2954. return this.customerBillCity;
  2955. }
  2956. /**
  2957. * Get Customer_BillState.
  2958. * @returns {string}
  2959. */
  2960. getCustomerBillState() {
  2961. return this.customerBillState;
  2962. }
  2963. /**
  2964. * Get Customer_BillZip.
  2965. * @returns {string}
  2966. */
  2967. getCustomerBillZip() {
  2968. return this.customerBillZip;
  2969. }
  2970. /**
  2971. * Get Customer_BillCountry.
  2972. * @returns {string}
  2973. */
  2974. getCustomerBillCountry() {
  2975. return this.customerBillCountry;
  2976. }
  2977. /**
  2978. * Get Customer_Tax_Exempt.
  2979. * @returns {boolean}
  2980. */
  2981. getCustomerTaxExempt() {
  2982. return this.customerTaxExempt;
  2983. }
  2984. /**
  2985. * Get Customer_BusinessAccount.
  2986. * @returns {string}
  2987. */
  2988. getCustomerBusinessAccount() {
  2989. return this.customerBusinessAccount;
  2990. }
  2991. /**
  2992. * Get CustomField_Values.
  2993. * @returns {?CustomFieldValues}
  2994. */
  2995. getCustomFieldValues() {
  2996. return this.customFieldValues;
  2997. }
  2998. /**
  2999. * Set Customer_Login.
  3000. * @param {string} customerLogin
  3001. * @returns {CustomerInsert}
  3002. */
  3003. setCustomerLogin(customerLogin) {
  3004. this.customerLogin = customerLogin;
  3005. return this;
  3006. }
  3007. /**
  3008. * Set Customer_PasswordEmail.
  3009. * @param {string} customerPasswordEmail
  3010. * @returns {CustomerInsert}
  3011. */
  3012. setCustomerPasswordEmail(customerPasswordEmail) {
  3013. this.customerPasswordEmail = customerPasswordEmail;
  3014. return this;
  3015. }
  3016. /**
  3017. * Set Customer_Password.
  3018. * @param {string} customerPassword
  3019. * @returns {CustomerInsert}
  3020. */
  3021. setCustomerPassword(customerPassword) {
  3022. this.customerPassword = customerPassword;
  3023. return this;
  3024. }
  3025. /**
  3026. * Set Customer_ShipResidential.
  3027. * @param {boolean} customerShipResidential
  3028. * @returns {CustomerInsert}
  3029. */
  3030. setCustomerShipResidential(customerShipResidential) {
  3031. this.customerShipResidential = customerShipResidential;
  3032. return this;
  3033. }
  3034. /**
  3035. * Set Customer_ShipFirstName.
  3036. * @param {string} customerShipFirstName
  3037. * @returns {CustomerInsert}
  3038. */
  3039. setCustomerShipFirstName(customerShipFirstName) {
  3040. this.customerShipFirstName = customerShipFirstName;
  3041. return this;
  3042. }
  3043. /**
  3044. * Set Customer_ShipLastName.
  3045. * @param {string} customerShipLastName
  3046. * @returns {CustomerInsert}
  3047. */
  3048. setCustomerShipLastName(customerShipLastName) {
  3049. this.customerShipLastName = customerShipLastName;
  3050. return this;
  3051. }
  3052. /**
  3053. * Set Customer_ShipEmail.
  3054. * @param {string} customerShipEmail
  3055. * @returns {CustomerInsert}
  3056. */
  3057. setCustomerShipEmail(customerShipEmail) {
  3058. this.customerShipEmail = customerShipEmail;
  3059. return this;
  3060. }
  3061. /**
  3062. * Set Customer_ShipCompany.
  3063. * @param {string} customerShipCompany
  3064. * @returns {CustomerInsert}
  3065. */
  3066. setCustomerShipCompany(customerShipCompany) {
  3067. this.customerShipCompany = customerShipCompany;
  3068. return this;
  3069. }
  3070. /**
  3071. * Set Customer_ShipPhone.
  3072. * @param {string} customerShipPhone
  3073. * @returns {CustomerInsert}
  3074. */
  3075. setCustomerShipPhone(customerShipPhone) {
  3076. this.customerShipPhone = customerShipPhone;
  3077. return this;
  3078. }
  3079. /**
  3080. * Set Customer_ShipFax.
  3081. * @param {string} customerShipFax
  3082. * @returns {CustomerInsert}
  3083. */
  3084. setCustomerShipFax(customerShipFax) {
  3085. this.customerShipFax = customerShipFax;
  3086. return this;
  3087. }
  3088. /**
  3089. * Set Customer_ShipAddress1.
  3090. * @param {string} customerShipAddress1
  3091. * @returns {CustomerInsert}
  3092. */
  3093. setCustomerShipAddress1(customerShipAddress1) {
  3094. this.customerShipAddress1 = customerShipAddress1;
  3095. return this;
  3096. }
  3097. /**
  3098. * Set Customer_ShipAddress2.
  3099. * @param {string} customerShipAddress2
  3100. * @returns {CustomerInsert}
  3101. */
  3102. setCustomerShipAddress2(customerShipAddress2) {
  3103. this.customerShipAddress2 = customerShipAddress2;
  3104. return this;
  3105. }
  3106. /**
  3107. * Set Customer_ShipCity.
  3108. * @param {string} customerShipCity
  3109. * @returns {CustomerInsert}
  3110. */
  3111. setCustomerShipCity(customerShipCity) {
  3112. this.customerShipCity = customerShipCity;
  3113. return this;
  3114. }
  3115. /**
  3116. * Set Customer_ShipState.
  3117. * @param {string} customerShipState
  3118. * @returns {CustomerInsert}
  3119. */
  3120. setCustomerShipState(customerShipState) {
  3121. this.customerShipState = customerShipState;
  3122. return this;
  3123. }
  3124. /**
  3125. * Set Customer_ShipZip.
  3126. * @param {string} customerShipZip
  3127. * @returns {CustomerInsert}
  3128. */
  3129. setCustomerShipZip(customerShipZip) {
  3130. this.customerShipZip = customerShipZip;
  3131. return this;
  3132. }
  3133. /**
  3134. * Set Customer_ShipCountry.
  3135. * @param {string} customerShipCountry
  3136. * @returns {CustomerInsert}
  3137. */
  3138. setCustomerShipCountry(customerShipCountry) {
  3139. this.customerShipCountry = customerShipCountry;
  3140. return this;
  3141. }
  3142. /**
  3143. * Set Customer_BillFirstName.
  3144. * @param {string} customerBillFirstName
  3145. * @returns {CustomerInsert}
  3146. */
  3147. setCustomerBillFirstName(customerBillFirstName) {
  3148. this.customerBillFirstName = customerBillFirstName;
  3149. return this;
  3150. }
  3151. /**
  3152. * Set Customer_BillLastName.
  3153. * @param {string} customerBillLastName
  3154. * @returns {CustomerInsert}
  3155. */
  3156. setCustomerBillLastName(customerBillLastName) {
  3157. this.customerBillLastName = customerBillLastName;
  3158. return this;
  3159. }
  3160. /**
  3161. * Set Customer_BillEmail.
  3162. * @param {string} customerBillEmail
  3163. * @returns {CustomerInsert}
  3164. */
  3165. setCustomerBillEmail(customerBillEmail) {
  3166. this.customerBillEmail = customerBillEmail;
  3167. return this;
  3168. }
  3169. /**
  3170. * Set Customer_BillCompany.
  3171. * @param {string} customerBillCompany
  3172. * @returns {CustomerInsert}
  3173. */
  3174. setCustomerBillCompany(customerBillCompany) {
  3175. this.customerBillCompany = customerBillCompany;
  3176. return this;
  3177. }
  3178. /**
  3179. * Set Customer_BillPhone.
  3180. * @param {string} customerBillPhone
  3181. * @returns {CustomerInsert}
  3182. */
  3183. setCustomerBillPhone(customerBillPhone) {
  3184. this.customerBillPhone = customerBillPhone;
  3185. return this;
  3186. }
  3187. /**
  3188. * Set Customer_BillFax.
  3189. * @param {string} customerBillFax
  3190. * @returns {CustomerInsert}
  3191. */
  3192. setCustomerBillFax(customerBillFax) {
  3193. this.customerBillFax = customerBillFax;
  3194. return this;
  3195. }
  3196. /**
  3197. * Set Customer_BillAddress1.
  3198. * @param {string} customerBillAddress1
  3199. * @returns {CustomerInsert}
  3200. */
  3201. setCustomerBillAddress1(customerBillAddress1) {
  3202. this.customerBillAddress1 = customerBillAddress1;
  3203. return this;
  3204. }
  3205. /**
  3206. * Set Customer_BillAddress2.
  3207. * @param {string} customerBillAddress2
  3208. * @returns {CustomerInsert}
  3209. */
  3210. setCustomerBillAddress2(customerBillAddress2) {
  3211. this.customerBillAddress2 = customerBillAddress2;
  3212. return this;
  3213. }
  3214. /**
  3215. * Set Customer_BillCity.
  3216. * @param {string} customerBillCity
  3217. * @returns {CustomerInsert}
  3218. */
  3219. setCustomerBillCity(customerBillCity) {
  3220. this.customerBillCity = customerBillCity;
  3221. return this;
  3222. }
  3223. /**
  3224. * Set Customer_BillState.
  3225. * @param {string} customerBillState
  3226. * @returns {CustomerInsert}
  3227. */
  3228. setCustomerBillState(customerBillState) {
  3229. this.customerBillState = customerBillState;
  3230. return this;
  3231. }
  3232. /**
  3233. * Set Customer_BillZip.
  3234. * @param {string} customerBillZip
  3235. * @returns {CustomerInsert}
  3236. */
  3237. setCustomerBillZip(customerBillZip) {
  3238. this.customerBillZip = customerBillZip;
  3239. return this;
  3240. }
  3241. /**
  3242. * Set Customer_BillCountry.
  3243. * @param {string} customerBillCountry
  3244. * @returns {CustomerInsert}
  3245. */
  3246. setCustomerBillCountry(customerBillCountry) {
  3247. this.customerBillCountry = customerBillCountry;
  3248. return this;
  3249. }
  3250. /**
  3251. * Set Customer_Tax_Exempt.
  3252. * @param {boolean} customerTaxExempt
  3253. * @returns {CustomerInsert}
  3254. */
  3255. setCustomerTaxExempt(customerTaxExempt) {
  3256. this.customerTaxExempt = customerTaxExempt;
  3257. return this;
  3258. }
  3259. /**
  3260. * Set Customer_BusinessAccount.
  3261. * @param {string} customerBusinessAccount
  3262. * @returns {CustomerInsert}
  3263. */
  3264. setCustomerBusinessAccount(customerBusinessAccount) {
  3265. this.customerBusinessAccount = customerBusinessAccount;
  3266. return this;
  3267. }
  3268. /**
  3269. * Set CustomField_Values.
  3270. * @param {?CustomFieldValues} customFieldValues
  3271. * @throws {Error}
  3272. * @returns {CustomerInsert}
  3273. */
  3274. setCustomFieldValues(customFieldValues) {
  3275. if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues) && util.isObject(customFieldValues)) {
  3276. customFieldValues = new models.CustomFieldValues(customFieldValues);
  3277. } else if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues)) {
  3278. throw new Error(util.format('Expected instance of CustomFieldValues or an Object but got %s',
  3279. typeof customFieldValues));
  3280. }
  3281. this.customFieldValues = customFieldValues;
  3282. return this;
  3283. }
  3284. /**
  3285. * Reduce the request to a an object.
  3286. * @override
  3287. * @returns {Object}
  3288. */
  3289. toObject() {
  3290. var data = super.toObject();
  3291. data['Customer_Login'] = this.customerLogin;
  3292. data['Customer_PasswordEmail'] = this.customerPasswordEmail;
  3293. data['Customer_Password'] = this.customerPassword;
  3294. if (!util.isNullOrUndefined(this.customerShipResidential)) {
  3295. data['Customer_ShipResidential'] = this.customerShipResidential;
  3296. }
  3297. if (!util.isNullOrUndefined(this.customerShipFirstName)) {
  3298. data['Customer_ShipFirstName'] = this.customerShipFirstName;
  3299. }
  3300. if (!util.isNullOrUndefined(this.customerShipLastName)) {
  3301. data['Customer_ShipLastName'] = this.customerShipLastName;
  3302. }
  3303. if (!util.isNullOrUndefined(this.customerShipEmail)) {
  3304. data['Customer_ShipEmail'] = this.customerShipEmail;
  3305. }
  3306. if (!util.isNullOrUndefined(this.customerShipCompany)) {
  3307. data['Customer_ShipCompany'] = this.customerShipCompany;
  3308. }
  3309. if (!util.isNullOrUndefined(this.customerShipPhone)) {
  3310. data['Customer_ShipPhone'] = this.customerShipPhone;
  3311. }
  3312. if (!util.isNullOrUndefined(this.customerShipFax)) {
  3313. data['Customer_ShipFax'] = this.customerShipFax;
  3314. }
  3315. if (!util.isNullOrUndefined(this.customerShipAddress1)) {
  3316. data['Customer_ShipAddress1'] = this.customerShipAddress1;
  3317. }
  3318. if (!util.isNullOrUndefined(this.customerShipAddress2)) {
  3319. data['Customer_ShipAddress2'] = this.customerShipAddress2;
  3320. }
  3321. if (!util.isNullOrUndefined(this.customerShipCity)) {
  3322. data['Customer_ShipCity'] = this.customerShipCity;
  3323. }
  3324. if (!util.isNullOrUndefined(this.customerShipState)) {
  3325. data['Customer_ShipState'] = this.customerShipState;
  3326. }
  3327. if (!util.isNullOrUndefined(this.customerShipZip)) {
  3328. data['Customer_ShipZip'] = this.customerShipZip;
  3329. }
  3330. if (!util.isNullOrUndefined(this.customerShipCountry)) {
  3331. data['Customer_ShipCountry'] = this.customerShipCountry;
  3332. }
  3333. if (!util.isNullOrUndefined(this.customerBillFirstName)) {
  3334. data['Customer_BillFirstName'] = this.customerBillFirstName;
  3335. }
  3336. if (!util.isNullOrUndefined(this.customerBillLastName)) {
  3337. data['Customer_BillLastName'] = this.customerBillLastName;
  3338. }
  3339. if (!util.isNullOrUndefined(this.customerBillEmail)) {
  3340. data['Customer_BillEmail'] = this.customerBillEmail;
  3341. }
  3342. if (!util.isNullOrUndefined(this.customerBillCompany)) {
  3343. data['Customer_BillCompany'] = this.customerBillCompany;
  3344. }
  3345. if (!util.isNullOrUndefined(this.customerBillPhone)) {
  3346. data['Customer_BillPhone'] = this.customerBillPhone;
  3347. }
  3348. if (!util.isNullOrUndefined(this.customerBillFax)) {
  3349. data['Customer_BillFax'] = this.customerBillFax;
  3350. }
  3351. if (!util.isNullOrUndefined(this.customerBillAddress1)) {
  3352. data['Customer_BillAddress1'] = this.customerBillAddress1;
  3353. }
  3354. if (!util.isNullOrUndefined(this.customerBillAddress2)) {
  3355. data['Customer_BillAddress2'] = this.customerBillAddress2;
  3356. }
  3357. if (!util.isNullOrUndefined(this.customerBillCity)) {
  3358. data['Customer_BillCity'] = this.customerBillCity;
  3359. }
  3360. if (!util.isNullOrUndefined(this.customerBillState)) {
  3361. data['Customer_BillState'] = this.customerBillState;
  3362. }
  3363. if (!util.isNullOrUndefined(this.customerBillZip)) {
  3364. data['Customer_BillZip'] = this.customerBillZip;
  3365. }
  3366. if (!util.isNullOrUndefined(this.customerBillCountry)) {
  3367. data['Customer_BillCountry'] = this.customerBillCountry;
  3368. }
  3369. if (!util.isNullOrUndefined(this.customerTaxExempt)) {
  3370. data['Customer_Tax_Exempt'] = this.customerTaxExempt;
  3371. }
  3372. if (!util.isNullOrUndefined(this.customerBusinessAccount)) {
  3373. data['Customer_BusinessAccount'] = this.customerBusinessAccount;
  3374. }
  3375. if (this.customFieldValues && util.isObject(this.customFieldValues)) {
  3376. data['CustomField_Values'] = this.customFieldValues.toObject();
  3377. }
  3378. return data;
  3379. }
  3380. /**
  3381. * Create a response object from the response data.
  3382. * @override
  3383. * @returns {Response}
  3384. */
  3385. createResponse(data) {
  3386. return new responses.CustomerInsert(this, data);
  3387. }
  3388. }
  3389. /**
  3390. * Handles API Request Customer_Update. Scope: Store.
  3391. * @see https://docs.miva.com/json-api/functions/customer_update
  3392. */
  3393. class CustomerUpdate extends Request {
  3394. /**
  3395. * CustomerUpdate Constructor.
  3396. * @param {?Client} client
  3397. * @param {?Customer} customer
  3398. */
  3399. constructor(client, customer = null) {
  3400. super(client);
  3401. this.function = 'Customer_Update';
  3402. this.scope = Request.REQUEST_SCOPE_STORE;
  3403. this.customerId = null;
  3404. this.editCustomer = null;
  3405. this.customerLogin = null;
  3406. this.customerPasswordEmail = null;
  3407. this.customerPassword = null;
  3408. this.customerShipResidential = null;
  3409. this.customerShipFirstName = null;
  3410. this.customerShipLastName = null;
  3411. this.customerShipEmail = null;
  3412. this.customerShipCompany = null;
  3413. this.customerShipPhone = null;
  3414. this.customerShipFax = null;
  3415. this.customerShipAddress1 = null;
  3416. this.customerShipAddress2 = null;
  3417. this.customerShipCity = null;
  3418. this.customerShipState = null;
  3419. this.customerShipZip = null;
  3420. this.customerShipCountry = null;
  3421. this.customerBillFirstName = null;
  3422. this.customerBillLastName = null;
  3423. this.customerBillEmail = null;
  3424. this.customerBillCompany = null;
  3425. this.customerBillPhone = null;
  3426. this.customerBillFax = null;
  3427. this.customerBillAddress1 = null;
  3428. this.customerBillAddress2 = null;
  3429. this.customerBillCity = null;
  3430. this.customerBillState = null;
  3431. this.customerBillZip = null;
  3432. this.customerBillCountry = null;
  3433. this.customerTaxExempt = null;
  3434. this.customerBusinessAccount = null;
  3435. this.customFieldValues = new models.CustomFieldValues();
  3436. if (util.isInstanceOf(customer, models.Customer)) {
  3437. if (customer.getId()) {
  3438. this.setCustomerId(customer.getId());
  3439. } else if (customer.getLogin()) {
  3440. this.setEditCustomer(customer.getLogin());
  3441. }
  3442. this.setCustomerLogin(customer.getLogin());
  3443. this.setCustomerPasswordEmail(customer.getPasswordEmail());
  3444. this.setCustomerShipResidential(customer.getShippingResidential());
  3445. this.setCustomerShipFirstName(customer.getShipFirstName());
  3446. this.setCustomerShipLastName(customer.getShipLastName());
  3447. this.setCustomerShipEmail(customer.getShipEmail());
  3448. this.setCustomerShipCompany(customer.getShipCompany());
  3449. this.setCustomerShipPhone(customer.getShipPhone());
  3450. this.setCustomerShipFax(customer.getShipFax());
  3451. this.setCustomerShipAddress1(customer.getShipAddress1());
  3452. this.setCustomerShipAddress2(customer.getShipAddress2());
  3453. this.setCustomerShipCity(customer.getShipCity());
  3454. this.setCustomerShipState(customer.getShipState());
  3455. this.setCustomerShipZip(customer.getShipZip());
  3456. this.setCustomerShipCountry(customer.getShipCountry());
  3457. this.setCustomerBillFirstName(customer.getBillFirstName());
  3458. this.setCustomerBillLastName(customer.getBillLastName());
  3459. this.setCustomerBillEmail(customer.getBillEmail());
  3460. this.setCustomerBillCompany(customer.getBillCompany());
  3461. this.setCustomerBillPhone(customer.getBillPhone());
  3462. this.setCustomerBillFax(customer.getBillFax());
  3463. this.setCustomerBillAddress1(customer.getBillAddress1());
  3464. this.setCustomerBillAddress2(customer.getBillAddress2());
  3465. this.setCustomerBillCity(customer.getBillCity());
  3466. this.setCustomerBillState(customer.getBillState());
  3467. this.setCustomerBillZip(customer.getBillZip());
  3468. this.setCustomerBillCountry(customer.getBillCountry());
  3469. this.setCustomerBusinessAccount(customer.getBusinessTitle());
  3470. if (customer.getCustomFieldValues()) {
  3471. this.setCustomFieldValues(customer.getCustomFieldValues());
  3472. }
  3473. }
  3474. }
  3475. /**
  3476. * Get Customer_ID.
  3477. * @returns {number}
  3478. */
  3479. getCustomerId() {
  3480. return this.customerId;
  3481. }
  3482. /**
  3483. * Get Edit_Customer.
  3484. * @returns {string}
  3485. */
  3486. getEditCustomer() {
  3487. return this.editCustomer;
  3488. }
  3489. /**
  3490. * Get Customer_Login.
  3491. * @returns {string}
  3492. */
  3493. getCustomerLogin() {
  3494. return this.customerLogin;
  3495. }
  3496. /**
  3497. * Get Customer_PasswordEmail.
  3498. * @returns {string}
  3499. */
  3500. getCustomerPasswordEmail() {
  3501. return this.customerPasswordEmail;
  3502. }
  3503. /**
  3504. * Get Customer_Password.
  3505. * @returns {string}
  3506. */
  3507. getCustomerPassword() {
  3508. return this.customerPassword;
  3509. }
  3510. /**
  3511. * Get Customer_ShipResidential.
  3512. * @returns {boolean}
  3513. */
  3514. getCustomerShipResidential() {
  3515. return this.customerShipResidential;
  3516. }
  3517. /**
  3518. * Get Customer_ShipFirstName.
  3519. * @returns {string}
  3520. */
  3521. getCustomerShipFirstName() {
  3522. return this.customerShipFirstName;
  3523. }
  3524. /**
  3525. * Get Customer_ShipLastName.
  3526. * @returns {string}
  3527. */
  3528. getCustomerShipLastName() {
  3529. return this.customerShipLastName;
  3530. }
  3531. /**
  3532. * Get Customer_ShipEmail.
  3533. * @returns {string}
  3534. */
  3535. getCustomerShipEmail() {
  3536. return this.customerShipEmail;
  3537. }
  3538. /**
  3539. * Get Customer_ShipCompany.
  3540. * @returns {string}
  3541. */
  3542. getCustomerShipCompany() {
  3543. return this.customerShipCompany;
  3544. }
  3545. /**
  3546. * Get Customer_ShipPhone.
  3547. * @returns {string}
  3548. */
  3549. getCustomerShipPhone() {
  3550. return this.customerShipPhone;
  3551. }
  3552. /**
  3553. * Get Customer_ShipFax.
  3554. * @returns {string}
  3555. */
  3556. getCustomerShipFax() {
  3557. return this.customerShipFax;
  3558. }
  3559. /**
  3560. * Get Customer_ShipAddress1.
  3561. * @returns {string}
  3562. */
  3563. getCustomerShipAddress1() {
  3564. return this.customerShipAddress1;
  3565. }
  3566. /**
  3567. * Get Customer_ShipAddress2.
  3568. * @returns {string}
  3569. */
  3570. getCustomerShipAddress2() {
  3571. return this.customerShipAddress2;
  3572. }
  3573. /**
  3574. * Get Customer_ShipCity.
  3575. * @returns {string}
  3576. */
  3577. getCustomerShipCity() {
  3578. return this.customerShipCity;
  3579. }
  3580. /**
  3581. * Get Customer_ShipState.
  3582. * @returns {string}
  3583. */
  3584. getCustomerShipState() {
  3585. return this.customerShipState;
  3586. }
  3587. /**
  3588. * Get Customer_ShipZip.
  3589. * @returns {string}
  3590. */
  3591. getCustomerShipZip() {
  3592. return this.customerShipZip;
  3593. }
  3594. /**
  3595. * Get Customer_ShipCountry.
  3596. * @returns {string}
  3597. */
  3598. getCustomerShipCountry() {
  3599. return this.customerShipCountry;
  3600. }
  3601. /**
  3602. * Get Customer_BillFirstName.
  3603. * @returns {string}
  3604. */
  3605. getCustomerBillFirstName() {
  3606. return this.customerBillFirstName;
  3607. }
  3608. /**
  3609. * Get Customer_BillLastName.
  3610. * @returns {string}
  3611. */
  3612. getCustomerBillLastName() {
  3613. return this.customerBillLastName;
  3614. }
  3615. /**
  3616. * Get Customer_BillEmail.
  3617. * @returns {string}
  3618. */
  3619. getCustomerBillEmail() {
  3620. return this.customerBillEmail;
  3621. }
  3622. /**
  3623. * Get Customer_BillCompany.
  3624. * @returns {string}
  3625. */
  3626. getCustomerBillCompany() {
  3627. return this.customerBillCompany;
  3628. }
  3629. /**
  3630. * Get Customer_BillPhone.
  3631. * @returns {string}
  3632. */
  3633. getCustomerBillPhone() {
  3634. return this.customerBillPhone;
  3635. }
  3636. /**
  3637. * Get Customer_BillFax.
  3638. * @returns {string}
  3639. */
  3640. getCustomerBillFax() {
  3641. return this.customerBillFax;
  3642. }
  3643. /**
  3644. * Get Customer_BillAddress1.
  3645. * @returns {string}
  3646. */
  3647. getCustomerBillAddress1() {
  3648. return this.customerBillAddress1;
  3649. }
  3650. /**
  3651. * Get Customer_BillAddress2.
  3652. * @returns {string}
  3653. */
  3654. getCustomerBillAddress2() {
  3655. return this.customerBillAddress2;
  3656. }
  3657. /**
  3658. * Get Customer_BillCity.
  3659. * @returns {string}
  3660. */
  3661. getCustomerBillCity() {
  3662. return this.customerBillCity;
  3663. }
  3664. /**
  3665. * Get Customer_BillState.
  3666. * @returns {string}
  3667. */
  3668. getCustomerBillState() {
  3669. return this.customerBillState;
  3670. }
  3671. /**
  3672. * Get Customer_BillZip.
  3673. * @returns {string}
  3674. */
  3675. getCustomerBillZip() {
  3676. return this.customerBillZip;
  3677. }
  3678. /**
  3679. * Get Customer_BillCountry.
  3680. * @returns {string}
  3681. */
  3682. getCustomerBillCountry() {
  3683. return this.customerBillCountry;
  3684. }
  3685. /**
  3686. * Get Customer_Tax_Exempt.
  3687. * @returns {string}
  3688. */
  3689. getCustomerTaxExempt() {
  3690. return this.customerTaxExempt;
  3691. }
  3692. /**
  3693. * Get Customer_BusinessAccount.
  3694. * @returns {string}
  3695. */
  3696. getCustomerBusinessAccount() {
  3697. return this.customerBusinessAccount;
  3698. }
  3699. /**
  3700. * Get CustomField_Values.
  3701. * @returns {?CustomFieldValues}
  3702. */
  3703. getCustomFieldValues() {
  3704. return this.customFieldValues;
  3705. }
  3706. /**
  3707. * Set Customer_ID.
  3708. * @param {number} customerId
  3709. * @returns {CustomerUpdate}
  3710. */
  3711. setCustomerId(customerId) {
  3712. this.customerId = customerId;
  3713. return this;
  3714. }
  3715. /**
  3716. * Set Edit_Customer.
  3717. * @param {string} editCustomer
  3718. * @returns {CustomerUpdate}
  3719. */
  3720. setEditCustomer(editCustomer) {
  3721. this.editCustomer = editCustomer;
  3722. return this;
  3723. }
  3724. /**
  3725. * Set Customer_Login.
  3726. * @param {string} customerLogin
  3727. * @returns {CustomerUpdate}
  3728. */
  3729. setCustomerLogin(customerLogin) {
  3730. this.customerLogin = customerLogin;
  3731. return this;
  3732. }
  3733. /**
  3734. * Set Customer_PasswordEmail.
  3735. * @param {string} customerPasswordEmail
  3736. * @returns {CustomerUpdate}
  3737. */
  3738. setCustomerPasswordEmail(customerPasswordEmail) {
  3739. this.customerPasswordEmail = customerPasswordEmail;
  3740. return this;
  3741. }
  3742. /**
  3743. * Set Customer_Password.
  3744. * @param {string} customerPassword
  3745. * @returns {CustomerUpdate}
  3746. */
  3747. setCustomerPassword(customerPassword) {
  3748. this.customerPassword = customerPassword;
  3749. return this;
  3750. }
  3751. /**
  3752. * Set Customer_ShipResidential.
  3753. * @param {boolean} customerShipResidential
  3754. * @returns {CustomerUpdate}
  3755. */
  3756. setCustomerShipResidential(customerShipResidential) {
  3757. this.customerShipResidential = customerShipResidential;
  3758. return this;
  3759. }
  3760. /**
  3761. * Set Customer_ShipFirstName.
  3762. * @param {string} customerShipFirstName
  3763. * @returns {CustomerUpdate}
  3764. */
  3765. setCustomerShipFirstName(customerShipFirstName) {
  3766. this.customerShipFirstName = customerShipFirstName;
  3767. return this;
  3768. }
  3769. /**
  3770. * Set Customer_ShipLastName.
  3771. * @param {string} customerShipLastName
  3772. * @returns {CustomerUpdate}
  3773. */
  3774. setCustomerShipLastName(customerShipLastName) {
  3775. this.customerShipLastName = customerShipLastName;
  3776. return this;
  3777. }
  3778. /**
  3779. * Set Customer_ShipEmail.
  3780. * @param {string} customerShipEmail
  3781. * @returns {CustomerUpdate}
  3782. */
  3783. setCustomerShipEmail(customerShipEmail) {
  3784. this.customerShipEmail = customerShipEmail;
  3785. return this;
  3786. }
  3787. /**
  3788. * Set Customer_ShipCompany.
  3789. * @param {string} customerShipCompany
  3790. * @returns {CustomerUpdate}
  3791. */
  3792. setCustomerShipCompany(customerShipCompany) {
  3793. this.customerShipCompany = customerShipCompany;
  3794. return this;
  3795. }
  3796. /**
  3797. * Set Customer_ShipPhone.
  3798. * @param {string} customerShipPhone
  3799. * @returns {CustomerUpdate}
  3800. */
  3801. setCustomerShipPhone(customerShipPhone) {
  3802. this.customerShipPhone = customerShipPhone;
  3803. return this;
  3804. }
  3805. /**
  3806. * Set Customer_ShipFax.
  3807. * @param {string} customerShipFax
  3808. * @returns {CustomerUpdate}
  3809. */
  3810. setCustomerShipFax(customerShipFax) {
  3811. this.customerShipFax = customerShipFax;
  3812. return this;
  3813. }
  3814. /**
  3815. * Set Customer_ShipAddress1.
  3816. * @param {string} customerShipAddress1
  3817. * @returns {CustomerUpdate}
  3818. */
  3819. setCustomerShipAddress1(customerShipAddress1) {
  3820. this.customerShipAddress1 = customerShipAddress1;
  3821. return this;
  3822. }
  3823. /**
  3824. * Set Customer_ShipAddress2.
  3825. * @param {string} customerShipAddress2
  3826. * @returns {CustomerUpdate}
  3827. */
  3828. setCustomerShipAddress2(customerShipAddress2) {
  3829. this.customerShipAddress2 = customerShipAddress2;
  3830. return this;
  3831. }
  3832. /**
  3833. * Set Customer_ShipCity.
  3834. * @param {string} customerShipCity
  3835. * @returns {CustomerUpdate}
  3836. */
  3837. setCustomerShipCity(customerShipCity) {
  3838. this.customerShipCity = customerShipCity;
  3839. return this;
  3840. }
  3841. /**
  3842. * Set Customer_ShipState.
  3843. * @param {string} customerShipState
  3844. * @returns {CustomerUpdate}
  3845. */
  3846. setCustomerShipState(customerShipState) {
  3847. this.customerShipState = customerShipState;
  3848. return this;
  3849. }
  3850. /**
  3851. * Set Customer_ShipZip.
  3852. * @param {string} customerShipZip
  3853. * @returns {CustomerUpdate}
  3854. */
  3855. setCustomerShipZip(customerShipZip) {
  3856. this.customerShipZip = customerShipZip;
  3857. return this;
  3858. }
  3859. /**
  3860. * Set Customer_ShipCountry.
  3861. * @param {string} customerShipCountry
  3862. * @returns {CustomerUpdate}
  3863. */
  3864. setCustomerShipCountry(customerShipCountry) {
  3865. this.customerShipCountry = customerShipCountry;
  3866. return this;
  3867. }
  3868. /**
  3869. * Set Customer_BillFirstName.
  3870. * @param {string} customerBillFirstName
  3871. * @returns {CustomerUpdate}
  3872. */
  3873. setCustomerBillFirstName(customerBillFirstName) {
  3874. this.customerBillFirstName = customerBillFirstName;
  3875. return this;
  3876. }
  3877. /**
  3878. * Set Customer_BillLastName.
  3879. * @param {string} customerBillLastName
  3880. * @returns {CustomerUpdate}
  3881. */
  3882. setCustomerBillLastName(customerBillLastName) {
  3883. this.customerBillLastName = customerBillLastName;
  3884. return this;
  3885. }
  3886. /**
  3887. * Set Customer_BillEmail.
  3888. * @param {string} customerBillEmail
  3889. * @returns {CustomerUpdate}
  3890. */
  3891. setCustomerBillEmail(customerBillEmail) {
  3892. this.customerBillEmail = customerBillEmail;
  3893. return this;
  3894. }
  3895. /**
  3896. * Set Customer_BillCompany.
  3897. * @param {string} customerBillCompany
  3898. * @returns {CustomerUpdate}
  3899. */
  3900. setCustomerBillCompany(customerBillCompany) {
  3901. this.customerBillCompany = customerBillCompany;
  3902. return this;
  3903. }
  3904. /**
  3905. * Set Customer_BillPhone.
  3906. * @param {string} customerBillPhone
  3907. * @returns {CustomerUpdate}
  3908. */
  3909. setCustomerBillPhone(customerBillPhone) {
  3910. this.customerBillPhone = customerBillPhone;
  3911. return this;
  3912. }
  3913. /**
  3914. * Set Customer_BillFax.
  3915. * @param {string} customerBillFax
  3916. * @returns {CustomerUpdate}
  3917. */
  3918. setCustomerBillFax(customerBillFax) {
  3919. this.customerBillFax = customerBillFax;
  3920. return this;
  3921. }
  3922. /**
  3923. * Set Customer_BillAddress1.
  3924. * @param {string} customerBillAddress1
  3925. * @returns {CustomerUpdate}
  3926. */
  3927. setCustomerBillAddress1(customerBillAddress1) {
  3928. this.customerBillAddress1 = customerBillAddress1;
  3929. return this;
  3930. }
  3931. /**
  3932. * Set Customer_BillAddress2.
  3933. * @param {string} customerBillAddress2
  3934. * @returns {CustomerUpdate}
  3935. */
  3936. setCustomerBillAddress2(customerBillAddress2) {
  3937. this.customerBillAddress2 = customerBillAddress2;
  3938. return this;
  3939. }
  3940. /**
  3941. * Set Customer_BillCity.
  3942. * @param {string} customerBillCity
  3943. * @returns {CustomerUpdate}
  3944. */
  3945. setCustomerBillCity(customerBillCity) {
  3946. this.customerBillCity = customerBillCity;
  3947. return this;
  3948. }
  3949. /**
  3950. * Set Customer_BillState.
  3951. * @param {string} customerBillState
  3952. * @returns {CustomerUpdate}
  3953. */
  3954. setCustomerBillState(customerBillState) {
  3955. this.customerBillState = customerBillState;
  3956. return this;
  3957. }
  3958. /**
  3959. * Set Customer_BillZip.
  3960. * @param {string} customerBillZip
  3961. * @returns {CustomerUpdate}
  3962. */
  3963. setCustomerBillZip(customerBillZip) {
  3964. this.customerBillZip = customerBillZip;
  3965. return this;
  3966. }
  3967. /**
  3968. * Set Customer_BillCountry.
  3969. * @param {string} customerBillCountry
  3970. * @returns {CustomerUpdate}
  3971. */
  3972. setCustomerBillCountry(customerBillCountry) {
  3973. this.customerBillCountry = customerBillCountry;
  3974. return this;
  3975. }
  3976. /**
  3977. * Set Customer_Tax_Exempt.
  3978. * @param {string} customerTaxExempt
  3979. * @returns {CustomerUpdate}
  3980. */
  3981. setCustomerTaxExempt(customerTaxExempt) {
  3982. this.customerTaxExempt = customerTaxExempt;
  3983. return this;
  3984. }
  3985. /**
  3986. * Set Customer_BusinessAccount.
  3987. * @param {string} customerBusinessAccount
  3988. * @returns {CustomerUpdate}
  3989. */
  3990. setCustomerBusinessAccount(customerBusinessAccount) {
  3991. this.customerBusinessAccount = customerBusinessAccount;
  3992. return this;
  3993. }
  3994. /**
  3995. * Set CustomField_Values.
  3996. * @param {?CustomFieldValues} customFieldValues
  3997. * @throws {Error}
  3998. * @returns {CustomerUpdate}
  3999. */
  4000. setCustomFieldValues(customFieldValues) {
  4001. if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues) && util.isObject(customFieldValues)) {
  4002. customFieldValues = new models.CustomFieldValues(customFieldValues);
  4003. } else if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues)) {
  4004. throw new Error(util.format('Expected instance of CustomFieldValues or an Object but got %s',
  4005. typeof customFieldValues));
  4006. }
  4007. this.customFieldValues = customFieldValues;
  4008. return this;
  4009. }
  4010. /**
  4011. * Reduce the request to a an object.
  4012. * @override
  4013. * @returns {Object}
  4014. */
  4015. toObject() {
  4016. var data = super.toObject();
  4017. if (!util.isNullOrUndefined(this.customerId)) {
  4018. data['Customer_ID'] = this.customerId;
  4019. } else if (!util.isNullOrUndefined(this.editCustomer)) {
  4020. data['Edit_Customer'] = this.editCustomer;
  4021. }
  4022. if (!util.isNullOrUndefined(this.customerLogin)) {
  4023. data['Customer_Login'] = this.customerLogin;
  4024. }
  4025. if (!util.isNullOrUndefined(this.customerPasswordEmail)) {
  4026. data['Customer_PasswordEmail'] = this.customerPasswordEmail;
  4027. }
  4028. if (!util.isNullOrUndefined(this.customerPassword)) {
  4029. data['Customer_Password'] = this.customerPassword;
  4030. }
  4031. if (!util.isNullOrUndefined(this.customerShipResidential)) {
  4032. data['Customer_ShipResidential'] = this.customerShipResidential;
  4033. }
  4034. if (!util.isNullOrUndefined(this.customerShipFirstName)) {
  4035. data['Customer_ShipFirstName'] = this.customerShipFirstName;
  4036. }
  4037. if (!util.isNullOrUndefined(this.customerShipLastName)) {
  4038. data['Customer_ShipLastName'] = this.customerShipLastName;
  4039. }
  4040. if (!util.isNullOrUndefined(this.customerShipEmail)) {
  4041. data['Customer_ShipEmail'] = this.customerShipEmail;
  4042. }
  4043. if (!util.isNullOrUndefined(this.customerShipCompany)) {
  4044. data['Customer_ShipCompany'] = this.customerShipCompany;
  4045. }
  4046. if (!util.isNullOrUndefined(this.customerShipPhone)) {
  4047. data['Customer_ShipPhone'] = this.customerShipPhone;
  4048. }
  4049. if (!util.isNullOrUndefined(this.customerShipFax)) {
  4050. data['Customer_ShipFax'] = this.customerShipFax;
  4051. }
  4052. if (!util.isNullOrUndefined(this.customerShipAddress1)) {
  4053. data['Customer_ShipAddress1'] = this.customerShipAddress1;
  4054. }
  4055. if (!util.isNullOrUndefined(this.customerShipAddress2)) {
  4056. data['Customer_ShipAddress2'] = this.customerShipAddress2;
  4057. }
  4058. if (!util.isNullOrUndefined(this.customerShipCity)) {
  4059. data['Customer_ShipCity'] = this.customerShipCity;
  4060. }
  4061. if (!util.isNullOrUndefined(this.customerShipState)) {
  4062. data['Customer_ShipState'] = this.customerShipState;
  4063. }
  4064. if (!util.isNullOrUndefined(this.customerShipZip)) {
  4065. data['Customer_ShipZip'] = this.customerShipZip;
  4066. }
  4067. if (!util.isNullOrUndefined(this.customerShipCountry)) {
  4068. data['Customer_ShipCountry'] = this.customerShipCountry;
  4069. }
  4070. if (!util.isNullOrUndefined(this.customerBillFirstName)) {
  4071. data['Customer_BillFirstName'] = this.customerBillFirstName;
  4072. }
  4073. if (!util.isNullOrUndefined(this.customerBillLastName)) {
  4074. data['Customer_BillLastName'] = this.customerBillLastName;
  4075. }
  4076. if (!util.isNullOrUndefined(this.customerBillEmail)) {
  4077. data['Customer_BillEmail'] = this.customerBillEmail;
  4078. }
  4079. if (!util.isNullOrUndefined(this.customerBillCompany)) {
  4080. data['Customer_BillCompany'] = this.customerBillCompany;
  4081. }
  4082. if (!util.isNullOrUndefined(this.customerBillPhone)) {
  4083. data['Customer_BillPhone'] = this.customerBillPhone;
  4084. }
  4085. if (!util.isNullOrUndefined(this.customerBillFax)) {
  4086. data['Customer_BillFax'] = this.customerBillFax;
  4087. }
  4088. if (!util.isNullOrUndefined(this.customerBillAddress1)) {
  4089. data['Customer_BillAddress1'] = this.customerBillAddress1;
  4090. }
  4091. if (!util.isNullOrUndefined(this.customerBillAddress2)) {
  4092. data['Customer_BillAddress2'] = this.customerBillAddress2;
  4093. }
  4094. if (!util.isNullOrUndefined(this.customerBillCity)) {
  4095. data['Customer_BillCity'] = this.customerBillCity;
  4096. }
  4097. if (!util.isNullOrUndefined(this.customerBillState)) {
  4098. data['Customer_BillState'] = this.customerBillState;
  4099. }
  4100. if (!util.isNullOrUndefined(this.customerBillZip)) {
  4101. data['Customer_BillZip'] = this.customerBillZip;
  4102. }
  4103. if (!util.isNullOrUndefined(this.customerBillCountry)) {
  4104. data['Customer_BillCountry'] = this.customerBillCountry;
  4105. }
  4106. if (!util.isNullOrUndefined(this.customerTaxExempt)) {
  4107. data['Customer_Tax_Exempt'] = this.customerTaxExempt;
  4108. }
  4109. if (!util.isNullOrUndefined(this.customerBusinessAccount)) {
  4110. data['Customer_BusinessAccount'] = this.customerBusinessAccount;
  4111. }
  4112. if (this.customFieldValues && util.isObject(this.customFieldValues)) {
  4113. data['CustomField_Values'] = this.customFieldValues.toObject();
  4114. }
  4115. return data;
  4116. }
  4117. /**
  4118. * Create a response object from the response data.
  4119. * @override
  4120. * @returns {Response}
  4121. */
  4122. createResponse(data) {
  4123. return new responses.CustomerUpdate(this, data);
  4124. }
  4125. }
  4126. /**
  4127. * Handles API Request CustomerPaymentCard_Register. Scope: Store.
  4128. * @see https://docs.miva.com/json-api/functions/customerpaymentcard_register
  4129. */
  4130. class CustomerPaymentCardRegister extends Request {
  4131. /**
  4132. * CustomerPaymentCardRegister Constructor.
  4133. * @param {?Client} client
  4134. * @param {?Customer} customer
  4135. */
  4136. constructor(client, customer = null) {
  4137. super(client);
  4138. this.function = 'CustomerPaymentCard_Register';
  4139. this.scope = Request.REQUEST_SCOPE_STORE;
  4140. this.customerId = null;
  4141. this.editCustomer = null;
  4142. this.customerLogin = null;
  4143. this.firstName = null;
  4144. this.lastName = null;
  4145. this.cardType = null;
  4146. this.cardNumber = null;
  4147. this.expirationMonth = null;
  4148. this.expirationYear = null;
  4149. this.address1 = null;
  4150. this.address2 = null;
  4151. this.city = null;
  4152. this.state = null;
  4153. this.zip = null;
  4154. this.country = null;
  4155. if (util.isInstanceOf(customer, models.Customer)) {
  4156. if (customer.getId()) {
  4157. this.setCustomerId(customer.getId());
  4158. } else if (customer.getLogin()) {
  4159. this.setEditCustomer(customer.getLogin());
  4160. }
  4161. }
  4162. }
  4163. /**
  4164. * Get Customer_ID.
  4165. * @returns {number}
  4166. */
  4167. getCustomerId() {
  4168. return this.customerId;
  4169. }
  4170. /**
  4171. * Get Edit_Customer.
  4172. * @returns {string}
  4173. */
  4174. getEditCustomer() {
  4175. return this.editCustomer;
  4176. }
  4177. /**
  4178. * Get Customer_Login.
  4179. * @returns {string}
  4180. */
  4181. getCustomerLogin() {
  4182. return this.customerLogin;
  4183. }
  4184. /**
  4185. * Get FirstName.
  4186. * @returns {string}
  4187. */
  4188. getFirstName() {
  4189. return this.firstName;
  4190. }
  4191. /**
  4192. * Get LastName.
  4193. * @returns {string}
  4194. */
  4195. getLastName() {
  4196. return this.lastName;
  4197. }
  4198. /**
  4199. * Get CardType.
  4200. * @returns {string}
  4201. */
  4202. getCardType() {
  4203. return this.cardType;
  4204. }
  4205. /**
  4206. * Get CardNumber.
  4207. * @returns {string}
  4208. */
  4209. getCardNumber() {
  4210. return this.cardNumber;
  4211. }
  4212. /**
  4213. * Get ExpirationMonth.
  4214. * @returns {number}
  4215. */
  4216. getExpirationMonth() {
  4217. return this.expirationMonth;
  4218. }
  4219. /**
  4220. * Get ExpirationYear.
  4221. * @returns {number}
  4222. */
  4223. getExpirationYear() {
  4224. return this.expirationYear;
  4225. }
  4226. /**
  4227. * Get Address1.
  4228. * @returns {string}
  4229. */
  4230. getAddress1() {
  4231. return this.address1;
  4232. }
  4233. /**
  4234. * Get Address2.
  4235. * @returns {string}
  4236. */
  4237. getAddress2() {
  4238. return this.address2;
  4239. }
  4240. /**
  4241. * Get City.
  4242. * @returns {string}
  4243. */
  4244. getCity() {
  4245. return this.city;
  4246. }
  4247. /**
  4248. * Get State.
  4249. * @returns {string}
  4250. */
  4251. getState() {
  4252. return this.state;
  4253. }
  4254. /**
  4255. * Get Zip.
  4256. * @returns {string}
  4257. */
  4258. getZip() {
  4259. return this.zip;
  4260. }
  4261. /**
  4262. * Get Country.
  4263. * @returns {string}
  4264. */
  4265. getCountry() {
  4266. return this.country;
  4267. }
  4268. /**
  4269. * Set Customer_ID.
  4270. * @param {number} customerId
  4271. * @returns {CustomerPaymentCardRegister}
  4272. */
  4273. setCustomerId(customerId) {
  4274. this.customerId = customerId;
  4275. return this;
  4276. }
  4277. /**
  4278. * Set Edit_Customer.
  4279. * @param {string} editCustomer
  4280. * @returns {CustomerPaymentCardRegister}
  4281. */
  4282. setEditCustomer(editCustomer) {
  4283. this.editCustomer = editCustomer;
  4284. return this;
  4285. }
  4286. /**
  4287. * Set Customer_Login.
  4288. * @param {string} customerLogin
  4289. * @returns {CustomerPaymentCardRegister}
  4290. */
  4291. setCustomerLogin(customerLogin) {
  4292. this.customerLogin = customerLogin;
  4293. return this;
  4294. }
  4295. /**
  4296. * Set FirstName.
  4297. * @param {string} firstName
  4298. * @returns {CustomerPaymentCardRegister}
  4299. */
  4300. setFirstName(firstName) {
  4301. this.firstName = firstName;
  4302. return this;
  4303. }
  4304. /**
  4305. * Set LastName.
  4306. * @param {string} lastName
  4307. * @returns {CustomerPaymentCardRegister}
  4308. */
  4309. setLastName(lastName) {
  4310. this.lastName = lastName;
  4311. return this;
  4312. }
  4313. /**
  4314. * Set CardType.
  4315. * @param {string} cardType
  4316. * @returns {CustomerPaymentCardRegister}
  4317. */
  4318. setCardType(cardType) {
  4319. this.cardType = cardType;
  4320. return this;
  4321. }
  4322. /**
  4323. * Set CardNumber.
  4324. * @param {string} cardNumber
  4325. * @returns {CustomerPaymentCardRegister}
  4326. */
  4327. setCardNumber(cardNumber) {
  4328. this.cardNumber = cardNumber;
  4329. return this;
  4330. }
  4331. /**
  4332. * Set ExpirationMonth.
  4333. * @param {number} expirationMonth
  4334. * @returns {CustomerPaymentCardRegister}
  4335. */
  4336. setExpirationMonth(expirationMonth) {
  4337. this.expirationMonth = expirationMonth;
  4338. return this;
  4339. }
  4340. /**
  4341. * Set ExpirationYear.
  4342. * @param {number} expirationYear
  4343. * @returns {CustomerPaymentCardRegister}
  4344. */
  4345. setExpirationYear(expirationYear) {
  4346. this.expirationYear = expirationYear;
  4347. return this;
  4348. }
  4349. /**
  4350. * Set Address1.
  4351. * @param {string} address1
  4352. * @returns {CustomerPaymentCardRegister}
  4353. */
  4354. setAddress1(address1) {
  4355. this.address1 = address1;
  4356. return this;
  4357. }
  4358. /**
  4359. * Set Address2.
  4360. * @param {string} address2
  4361. * @returns {CustomerPaymentCardRegister}
  4362. */
  4363. setAddress2(address2) {
  4364. this.address2 = address2;
  4365. return this;
  4366. }
  4367. /**
  4368. * Set City.
  4369. * @param {string} city
  4370. * @returns {CustomerPaymentCardRegister}
  4371. */
  4372. setCity(city) {
  4373. this.city = city;
  4374. return this;
  4375. }
  4376. /**
  4377. * Set State.
  4378. * @param {string} state
  4379. * @returns {CustomerPaymentCardRegister}
  4380. */
  4381. setState(state) {
  4382. this.state = state;
  4383. return this;
  4384. }
  4385. /**
  4386. * Set Zip.
  4387. * @param {string} zip
  4388. * @returns {CustomerPaymentCardRegister}
  4389. */
  4390. setZip(zip) {
  4391. this.zip = zip;
  4392. return this;
  4393. }
  4394. /**
  4395. * Set Country.
  4396. * @param {string} country
  4397. * @returns {CustomerPaymentCardRegister}
  4398. */
  4399. setCountry(country) {
  4400. this.country = country;
  4401. return this;
  4402. }
  4403. /**
  4404. * Reduce the request to a an object.
  4405. * @override
  4406. * @returns {Object}
  4407. */
  4408. toObject() {
  4409. var data = super.toObject();
  4410. if (!util.isNullOrUndefined(this.customerId)) {
  4411. data['Customer_ID'] = this.customerId;
  4412. } else if (!util.isNullOrUndefined(this.editCustomer)) {
  4413. data['Edit_Customer'] = this.editCustomer;
  4414. } else if (!util.isNullOrUndefined(this.customerLogin)) {
  4415. data['Customer_Login'] = this.customerLogin;
  4416. }
  4417. if (!util.isNullOrUndefined(this.firstName)) {
  4418. data['FirstName'] = this.firstName;
  4419. }
  4420. if (!util.isNullOrUndefined(this.lastName)) {
  4421. data['LastName'] = this.lastName;
  4422. }
  4423. if (!util.isNullOrUndefined(this.cardType)) {
  4424. data['CardType'] = this.cardType;
  4425. }
  4426. if (!util.isNullOrUndefined(this.cardNumber)) {
  4427. data['CardNumber'] = this.cardNumber;
  4428. }
  4429. if (!util.isNullOrUndefined(this.expirationMonth)) {
  4430. data['ExpirationMonth'] = this.expirationMonth;
  4431. }
  4432. if (!util.isNullOrUndefined(this.expirationYear)) {
  4433. data['ExpirationYear'] = this.expirationYear;
  4434. }
  4435. if (!util.isNullOrUndefined(this.address1)) {
  4436. data['Address1'] = this.address1;
  4437. }
  4438. if (!util.isNullOrUndefined(this.address2)) {
  4439. data['Address2'] = this.address2;
  4440. }
  4441. if (!util.isNullOrUndefined(this.city)) {
  4442. data['City'] = this.city;
  4443. }
  4444. if (!util.isNullOrUndefined(this.state)) {
  4445. data['State'] = this.state;
  4446. }
  4447. if (!util.isNullOrUndefined(this.zip)) {
  4448. data['Zip'] = this.zip;
  4449. }
  4450. if (!util.isNullOrUndefined(this.country)) {
  4451. data['Country'] = this.country;
  4452. }
  4453. return data;
  4454. }
  4455. /**
  4456. * Create a response object from the response data.
  4457. * @override
  4458. * @returns {Response}
  4459. */
  4460. createResponse(data) {
  4461. return new responses.CustomerPaymentCardRegister(this, data);
  4462. }
  4463. }
  4464. /**
  4465. * Handles API Request Module. Scope: Store.
  4466. * @see https://docs.miva.com/json-api/functions/module
  4467. */
  4468. class Module extends Request {
  4469. /**
  4470. * Module Constructor.
  4471. * @param {?Client} client
  4472. */
  4473. constructor(client) {
  4474. super(client);
  4475. this.function = 'Module';
  4476. this.scope = Request.REQUEST_SCOPE_STORE;
  4477. this.moduleCode = null;
  4478. this.moduleFunction = null;
  4479. this.moduleFields = {};
  4480. }
  4481. /**
  4482. * Get Module_Code.
  4483. * @returns {string}
  4484. */
  4485. getModuleCode() {
  4486. return this.moduleCode;
  4487. }
  4488. /**
  4489. * Get Module_Function.
  4490. * @returns {string}
  4491. */
  4492. getModuleFunction() {
  4493. return this.moduleFunction;
  4494. }
  4495. /**
  4496. * Get Module_Fields.
  4497. * @returns {Object}
  4498. */
  4499. getModuleFields() {
  4500. return this.moduleFields;
  4501. }
  4502. /**
  4503. * Set Module_Code.
  4504. * @param {string} moduleCode
  4505. * @returns {Module}
  4506. */
  4507. setModuleCode(moduleCode) {
  4508. this.moduleCode = moduleCode;
  4509. return this;
  4510. }
  4511. /**
  4512. * Set Module_Function.
  4513. * @param {string} moduleFunction
  4514. * @returns {Module}
  4515. */
  4516. setModuleFunction(moduleFunction) {
  4517. this.moduleFunction = moduleFunction;
  4518. return this;
  4519. }
  4520. /**
  4521. * Set Module_Fields.
  4522. * @param {Object} moduleFields
  4523. * @returns {Module}
  4524. */
  4525. setModuleFields(moduleFields) {
  4526. this.moduleFields = moduleFields;
  4527. return this;
  4528. }
  4529. /**
  4530. * Add custom data to the request.
  4531. *
  4532. * @param {string}
  4533. * @param {*}
  4534. * @returns {Module}
  4535. */
  4536. setModuleField(field, value)
  4537. {
  4538. this.moduleFields[field] = value;
  4539. return this;
  4540. }
  4541. /**
  4542. * Reduce the request to a an object.
  4543. * @override
  4544. * @returns {Object}
  4545. */
  4546. toObject() {
  4547. var data = Object.assign(super.toObject(), this.getModuleFields());
  4548. data['Module_Code'] = this.moduleCode;
  4549. data['Module_Function'] = this.moduleFunction;
  4550. return data;
  4551. }
  4552. /**
  4553. * Create a response object from the response data.
  4554. * @override
  4555. * @returns {Response}
  4556. */
  4557. createResponse(data) {
  4558. return new responses.Module(this, data);
  4559. }
  4560. }
  4561. /**
  4562. * Handles API Request NoteList_Load_Query. Scope: Store.
  4563. * @see https://docs.miva.com/json-api/functions/notelist_load_query
  4564. */
  4565. class NoteListLoadQuery extends ListQueryRequest {
  4566. /**
  4567. * NoteListLoadQuery Constructor.
  4568. * @param {?Client} client
  4569. */
  4570. constructor(client) {
  4571. super(client);
  4572. this.function = 'NoteList_Load_Query';
  4573. this.scope = Request.REQUEST_SCOPE_STORE;
  4574. this.availableSearchFields = [
  4575. 'id',
  4576. 'notetext',
  4577. 'dtstamp',
  4578. 'cust_id',
  4579. 'account_id',
  4580. 'order_id',
  4581. 'admin_user',
  4582. 'cust_login',
  4583. 'business_title'
  4584. ];
  4585. this.availableSortFields = [
  4586. 'id',
  4587. 'notetext',
  4588. 'dtstamp',
  4589. 'cust_id',
  4590. 'account_id',
  4591. 'order_id',
  4592. 'admin_user',
  4593. 'cust_login',
  4594. 'business_title'
  4595. ];
  4596. }
  4597. /**
  4598. * Create a response object from the response data.
  4599. * @override
  4600. * @returns {Response}
  4601. */
  4602. createResponse(data) {
  4603. return new responses.NoteListLoadQuery(this, data);
  4604. }
  4605. }
  4606. /**
  4607. * Handles API Request Note_Delete. Scope: Store.
  4608. * @see https://docs.miva.com/json-api/functions/note_delete
  4609. */
  4610. class NoteDelete extends Request {
  4611. /**
  4612. * NoteDelete Constructor.
  4613. * @param {?Client} client
  4614. * @param {?Note} note
  4615. */
  4616. constructor(client, note = null) {
  4617. super(client);
  4618. this.function = 'Note_Delete';
  4619. this.scope = Request.REQUEST_SCOPE_STORE;
  4620. this.noteId = null;
  4621. if (util.isInstanceOf(note, models.Note)) {
  4622. this.setNoteId(note.getId());
  4623. }
  4624. }
  4625. /**
  4626. * Get Note_ID.
  4627. * @returns {number}
  4628. */
  4629. getNoteId() {
  4630. return this.noteId;
  4631. }
  4632. /**
  4633. * Set Note_ID.
  4634. * @param {number} noteId
  4635. * @returns {NoteDelete}
  4636. */
  4637. setNoteId(noteId) {
  4638. this.noteId = noteId;
  4639. return this;
  4640. }
  4641. /**
  4642. * Reduce the request to a an object.
  4643. * @override
  4644. * @returns {Object}
  4645. */
  4646. toObject() {
  4647. var data = super.toObject();
  4648. data['Note_ID'] = this.noteId;
  4649. return data;
  4650. }
  4651. /**
  4652. * Create a response object from the response data.
  4653. * @override
  4654. * @returns {Response}
  4655. */
  4656. createResponse(data) {
  4657. return new responses.NoteDelete(this, data);
  4658. }
  4659. }
  4660. /**
  4661. * Handles API Request Note_Insert. Scope: Store.
  4662. * @see https://docs.miva.com/json-api/functions/note_insert
  4663. */
  4664. class NoteInsert extends Request {
  4665. /**
  4666. * NoteInsert Constructor.
  4667. * @param {?Client} client
  4668. */
  4669. constructor(client) {
  4670. super(client);
  4671. this.function = 'Note_Insert';
  4672. this.scope = Request.REQUEST_SCOPE_STORE;
  4673. this.noteText = null;
  4674. this.customerId = null;
  4675. this.accountId = null;
  4676. this.orderId = null;
  4677. }
  4678. /**
  4679. * Get NoteText.
  4680. * @returns {string}
  4681. */
  4682. getNoteText() {
  4683. return this.noteText;
  4684. }
  4685. /**
  4686. * Get Customer_ID.
  4687. * @returns {number}
  4688. */
  4689. getCustomerId() {
  4690. return this.customerId;
  4691. }
  4692. /**
  4693. * Get Account_ID.
  4694. * @returns {number}
  4695. */
  4696. getAccountId() {
  4697. return this.accountId;
  4698. }
  4699. /**
  4700. * Get Order_ID.
  4701. * @returns {number}
  4702. */
  4703. getOrderId() {
  4704. return this.orderId;
  4705. }
  4706. /**
  4707. * Set NoteText.
  4708. * @param {string} noteText
  4709. * @returns {NoteInsert}
  4710. */
  4711. setNoteText(noteText) {
  4712. this.noteText = noteText;
  4713. return this;
  4714. }
  4715. /**
  4716. * Set Customer_ID.
  4717. * @param {number} customerId
  4718. * @returns {NoteInsert}
  4719. */
  4720. setCustomerId(customerId) {
  4721. this.customerId = customerId;
  4722. return this;
  4723. }
  4724. /**
  4725. * Set Account_ID.
  4726. * @param {number} accountId
  4727. * @returns {NoteInsert}
  4728. */
  4729. setAccountId(accountId) {
  4730. this.accountId = accountId;
  4731. return this;
  4732. }
  4733. /**
  4734. * Set Order_ID.
  4735. * @param {number} orderId
  4736. * @returns {NoteInsert}
  4737. */
  4738. setOrderId(orderId) {
  4739. this.orderId = orderId;
  4740. return this;
  4741. }
  4742. /**
  4743. * Reduce the request to a an object.
  4744. * @override
  4745. * @returns {Object}
  4746. */
  4747. toObject() {
  4748. var data = super.toObject();
  4749. data['NoteText'] = this.noteText;
  4750. if (!util.isNullOrUndefined(this.customerId)) {
  4751. data['Customer_ID'] = this.customerId;
  4752. }
  4753. if (!util.isNullOrUndefined(this.accountId)) {
  4754. data['Account_ID'] = this.accountId;
  4755. }
  4756. if (!util.isNullOrUndefined(this.orderId)) {
  4757. data['Order_ID'] = this.orderId;
  4758. }
  4759. return data;
  4760. }
  4761. /**
  4762. * Create a response object from the response data.
  4763. * @override
  4764. * @returns {Response}
  4765. */
  4766. createResponse(data) {
  4767. return new responses.NoteInsert(this, data);
  4768. }
  4769. }
  4770. /**
  4771. * Handles API Request Note_Update. Scope: Store.
  4772. * @see https://docs.miva.com/json-api/functions/note_update
  4773. */
  4774. class NoteUpdate extends Request {
  4775. /**
  4776. * NoteUpdate Constructor.
  4777. * @param {?Client} client
  4778. * @param {?Note} note
  4779. */
  4780. constructor(client, note = null) {
  4781. super(client);
  4782. this.function = 'Note_Update';
  4783. this.scope = Request.REQUEST_SCOPE_STORE;
  4784. this.noteId = null;
  4785. this.noteText = null;
  4786. if (util.isInstanceOf(note, models.Note)) {
  4787. this.setNoteId(note.getId());
  4788. this.setNoteText(note.getNoteText());
  4789. }
  4790. }
  4791. /**
  4792. * Get Note_ID.
  4793. * @returns {number}
  4794. */
  4795. getNoteId() {
  4796. return this.noteId;
  4797. }
  4798. /**
  4799. * Get NoteText.
  4800. * @returns {string}
  4801. */
  4802. getNoteText() {
  4803. return this.noteText;
  4804. }
  4805. /**
  4806. * Set Note_ID.
  4807. * @param {number} noteId
  4808. * @returns {NoteUpdate}
  4809. */
  4810. setNoteId(noteId) {
  4811. this.noteId = noteId;
  4812. return this;
  4813. }
  4814. /**
  4815. * Set NoteText.
  4816. * @param {string} noteText
  4817. * @returns {NoteUpdate}
  4818. */
  4819. setNoteText(noteText) {
  4820. this.noteText = noteText;
  4821. return this;
  4822. }
  4823. /**
  4824. * Reduce the request to a an object.
  4825. * @override
  4826. * @returns {Object}
  4827. */
  4828. toObject() {
  4829. var data = super.toObject();
  4830. data['Note_ID'] = this.getNoteId();
  4831. data['NoteText'] = this.noteText;
  4832. return data;
  4833. }
  4834. /**
  4835. * Create a response object from the response data.
  4836. * @override
  4837. * @returns {Response}
  4838. */
  4839. createResponse(data) {
  4840. return new responses.NoteUpdate(this, data);
  4841. }
  4842. }
  4843. /**
  4844. * Handles API Request OrderCustomFieldList_Load. Scope: Store.
  4845. * @see https://docs.miva.com/json-api/functions/ordercustomfieldlist_load
  4846. */
  4847. class OrderCustomFieldListLoad extends Request {
  4848. /**
  4849. * OrderCustomFieldListLoad Constructor.
  4850. * @param {?Client} client
  4851. */
  4852. constructor(client) {
  4853. super(client);
  4854. this.function = 'OrderCustomFieldList_Load';
  4855. this.scope = Request.REQUEST_SCOPE_STORE;
  4856. }
  4857. /**
  4858. * Create a response object from the response data.
  4859. * @override
  4860. * @returns {Response}
  4861. */
  4862. createResponse(data) {
  4863. return new responses.OrderCustomFieldListLoad(this, data);
  4864. }
  4865. }
  4866. /**
  4867. * Handles API Request OrderCustomFields_Update. Scope: Store.
  4868. * @see https://docs.miva.com/json-api/functions/ordercustomfields_update
  4869. */
  4870. class OrderCustomFieldsUpdate extends Request {
  4871. /**
  4872. * OrderCustomFieldsUpdate Constructor.
  4873. * @param {?Client} client
  4874. * @param {?Order} order
  4875. */
  4876. constructor(client, order = null) {
  4877. super(client);
  4878. this.function = 'OrderCustomFields_Update';
  4879. this.scope = Request.REQUEST_SCOPE_STORE;
  4880. this.orderId = null;
  4881. this.customFieldValues = new models.CustomFieldValues();
  4882. if (util.isInstanceOf(order, models.Order)) {
  4883. if (order.getId()) {
  4884. this.setOrderId(order.getId());
  4885. }
  4886. }
  4887. }
  4888. /**
  4889. * Get Order_ID.
  4890. * @returns {number}
  4891. */
  4892. getOrderId() {
  4893. return this.orderId;
  4894. }
  4895. /**
  4896. * Get CustomField_Values.
  4897. * @returns {?CustomFieldValues}
  4898. */
  4899. getCustomFieldValues() {
  4900. return this.customFieldValues;
  4901. }
  4902. /**
  4903. * Set Order_ID.
  4904. * @param {number} orderId
  4905. * @returns {OrderCustomFieldsUpdate}
  4906. */
  4907. setOrderId(orderId) {
  4908. this.orderId = orderId;
  4909. return this;
  4910. }
  4911. /**
  4912. * Set CustomField_Values.
  4913. * @param {?CustomFieldValues} customFieldValues
  4914. * @throws {Error}
  4915. * @returns {OrderCustomFieldsUpdate}
  4916. */
  4917. setCustomFieldValues(customFieldValues) {
  4918. if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues) && util.isObject(customFieldValues)) {
  4919. customFieldValues = new models.CustomFieldValues(customFieldValues);
  4920. } else if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues)) {
  4921. throw new Error(util.format('Expected instance of CustomFieldValues or an Object but got %s',
  4922. typeof customFieldValues));
  4923. }
  4924. this.customFieldValues = customFieldValues;
  4925. return this;
  4926. }
  4927. /**
  4928. * Reduce the request to a an object.
  4929. * @override
  4930. * @returns {Object}
  4931. */
  4932. toObject() {
  4933. var data = super.toObject();
  4934. if (!util.isNullOrUndefined(this.orderId)) {
  4935. data['Order_ID'] = this.orderId;
  4936. }
  4937. if (this.customFieldValues) {
  4938. data['CustomField_Values'] = this.customFieldValues.toObject();
  4939. }
  4940. return data;
  4941. }
  4942. /**
  4943. * Create a response object from the response data.
  4944. * @override
  4945. * @returns {Response}
  4946. */
  4947. createResponse(data) {
  4948. return new responses.OrderCustomFieldsUpdate(this, data);
  4949. }
  4950. }
  4951. /**
  4952. * Handles API Request OrderItemList_BackOrder. Scope: Store.
  4953. * @see https://docs.miva.com/json-api/functions/orderitemlist_backorder
  4954. */
  4955. class OrderItemListBackOrder extends Request {
  4956. /**
  4957. * OrderItemListBackOrder Constructor.
  4958. * @param {?Client} client
  4959. * @param {?Order} order
  4960. */
  4961. constructor(client, order = null) {
  4962. super(client);
  4963. this.function = 'OrderItemList_BackOrder';
  4964. this.scope = Request.REQUEST_SCOPE_STORE;
  4965. this.orderId = null;
  4966. this.lineIds = [];
  4967. this.dateInStock = null;
  4968. if (util.isInstanceOf(order, models.Order)) {
  4969. if (order.getId()) {
  4970. this.setOrderId(order.getId());
  4971. }
  4972. }
  4973. }
  4974. /**
  4975. * Get Order_ID.
  4976. * @returns {number}
  4977. */
  4978. getOrderId() {
  4979. return this.orderId;
  4980. }
  4981. /**
  4982. * Get Line_IDs.
  4983. * @returns {Array}
  4984. */
  4985. getLineIds() {
  4986. return this.lineIds;
  4987. }
  4988. /**
  4989. * Get Date_InStock.
  4990. * @returns {number}
  4991. */
  4992. getDateInStock() {
  4993. return this.dateInStock;
  4994. }
  4995. /**
  4996. * Set Order_ID.
  4997. * @param {number} orderId
  4998. * @returns {OrderItemListBackOrder}
  4999. */
  5000. setOrderId(orderId) {
  5001. this.orderId = orderId;
  5002. return this;
  5003. }
  5004. /**
  5005. * Set Date_InStock.
  5006. * @param {number|Date} dateInStock
  5007. * @returns {OrderItemListBackOrder}
  5008. */
  5009. setDateInStock(dateInStock) {
  5010. if (util.isDate(dateInStock)) {
  5011. this.dateInStock = Math.floor(dateInStock.getTime()/1000);
  5012. } else {
  5013. this.dateInStock = dateInStock;
  5014. }
  5015. return this;
  5016. }
  5017. /**
  5018. * Add Line_IDs.
  5019. * @param {number} lineId
  5020. * @returns {OrderItemListBackOrder}
  5021. */
  5022. addLineId(lineId) {
  5023. this.lineIds.push(lineId);
  5024. return this;
  5025. }
  5026. /**
  5027. * Add OrderItem model.
  5028. * @param {OrderItem} orderItem
  5029. * @throws {Error}
  5030. * @returns {OrderItemListBackOrder}
  5031. */
  5032. addOrderItem(orderItem) {
  5033. if (!util.isInstanceOf(orderItem, models.OrderItem)) {
  5034. throw new Error(util.format('Expected instance of OrderItem but got %s',
  5035. typeof orderItem));
  5036. }
  5037. if (orderItem.getLineId()) {
  5038. this.lineIds.push(orderItem.getLineId());
  5039. }
  5040. return this;
  5041. }
  5042. /**
  5043. * Reduce the request to a an object.
  5044. * @override
  5045. * @returns {Object}
  5046. */
  5047. toObject() {
  5048. var data = super.toObject();
  5049. if (!util.isNullOrUndefined(this.orderId)) {
  5050. data['Order_ID'] = this.orderId;
  5051. }
  5052. data['Line_IDs'] = this.lineIds;
  5053. if (!util.isNullOrUndefined(this.dateInStock)) {
  5054. data['Date_InStock'] = this.dateInStock;
  5055. }
  5056. return data;
  5057. }
  5058. /**
  5059. * Create a response object from the response data.
  5060. * @override
  5061. * @returns {Response}
  5062. */
  5063. createResponse(data) {
  5064. return new responses.OrderItemListBackOrder(this, data);
  5065. }
  5066. }
  5067. /**
  5068. * Handles API Request OrderItemList_Cancel. Scope: Store.
  5069. * @see https://docs.miva.com/json-api/functions/orderitemlist_cancel
  5070. */
  5071. class OrderItemListCancel extends Request {
  5072. /**
  5073. * OrderItemListCancel Constructor.
  5074. * @param {?Client} client
  5075. * @param {?Order} order
  5076. */
  5077. constructor(client, order = null) {
  5078. super(client);
  5079. this.function = 'OrderItemList_Cancel';
  5080. this.scope = Request.REQUEST_SCOPE_STORE;
  5081. this.orderId = null;
  5082. this.lineIds = [];
  5083. this.reason = null;
  5084. if (util.isInstanceOf(order, models.Order)) {
  5085. this.setOrderId(order.getId());
  5086. }
  5087. }
  5088. /**
  5089. * Get Order_ID.
  5090. * @returns {number}
  5091. */
  5092. getOrderId() {
  5093. return this.orderId;
  5094. }
  5095. /**
  5096. * Get Line_IDs.
  5097. * @returns {Array}
  5098. */
  5099. getLineIds() {
  5100. return this.lineIds;
  5101. }
  5102. /**
  5103. * Get Reason.
  5104. * @returns {string}
  5105. */
  5106. getReason() {
  5107. return this.reason;
  5108. }
  5109. /**
  5110. * Set Order_ID.
  5111. * @param {number} orderId
  5112. * @returns {OrderItemListCancel}
  5113. */
  5114. setOrderId(orderId) {
  5115. this.orderId = orderId;
  5116. return this;
  5117. }
  5118. /**
  5119. * Set Reason.
  5120. * @param {string} reason
  5121. * @returns {OrderItemListCancel}
  5122. */
  5123. setReason(reason) {
  5124. this.reason = reason;
  5125. return this;
  5126. }
  5127. /**
  5128. * Add Line_IDs.
  5129. * @param {number} lineId
  5130. * @returns {OrderItemListCancel}
  5131. */
  5132. addLineId(lineId) {
  5133. this.lineIds.push(lineId);
  5134. return this;
  5135. }
  5136. /**
  5137. * Add OrderItem model.
  5138. * @param {OrderItem} orderItem
  5139. * @throws {Error}
  5140. * @returns {OrderItemListCancel}
  5141. */
  5142. addOrderItem(orderItem) {
  5143. if (!util.isInstanceOf(orderItem, models.OrderItem)) {
  5144. throw new Error(util.format('Expected instance of OrderItem but got %s',
  5145. typeof orderItem));
  5146. }
  5147. if (orderItem.getLineId()) {
  5148. this.lineIds.push(orderItem.getLineId());
  5149. }
  5150. return this;
  5151. }
  5152. /**
  5153. * Reduce the request to a an object.
  5154. * @override
  5155. * @returns {Object}
  5156. */
  5157. toObject() {
  5158. var data = super.toObject();
  5159. data['Order_ID'] = this.getOrderId();
  5160. data['Line_IDs'] = this.lineIds;
  5161. if (!util.isNullOrUndefined(this.reason)) {
  5162. data['Reason'] = this.reason;
  5163. }
  5164. return data;
  5165. }
  5166. /**
  5167. * Create a response object from the response data.
  5168. * @override
  5169. * @returns {Response}
  5170. */
  5171. createResponse(data) {
  5172. return new responses.OrderItemListCancel(this, data);
  5173. }
  5174. }
  5175. /**
  5176. * Handles API Request OrderItemList_CreateShipment. Scope: Store.
  5177. * @see https://docs.miva.com/json-api/functions/orderitemlist_createshipment
  5178. */
  5179. class OrderItemListCreateShipment extends Request {
  5180. /**
  5181. * OrderItemListCreateShipment Constructor.
  5182. * @param {?Client} client
  5183. * @param {?Order} order
  5184. */
  5185. constructor(client, order = null) {
  5186. super(client);
  5187. this.function = 'OrderItemList_CreateShipment';
  5188. this.scope = Request.REQUEST_SCOPE_STORE;
  5189. this.orderId = null;
  5190. this.lineIds = [];
  5191. if (util.isInstanceOf(order, models.Order)) {
  5192. this.setOrderId(order.getId());
  5193. }
  5194. }
  5195. /**
  5196. * Get Order_ID.
  5197. * @returns {number}
  5198. */
  5199. getOrderId() {
  5200. return this.orderId;
  5201. }
  5202. /**
  5203. * Get Line_IDs.
  5204. * @returns {Array}
  5205. */
  5206. getLineIds() {
  5207. return this.lineIds;
  5208. }
  5209. /**
  5210. * Set Order_ID.
  5211. * @param {number} orderId
  5212. * @returns {OrderItemListCreateShipment}
  5213. */
  5214. setOrderId(orderId) {
  5215. this.orderId = orderId;
  5216. return this;
  5217. }
  5218. /**
  5219. * Add Line_IDs.
  5220. * @param {number} lineId
  5221. * @returns {OrderItemListCreateShipment}
  5222. */
  5223. addLineId(lineId) {
  5224. this.lineIds.push(lineId);
  5225. return this;
  5226. }
  5227. /**
  5228. * Add OrderItem model.
  5229. * @param {OrderItem} orderItem
  5230. * @throws {Error}
  5231. * @returns {OrderItemListCreateShipment}
  5232. */
  5233. addOrderItem(orderItem) {
  5234. if (!util.isInstanceOf(orderItem, models.OrderItem)) {
  5235. throw new Error(util.format('Expected instance of OrderItem but got %s',
  5236. typeof orderItem));
  5237. }
  5238. if (orderItem.getLineId()) {
  5239. this.lineIds.push(orderItem.getLineId());
  5240. }
  5241. return this;
  5242. }
  5243. /**
  5244. * Reduce the request to a an object.
  5245. * @override
  5246. * @returns {Object}
  5247. */
  5248. toObject() {
  5249. var data = super.toObject();
  5250. data['Order_ID'] = this.getOrderId();
  5251. data['Line_IDs'] = this.lineIds;
  5252. return data;
  5253. }
  5254. /**
  5255. * Create a response object from the response data.
  5256. * @override
  5257. * @returns {Response}
  5258. */
  5259. createResponse(data) {
  5260. return new responses.OrderItemListCreateShipment(this, data);
  5261. }
  5262. }
  5263. /**
  5264. * Handles API Request OrderItemList_Delete. Scope: Store.
  5265. * @see https://docs.miva.com/json-api/functions/orderitemlist_delete
  5266. */
  5267. class OrderItemListDelete extends Request {
  5268. /**
  5269. * OrderItemListDelete Constructor.
  5270. * @param {?Client} client
  5271. * @param {?Order} order
  5272. */
  5273. constructor(client, order = null) {
  5274. super(client);
  5275. this.function = 'OrderItemList_Delete';
  5276. this.scope = Request.REQUEST_SCOPE_STORE;
  5277. this.orderId = null;
  5278. this.lineIds = [];
  5279. if (util.isInstanceOf(order, models.Order)) {
  5280. this.setOrderId(order.getId());
  5281. }
  5282. }
  5283. /**
  5284. * Get Order_ID.
  5285. * @returns {number}
  5286. */
  5287. getOrderId() {
  5288. return this.orderId;
  5289. }
  5290. /**
  5291. * Get Line_IDs.
  5292. * @returns {Array}
  5293. */
  5294. getLineIds() {
  5295. return this.lineIds;
  5296. }
  5297. /**
  5298. * Set Order_ID.
  5299. * @param {number} orderId
  5300. * @returns {OrderItemListDelete}
  5301. */
  5302. setOrderId(orderId) {
  5303. this.orderId = orderId;
  5304. return this;
  5305. }
  5306. /**
  5307. * Add Line_IDs.
  5308. * @param {number} lineId
  5309. * @returns {OrderItemListDelete}
  5310. */
  5311. addLineId(lineId) {
  5312. this.lineIds.push(lineId);
  5313. return this;
  5314. }
  5315. /**
  5316. * Add OrderItem model.
  5317. * @param {OrderItem} orderItem
  5318. * @throws {Error}
  5319. * @returns {OrderItemListDelete}
  5320. */
  5321. addOrderItem(orderItem) {
  5322. if (!util.isInstanceOf(orderItem, models.OrderItem)) {
  5323. throw new Error(util.format('Expected instance of OrderItem but got %s',
  5324. typeof orderItem));
  5325. }
  5326. if (orderItem.getLineId()) {
  5327. this.lineIds.push(orderItem.getLineId());
  5328. }
  5329. return this;
  5330. }
  5331. /**
  5332. * Reduce the request to a an object.
  5333. * @override
  5334. * @returns {Object}
  5335. */
  5336. toObject() {
  5337. var data = super.toObject();
  5338. data['Order_ID'] = this.orderId;
  5339. data['Line_IDs'] = this.lineIds;
  5340. return data;
  5341. }
  5342. /**
  5343. * Create a response object from the response data.
  5344. * @override
  5345. * @returns {Response}
  5346. */
  5347. createResponse(data) {
  5348. return new responses.OrderItemListDelete(this, data);
  5349. }
  5350. }
  5351. /**
  5352. * Handles API Request OrderItem_Add. Scope: Store.
  5353. * @see https://docs.miva.com/json-api/functions/orderitem_add
  5354. */
  5355. class OrderItemAdd extends Request {
  5356. /**
  5357. * OrderItemAdd Constructor.
  5358. * @param {?Client} client
  5359. * @param {?Order} order
  5360. */
  5361. constructor(client, order = null) {
  5362. super(client);
  5363. this.function = 'OrderItem_Add';
  5364. this.scope = Request.REQUEST_SCOPE_STORE;
  5365. this.orderId = null;
  5366. this.code = null;
  5367. this.name = null;
  5368. this.sku = null;
  5369. this.quantity = null;
  5370. this.price = null;
  5371. this.weight = null;
  5372. this.taxable = null;
  5373. this.options = [];
  5374. if (util.isInstanceOf(order, models.Order)) {
  5375. this.setOrderId(order.getId());
  5376. }
  5377. }
  5378. /**
  5379. * Get Order_ID.
  5380. * @returns {number}
  5381. */
  5382. getOrderId() {
  5383. return this.orderId;
  5384. }
  5385. /**
  5386. * Get Code.
  5387. * @returns {string}
  5388. */
  5389. getCode() {
  5390. return this.code;
  5391. }
  5392. /**
  5393. * Get Name.
  5394. * @returns {string}
  5395. */
  5396. getName() {
  5397. return this.name;
  5398. }
  5399. /**
  5400. * Get Sku.
  5401. * @returns {string}
  5402. */
  5403. getSku() {
  5404. return this.sku;
  5405. }
  5406. /**
  5407. * Get Quantity.
  5408. * @returns {number}
  5409. */
  5410. getQuantity() {
  5411. return this.quantity;
  5412. }
  5413. /**
  5414. * Get Price.
  5415. * @returns {number}
  5416. */
  5417. getPrice() {
  5418. return this.price;
  5419. }
  5420. /**
  5421. * Get Weight.
  5422. * @returns {number}
  5423. */
  5424. getWeight() {
  5425. return this.weight;
  5426. }
  5427. /**
  5428. * Get Taxable.
  5429. * @returns {boolean}
  5430. */
  5431. getTaxable() {
  5432. return this.taxable;
  5433. }
  5434. /**
  5435. * Get Options.
  5436. * @returns {OrderItemOption[]}
  5437. */
  5438. getOptions() {
  5439. return this.options;
  5440. }
  5441. /**
  5442. * Set Order_ID.
  5443. * @param {number} orderId
  5444. * @returns {OrderItemAdd}
  5445. */
  5446. setOrderId(orderId) {
  5447. this.orderId = orderId;
  5448. return this;
  5449. }
  5450. /**
  5451. * Set Code.
  5452. * @param {string} code
  5453. * @returns {OrderItemAdd}
  5454. */
  5455. setCode(code) {
  5456. this.code = code;
  5457. return this;
  5458. }
  5459. /**
  5460. * Set Name.
  5461. * @param {string} name
  5462. * @returns {OrderItemAdd}
  5463. */
  5464. setName(name) {
  5465. this.name = name;
  5466. return this;
  5467. }
  5468. /**
  5469. * Set Sku.
  5470. * @param {string} sku
  5471. * @returns {OrderItemAdd}
  5472. */
  5473. setSku(sku) {
  5474. this.sku = sku;
  5475. return this;
  5476. }
  5477. /**
  5478. * Set Quantity.
  5479. * @param {number} quantity
  5480. * @returns {OrderItemAdd}
  5481. */
  5482. setQuantity(quantity) {
  5483. this.quantity = quantity;
  5484. return this;
  5485. }
  5486. /**
  5487. * Set Price.
  5488. * @param {number} price
  5489. * @returns {OrderItemAdd}
  5490. */
  5491. setPrice(price) {
  5492. this.price = price;
  5493. return this;
  5494. }
  5495. /**
  5496. * Set Weight.
  5497. * @param {number} weight
  5498. * @returns {OrderItemAdd}
  5499. */
  5500. setWeight(weight) {
  5501. this.weight = weight;
  5502. return this;
  5503. }
  5504. /**
  5505. * Set Taxable.
  5506. * @param {boolean} taxable
  5507. * @returns {OrderItemAdd}
  5508. */
  5509. setTaxable(taxable) {
  5510. this.taxable = taxable;
  5511. return this;
  5512. }
  5513. /**
  5514. * Set Options.
  5515. * @param {OrderItemOption[]} options
  5516. * @throws {Error}
  5517. * @returns {OrderItemAdd}
  5518. */
  5519. setOptions(options) {
  5520. var i;
  5521. var l;
  5522. if (!util.isArray(options)) {
  5523. throw new Error(util.format('Expected an array but got %s', typeof options));
  5524. }
  5525. for (i = 0, l = options.length; i < l; i++) {
  5526. if (!util.isInstanceOf(options[i], models.OrderItemOption) && util.isObject(options[i])) {
  5527. options[i] = new models.OrderItemOption(options[i]);
  5528. } else if (!util.isInstanceOf(options[i], models.OrderItemOption)) {
  5529. throw new Error(util.format('Expected instance of OrderItemOption or an Object but got %s',
  5530. typeof options[i]));
  5531. }
  5532. }
  5533. this.options = options;
  5534. return this;
  5535. }
  5536. /**
  5537. * Add Options.
  5538. * @param {OrderItemOption} option
  5539. * @throws {Error}
  5540. * @returns {OrderItemAdd}
  5541. */
  5542. addOption(option) {
  5543. if (util.isInstanceOf(option, models.OrderItemOption)) {
  5544. this.options.push(option);
  5545. } else if (util.isObject(option)) {
  5546. this.options.push(new models.OrderItemOption(option));
  5547. } else {
  5548. throw new Error(util.format('Expected instance of OrderItemOption or Object but got %s',
  5549. typeof option));
  5550. }
  5551. return this;
  5552. }
  5553. /**
  5554. * Add many OrderItemOption.
  5555. * @param {OrderItemOption[]} options
  5556. * @throws {Error}
  5557. * @returns {OrderItemAdd}
  5558. */
  5559. addOptions(options) {
  5560. var i;
  5561. var l;
  5562. if (!util.isArray(options)) {
  5563. throw new Error(util.format('Expecting an array of OrderItemOption but got %s',
  5564. typeof options));
  5565. }
  5566. for (i = 0, l = options.length; i < l; i++) {
  5567. if (util.isInstanceOf(options[i], models.OrderItemOption)) {
  5568. this.options.push(options[i]);
  5569. } else if (util.isObject(options[i])) {
  5570. this.options.push(new models.OrderItemOption(options[i]));
  5571. } else {
  5572. throw new Error(util.format('Expected array of OrderItemOption or an array of Object but got %s',
  5573. typeof options[i]));
  5574. }
  5575. }
  5576. return this;
  5577. }
  5578. /**
  5579. * Reduce the request to a an object.
  5580. * @override
  5581. * @returns {Object}
  5582. */
  5583. toObject() {
  5584. var i;
  5585. var l;
  5586. var data = super.toObject();
  5587. data['Order_ID'] = this.getOrderId();
  5588. data['Code'] = this.code;
  5589. data['Name'] = this.name;
  5590. if (!util.isNullOrUndefined(this.sku)) {
  5591. data['Sku'] = this.sku;
  5592. }
  5593. data['Quantity'] = this.quantity;
  5594. if (!util.isNullOrUndefined(this.price)) {
  5595. data['Price'] = this.price;
  5596. }
  5597. if (!util.isNullOrUndefined(this.weight)) {
  5598. data['Weight'] = this.weight;
  5599. }
  5600. if (!util.isNullOrUndefined(this.taxable)) {
  5601. data['Taxable'] = this.taxable;
  5602. }
  5603. if (util.isArray(this.options)) {
  5604. data['Options'] = [];
  5605. for (i = 0, l = this.options.length; i < l; i++) {
  5606. if (util.isObject(this.options[i])) {
  5607. data['Options'].push(this.options[i].toObject());
  5608. }
  5609. }
  5610. }
  5611. return data;
  5612. }
  5613. /**
  5614. * Create a response object from the response data.
  5615. * @override
  5616. * @returns {Response}
  5617. */
  5618. createResponse(data) {
  5619. return new responses.OrderItemAdd(this, data);
  5620. }
  5621. }
  5622. /**
  5623. * Handles API Request OrderItem_Update. Scope: Store.
  5624. * @see https://docs.miva.com/json-api/functions/orderitem_update
  5625. */
  5626. class OrderItemUpdate extends Request {
  5627. /**
  5628. * OrderItemUpdate Constructor.
  5629. * @param {?Client} client
  5630. * @param {?OrderItem} orderItem
  5631. */
  5632. constructor(client, orderItem = null) {
  5633. super(client);
  5634. var i;
  5635. var l;
  5636. var options;
  5637. var attribute;
  5638. this.function = 'OrderItem_Update';
  5639. this.scope = Request.REQUEST_SCOPE_STORE;
  5640. this.orderId = null;
  5641. this.lineId = null;
  5642. this.code = null;
  5643. this.name = null;
  5644. this.sku = null;
  5645. this.quantity = null;
  5646. this.price = null;
  5647. this.weight = null;
  5648. this.taxable = null;
  5649. this.options = [];
  5650. if (util.isInstanceOf(orderItem, models.OrderItem)) {
  5651. this.setOrderId(orderItem.getOrderId());
  5652. this.setLineId(orderItem.getLineId());
  5653. this.setCode(orderItem.getCode());
  5654. this.setName(orderItem.getName());
  5655. this.setSku(orderItem.getSku());
  5656. this.setQuantity(orderItem.getQuantity());
  5657. this.setPrice(orderItem.getPrice());
  5658. this.setWeight(orderItem.getWeight());
  5659. this.setTaxable(orderItem.getTaxable());
  5660. if (orderItem.getOptions() && orderItem.getOptions().length) {
  5661. this.options = orderItem.getOptions();
  5662. }
  5663. }
  5664. }
  5665. /**
  5666. * Get Order_ID.
  5667. * @returns {number}
  5668. */
  5669. getOrderId() {
  5670. return this.orderId;
  5671. }
  5672. /**
  5673. * Get Line_ID.
  5674. * @returns {number}
  5675. */
  5676. getLineId() {
  5677. return this.lineId;
  5678. }
  5679. /**
  5680. * Get Code.
  5681. * @returns {string}
  5682. */
  5683. getCode() {
  5684. return this.code;
  5685. }
  5686. /**
  5687. * Get Name.
  5688. * @returns {string}
  5689. */
  5690. getName() {
  5691. return this.name;
  5692. }
  5693. /**
  5694. * Get Sku.
  5695. * @returns {string}
  5696. */
  5697. getSku() {
  5698. return this.sku;
  5699. }
  5700. /**
  5701. * Get Quantity.
  5702. * @returns {number}
  5703. */
  5704. getQuantity() {
  5705. return this.quantity;
  5706. }
  5707. /**
  5708. * Get Price.
  5709. * @returns {number}
  5710. */
  5711. getPrice() {
  5712. return this.price;
  5713. }
  5714. /**
  5715. * Get Weight.
  5716. * @returns {number}
  5717. */
  5718. getWeight() {
  5719. return this.weight;
  5720. }
  5721. /**
  5722. * Get Taxable.
  5723. * @returns {boolean}
  5724. */
  5725. getTaxable() {
  5726. return this.taxable;
  5727. }
  5728. /**
  5729. * Get Options.
  5730. * @returns {OrderItemOption[]}
  5731. */
  5732. getOptions() {
  5733. return this.options;
  5734. }
  5735. /**
  5736. * Set Order_ID.
  5737. * @param {number} orderId
  5738. * @returns {OrderItemUpdate}
  5739. */
  5740. setOrderId(orderId) {
  5741. this.orderId = orderId;
  5742. return this;
  5743. }
  5744. /**
  5745. * Set Line_ID.
  5746. * @param {number} lineId
  5747. * @returns {OrderItemUpdate}
  5748. */
  5749. setLineId(lineId) {
  5750. this.lineId = lineId;
  5751. return this;
  5752. }
  5753. /**
  5754. * Set Code.
  5755. * @param {string} code
  5756. * @returns {OrderItemUpdate}
  5757. */
  5758. setCode(code) {
  5759. this.code = code;
  5760. return this;
  5761. }
  5762. /**
  5763. * Set Name.
  5764. * @param {string} name
  5765. * @returns {OrderItemUpdate}
  5766. */
  5767. setName(name) {
  5768. this.name = name;
  5769. return this;
  5770. }
  5771. /**
  5772. * Set Sku.
  5773. * @param {string} sku
  5774. * @returns {OrderItemUpdate}
  5775. */
  5776. setSku(sku) {
  5777. this.sku = sku;
  5778. return this;
  5779. }
  5780. /**
  5781. * Set Quantity.
  5782. * @param {number} quantity
  5783. * @returns {OrderItemUpdate}
  5784. */
  5785. setQuantity(quantity) {
  5786. this.quantity = quantity;
  5787. return this;
  5788. }
  5789. /**
  5790. * Set Price.
  5791. * @param {number} price
  5792. * @returns {OrderItemUpdate}
  5793. */
  5794. setPrice(price) {
  5795. this.price = price;
  5796. return this;
  5797. }
  5798. /**
  5799. * Set Weight.
  5800. * @param {number} weight
  5801. * @returns {OrderItemUpdate}
  5802. */
  5803. setWeight(weight) {
  5804. this.weight = weight;
  5805. return this;
  5806. }
  5807. /**
  5808. * Set Taxable.
  5809. * @param {boolean} taxable
  5810. * @returns {OrderItemUpdate}
  5811. */
  5812. setTaxable(taxable) {
  5813. this.taxable = taxable;
  5814. return this;
  5815. }
  5816. /**
  5817. * Set Options.
  5818. * @param {OrderItemOption[]} options
  5819. * @throws {Error}
  5820. * @returns {OrderItemUpdate}
  5821. */
  5822. setOptions(options) {
  5823. var i;
  5824. var l;
  5825. if (!util.isArray(options)) {
  5826. throw new Error(util.format('Expected an array but got %s', typeof options));
  5827. }
  5828. for (i = 0, l = options.length; i < l; i++) {
  5829. if (!util.isInstanceOf(options[i], models.OrderItemOption) && util.isObject(options[i])) {
  5830. options[i] = new models.OrderItemOption(options[i]);
  5831. } else if (!util.isInstanceOf(options[i], models.OrderItemOption)) {
  5832. throw new Error(util.format('Expected instance of OrderItemOption or an Object but got %s',
  5833. typeof options[i]));
  5834. }
  5835. }
  5836. this.options = options;
  5837. return this;
  5838. }
  5839. /**
  5840. * Add Options.
  5841. * @param {OrderItemOption} option
  5842. * @throws {Error}
  5843. * @returns {OrderItemUpdate}
  5844. */
  5845. addOption(option) {
  5846. if (util.isInstanceOf(option, models.OrderItemOption)) {
  5847. this.options.push(option);
  5848. } else if (util.isObject(option)) {
  5849. this.options.push(new models.OrderItemOption(option));
  5850. } else {
  5851. throw new Error(util.format('Expected instance of OrderItemOption or Object but got %s',
  5852. typeof option));
  5853. }
  5854. return this;
  5855. }
  5856. /**
  5857. * Add many OrderItemOption.
  5858. * @param {OrderItemOption[]} options
  5859. * @throws {Error}
  5860. * @returns {OrderItemUpdate}
  5861. */
  5862. addOptions(options) {
  5863. var i;
  5864. var l;
  5865. if (!util.isArray(options)) {
  5866. throw new Error(util.format('Expecting an array of OrderItemOption but got %s',
  5867. typeof options));
  5868. }
  5869. for (i = 0, l = options.length; i < l; i++) {
  5870. if (util.isInstanceOf(options[i], models.OrderItemOption)) {
  5871. this.options.push(options[i]);
  5872. } else if (util.isObject(options[i])) {
  5873. this.options.push(new models.OrderItemOption(options[i]));
  5874. } else {
  5875. throw new Error(util.format('Expected array of OrderItemOption or an array of Object but got %s',
  5876. typeof options[i]));
  5877. }
  5878. }
  5879. return this;
  5880. }
  5881. /**
  5882. * Reduce the request to a an object.
  5883. * @override
  5884. * @returns {Object}
  5885. */
  5886. toObject() {
  5887. var i;
  5888. var l;
  5889. var data = super.toObject();
  5890. data['Order_ID'] = this.getOrderId();
  5891. data['Line_ID'] = this.getLineId();
  5892. if (!util.isNullOrUndefined(this.code)) {
  5893. data['Code'] = this.code;
  5894. }
  5895. if (!util.isNullOrUndefined(this.name)) {
  5896. data['Name'] = this.name;
  5897. }
  5898. if (!util.isNullOrUndefined(this.sku)) {
  5899. data['Sku'] = this.sku;
  5900. }
  5901. if (!util.isNullOrUndefined(this.quantity)) {
  5902. data['Quantity'] = this.quantity;
  5903. }
  5904. if (!util.isNullOrUndefined(this.price)) {
  5905. data['Price'] = this.price;
  5906. }
  5907. if (!util.isNullOrUndefined(this.weight)) {
  5908. data['Weight'] = this.weight;
  5909. }
  5910. if (!util.isNullOrUndefined(this.taxable)) {
  5911. data['Taxable'] = this.taxable;
  5912. }
  5913. if (util.isArray(this.options)) {
  5914. data['Options'] = [];
  5915. for (i = 0, l = this.options.length; i < l; i++) {
  5916. if (util.isObject(this.options[i])) {
  5917. data['Options'].push(this.options[i].toObject());
  5918. }
  5919. }
  5920. }
  5921. return data;
  5922. }
  5923. /**
  5924. * Create a response object from the response data.
  5925. * @override
  5926. * @returns {Response}
  5927. */
  5928. createResponse(data) {
  5929. return new responses.OrderItemUpdate(this, data);
  5930. }
  5931. }
  5932. /** PAY_STATUS_FILTER constants. */
  5933. /** @ignore */
  5934. const PAY_STATUS_FILTER_AUTH_ONLY = 'auth_0_capt';
  5935. /** @ignore */
  5936. const PAY_STATUS_FILTER_PARTIAL_CAPTURE = 'partial_capt';
  5937. /** @ignore */
  5938. const PAY_STATUS_FILTER_CAPTURED_NOT_SHIPPED = 'capt_not_ship';
  5939. /** @ignore */
  5940. const PAY_STATUS_FILTER_SHIPPED_NOT_CAPTURED = 'ship_not_capt';
  5941. /**
  5942. * Handles API Request OrderList_Load_Query. Scope: Store.
  5943. * @see https://docs.miva.com/json-api/functions/orderlist_load_query
  5944. */
  5945. class OrderListLoadQuery extends ListQueryRequest {
  5946. /**
  5947. * OrderListLoadQuery Constructor.
  5948. * @param {?Client} client
  5949. */
  5950. constructor(client) {
  5951. super(client);
  5952. this.function = 'OrderList_Load_Query';
  5953. this.scope = Request.REQUEST_SCOPE_STORE;
  5954. this.availableSearchFields = [
  5955. 'id',
  5956. 'batch_id',
  5957. 'status',
  5958. 'pay_status',
  5959. 'orderdate',
  5960. 'dt_instock',
  5961. 'ship_res',
  5962. 'ship_fname',
  5963. 'ship_lname',
  5964. 'ship_email',
  5965. 'ship_comp',
  5966. 'ship_phone',
  5967. 'ship_fax',
  5968. 'ship_addr1',
  5969. 'ship_addr2',
  5970. 'ship_city',
  5971. 'ship_state',
  5972. 'ship_zip',
  5973. 'ship_cntry',
  5974. 'bill_fname',
  5975. 'bill_lname',
  5976. 'bill_email',
  5977. 'bill_comp',
  5978. 'bill_phone',
  5979. 'bill_fax',
  5980. 'bill_addr1',
  5981. 'bill_addr2',
  5982. 'bill_city',
  5983. 'bill_state',
  5984. 'bill_zip',
  5985. 'bill_cntry',
  5986. 'ship_id',
  5987. 'ship_data',
  5988. 'source',
  5989. 'source_id',
  5990. 'total',
  5991. 'total_ship',
  5992. 'total_tax',
  5993. 'total_auth',
  5994. 'total_capt',
  5995. 'total_rfnd',
  5996. 'net_capt',
  5997. 'pend_count',
  5998. 'bord_count',
  5999. 'cust_login',
  6000. 'cust_pw_email',
  6001. 'business_title',
  6002. 'note_count'
  6003. ];
  6004. this.availableSortFields = [
  6005. 'id',
  6006. 'batch_id',
  6007. 'status',
  6008. 'pay_status',
  6009. 'orderdate',
  6010. 'dt_instock',
  6011. 'ship_res',
  6012. 'ship_fname',
  6013. 'ship_lname',
  6014. 'ship_email',
  6015. 'ship_comp',
  6016. 'ship_phone',
  6017. 'ship_fax',
  6018. 'ship_addr1',
  6019. 'ship_addr2',
  6020. 'ship_city',
  6021. 'ship_state',
  6022. 'ship_zip',
  6023. 'ship_cntry',
  6024. 'bill_fname',
  6025. 'bill_lname',
  6026. 'bill_email',
  6027. 'bill_comp',
  6028. 'bill_phone',
  6029. 'bill_fax',
  6030. 'bill_addr1',
  6031. 'bill_addr2',
  6032. 'bill_city',
  6033. 'bill_state',
  6034. 'bill_zip',
  6035. 'bill_cntry',
  6036. 'ship_data',
  6037. 'source',
  6038. 'source_id',
  6039. 'total',
  6040. 'total_ship',
  6041. 'total_tax',
  6042. 'total_auth',
  6043. 'total_capt',
  6044. 'total_rfnd',
  6045. 'net_capt',
  6046. 'pend_count',
  6047. 'bord_count',
  6048. 'cust_login',
  6049. 'cust_pw_email',
  6050. 'business_title',
  6051. 'note_count',
  6052. 'payment_module'
  6053. ];
  6054. this.availableOnDemandColumns = [
  6055. 'ship_method',
  6056. 'cust_login',
  6057. 'cust_pw_email',
  6058. 'business_title',
  6059. 'payment_module',
  6060. 'customer',
  6061. 'items',
  6062. 'charges',
  6063. 'coupons',
  6064. 'discounts',
  6065. 'payments',
  6066. 'notes'
  6067. ];
  6068. this.availableCustomFilters = {
  6069. Customer_ID : 'int',
  6070. BusinessAccount_ID : 'int',
  6071. pay_id : 'int',
  6072. payment : [
  6073. PAY_STATUS_FILTER_AUTH_ONLY,
  6074. PAY_STATUS_FILTER_PARTIAL_CAPTURE,
  6075. PAY_STATUS_FILTER_CAPTURED_NOT_SHIPPED,
  6076. PAY_STATUS_FILTER_SHIPPED_NOT_CAPTURED
  6077. ],
  6078. product_code : 'string'
  6079. };
  6080. this.passphrase = null;
  6081. }
  6082. /**
  6083. * Constant PAY_STATUS_FILTER_AUTH_ONLY
  6084. * @returns {string}
  6085. * @const
  6086. * @static
  6087. */
  6088. static get PAY_STATUS_FILTER_AUTH_ONLY() {
  6089. return PAY_STATUS_FILTER_AUTH_ONLY;
  6090. }
  6091. /**
  6092. * Constant PAY_STATUS_FILTER_PARTIAL_CAPTURE
  6093. * @returns {string}
  6094. * @const
  6095. * @static
  6096. */
  6097. static get PAY_STATUS_FILTER_PARTIAL_CAPTURE() {
  6098. return PAY_STATUS_FILTER_PARTIAL_CAPTURE;
  6099. }
  6100. /**
  6101. * Constant PAY_STATUS_FILTER_CAPTURED_NOT_SHIPPED
  6102. * @returns {string}
  6103. * @const
  6104. * @static
  6105. */
  6106. static get PAY_STATUS_FILTER_CAPTURED_NOT_SHIPPED() {
  6107. return PAY_STATUS_FILTER_CAPTURED_NOT_SHIPPED;
  6108. }
  6109. /**
  6110. * Constant PAY_STATUS_FILTER_SHIPPED_NOT_CAPTURED
  6111. * @returns {string}
  6112. * @const
  6113. * @static
  6114. */
  6115. static get PAY_STATUS_FILTER_SHIPPED_NOT_CAPTURED() {
  6116. return PAY_STATUS_FILTER_SHIPPED_NOT_CAPTURED;
  6117. }
  6118. /**
  6119. * Get Passphrase.
  6120. * @returns {string}
  6121. */
  6122. getPassphrase() {
  6123. return this.passphrase;
  6124. }
  6125. /**
  6126. * Set Passphrase.
  6127. * @param {string} passphrase
  6128. * @returns {OrderListLoadQuery}
  6129. */
  6130. setPassphrase(passphrase) {
  6131. this.passphrase = passphrase;
  6132. return this;
  6133. }
  6134. /**
  6135. * Reduce the request to a an object.
  6136. * @override
  6137. * @returns {Object}
  6138. */
  6139. toObject() {
  6140. var data = super.toObject();
  6141. if (!util.isNullOrUndefined(this.passphrase)) {
  6142. data['Passphrase'] = this.passphrase;
  6143. }
  6144. return data;
  6145. }
  6146. /**
  6147. * Create a response object from the response data.
  6148. * @override
  6149. * @returns {Response}
  6150. */
  6151. createResponse(data) {
  6152. return new responses.OrderListLoadQuery(this, data);
  6153. }
  6154. }
  6155. /**
  6156. * Handles API Request OrderPayment_Capture. Scope: Store.
  6157. * @see https://docs.miva.com/json-api/functions/orderpayment_capture
  6158. */
  6159. class OrderPaymentCapture extends Request {
  6160. /**
  6161. * OrderPaymentCapture Constructor.
  6162. * @param {?Client} client
  6163. * @param {?OrderPayment} orderPayment
  6164. */
  6165. constructor(client, orderPayment = null) {
  6166. super(client);
  6167. this.function = 'OrderPayment_Capture';
  6168. this.scope = Request.REQUEST_SCOPE_STORE;
  6169. this.orderPaymentId = null;
  6170. this.amount = null;
  6171. if (util.isInstanceOf(orderPayment, models.OrderPayment)) {
  6172. this.setOrderPaymentId(orderPayment.getId());
  6173. }
  6174. }
  6175. /**
  6176. * Get OrderPayment_ID.
  6177. * @returns {number}
  6178. */
  6179. getOrderPaymentId() {
  6180. return this.orderPaymentId;
  6181. }
  6182. /**
  6183. * Get Amount.
  6184. * @returns {number}
  6185. */
  6186. getAmount() {
  6187. return this.amount;
  6188. }
  6189. /**
  6190. * Set OrderPayment_ID.
  6191. * @param {number} orderPaymentId
  6192. * @returns {OrderPaymentCapture}
  6193. */
  6194. setOrderPaymentId(orderPaymentId) {
  6195. this.orderPaymentId = orderPaymentId;
  6196. return this;
  6197. }
  6198. /**
  6199. * Set Amount.
  6200. * @param {number} amount
  6201. * @returns {OrderPaymentCapture}
  6202. */
  6203. setAmount(amount) {
  6204. this.amount = amount;
  6205. return this;
  6206. }
  6207. /**
  6208. * Reduce the request to a an object.
  6209. * @override
  6210. * @returns {Object}
  6211. */
  6212. toObject() {
  6213. var data = super.toObject();
  6214. data['OrderPayment_ID'] = this.orderPaymentId;
  6215. if (!util.isNullOrUndefined(this.amount)) {
  6216. data['Amount'] = this.amount;
  6217. }
  6218. return data;
  6219. }
  6220. /**
  6221. * Create a response object from the response data.
  6222. * @override
  6223. * @returns {Response}
  6224. */
  6225. createResponse(data) {
  6226. return new responses.OrderPaymentCapture(this, data);
  6227. }
  6228. }
  6229. /**
  6230. * Handles API Request OrderPayment_Refund. Scope: Store.
  6231. * @see https://docs.miva.com/json-api/functions/orderpayment_refund
  6232. */
  6233. class OrderPaymentRefund extends Request {
  6234. /**
  6235. * OrderPaymentRefund Constructor.
  6236. * @param {?Client} client
  6237. * @param {?OrderPayment} orderPayment
  6238. */
  6239. constructor(client, orderPayment = null) {
  6240. super(client);
  6241. this.function = 'OrderPayment_Refund';
  6242. this.scope = Request.REQUEST_SCOPE_STORE;
  6243. this.orderPaymentId = null;
  6244. this.amount = null;
  6245. if (util.isInstanceOf(orderPayment, models.OrderPayment)) {
  6246. this.setOrderPaymentId(orderPayment.getId());
  6247. }
  6248. }
  6249. /**
  6250. * Get OrderPayment_ID.
  6251. * @returns {number}
  6252. */
  6253. getOrderPaymentId() {
  6254. return this.orderPaymentId;
  6255. }
  6256. /**
  6257. * Get Amount.
  6258. * @returns {number}
  6259. */
  6260. getAmount() {
  6261. return this.amount;
  6262. }
  6263. /**
  6264. * Set OrderPayment_ID.
  6265. * @param {number} orderPaymentId
  6266. * @returns {OrderPaymentRefund}
  6267. */
  6268. setOrderPaymentId(orderPaymentId) {
  6269. this.orderPaymentId = orderPaymentId;
  6270. return this;
  6271. }
  6272. /**
  6273. * Set Amount.
  6274. * @param {number} amount
  6275. * @returns {OrderPaymentRefund}
  6276. */
  6277. setAmount(amount) {
  6278. this.amount = amount;
  6279. return this;
  6280. }
  6281. /**
  6282. * Reduce the request to a an object.
  6283. * @override
  6284. * @returns {Object}
  6285. */
  6286. toObject() {
  6287. var data = super.toObject();
  6288. data['OrderPayment_ID'] = this.orderPaymentId;
  6289. if (!util.isNullOrUndefined(this.amount)) {
  6290. data['Amount'] = this.amount;
  6291. }
  6292. return data;
  6293. }
  6294. /**
  6295. * Create a response object from the response data.
  6296. * @override
  6297. * @returns {Response}
  6298. */
  6299. createResponse(data) {
  6300. return new responses.OrderPaymentRefund(this, data);
  6301. }
  6302. }
  6303. /**
  6304. * Handles API Request OrderPayment_VOID. Scope: Store.
  6305. * @see https://docs.miva.com/json-api/functions/orderpayment_void
  6306. */
  6307. class OrderPaymentVoid extends Request {
  6308. /**
  6309. * OrderPaymentVoid Constructor.
  6310. * @param {?Client} client
  6311. * @param {?OrderPayment} orderPayment
  6312. */
  6313. constructor(client, orderPayment = null) {
  6314. super(client);
  6315. this.function = 'OrderPayment_VOID';
  6316. this.scope = Request.REQUEST_SCOPE_STORE;
  6317. this.orderPaymentId = null;
  6318. this.amount = null;
  6319. if (util.isInstanceOf(orderPayment, models.OrderPayment)) {
  6320. this.setOrderPaymentId(orderPayment.getId());
  6321. }
  6322. }
  6323. /**
  6324. * Get OrderPayment_ID.
  6325. * @returns {number}
  6326. */
  6327. getOrderPaymentId() {
  6328. return this.orderPaymentId;
  6329. }
  6330. /**
  6331. * Get Amount.
  6332. * @returns {number}
  6333. */
  6334. getAmount() {
  6335. return this.amount;
  6336. }
  6337. /**
  6338. * Set OrderPayment_ID.
  6339. * @param {number} orderPaymentId
  6340. * @returns {OrderPaymentVoid}
  6341. */
  6342. setOrderPaymentId(orderPaymentId) {
  6343. this.orderPaymentId = orderPaymentId;
  6344. return this;
  6345. }
  6346. /**
  6347. * Set Amount.
  6348. * @param {number} amount
  6349. * @returns {OrderPaymentVoid}
  6350. */
  6351. setAmount(amount) {
  6352. this.amount = amount;
  6353. return this;
  6354. }
  6355. /**
  6356. * Reduce the request to a an object.
  6357. * @override
  6358. * @returns {Object}
  6359. */
  6360. toObject() {
  6361. var data = super.toObject();
  6362. data['OrderPayment_ID'] = this.orderPaymentId;
  6363. if (!util.isNullOrUndefined(this.amount)) {
  6364. data['Amount'] = this.amount;
  6365. }
  6366. return data;
  6367. }
  6368. /**
  6369. * Create a response object from the response data.
  6370. * @override
  6371. * @returns {Response}
  6372. */
  6373. createResponse(data) {
  6374. return new responses.OrderPaymentVoid(this, data);
  6375. }
  6376. }
  6377. /**
  6378. * Handles API Request OrderShipmentList_Update. Scope: Store.
  6379. * @see https://docs.miva.com/json-api/functions/ordershipmentlist_update
  6380. */
  6381. class OrderShipmentListUpdate extends Request {
  6382. /**
  6383. * OrderShipmentListUpdate Constructor.
  6384. * @param {?Client} client
  6385. */
  6386. constructor(client) {
  6387. super(client);
  6388. this.function = 'OrderShipmentList_Update';
  6389. this.scope = Request.REQUEST_SCOPE_STORE;
  6390. this.shipmentUpdates = [];
  6391. }
  6392. /**
  6393. * Get Shipment_Updates.
  6394. * @returns {OrderShipmentUpdate[]}
  6395. */
  6396. getShipmentUpdates() {
  6397. return this.shipmentUpdates;
  6398. }
  6399. /**
  6400. * Set Shipment_Updates.
  6401. * @param {OrderShipmentUpdate[]} shipmentUpdates
  6402. * @throws {Error}
  6403. * @returns {OrderShipmentListUpdate}
  6404. */
  6405. setShipmentUpdates(shipmentUpdates) {
  6406. var i;
  6407. var l;
  6408. if (!util.isArray(shipmentUpdates)) {
  6409. throw new Error(util.format('Expected an array but got %s', typeof shipmentUpdates));
  6410. }
  6411. for (i = 0, l = shipmentUpdates.length; i < l; i++) {
  6412. if (!util.isInstanceOf(shipmentUpdates[i], models.OrderShipmentUpdate) && util.isObject(shipmentUpdates[i])) {
  6413. shipmentUpdates[i] = new models.OrderShipmentUpdate(shipmentUpdates[i]);
  6414. } else if (!util.isInstanceOf(shipmentUpdates[i], models.OrderShipmentUpdate)) {
  6415. throw new Error(util.format('Expected instance of OrderShipmentUpdate or an Object but got %s',
  6416. typeof shipmentUpdates[i]));
  6417. }
  6418. }
  6419. this.shipmentUpdates = shipmentUpdates;
  6420. return this;
  6421. }
  6422. /**
  6423. * Add Shipment_Updates.
  6424. * @param {OrderShipmentUpdate} shipmentUpdate
  6425. * @throws {Error}
  6426. * @returns {OrderShipmentListUpdate}
  6427. */
  6428. addShipmentUpdate(shipmentUpdate) {
  6429. if (util.isInstanceOf(shipmentUpdate, models.OrderShipmentUpdate)) {
  6430. this.shipmentUpdates.push(shipmentUpdate);
  6431. } else if (util.isObject(shipmentUpdate)) {
  6432. this.shipmentUpdates.push(new models.OrderShipmentUpdate(shipmentUpdate));
  6433. } else {
  6434. throw new Error(util.format('Expected instance of OrderShipmentUpdate or Object but got %s',
  6435. typeof shipmentUpdate));
  6436. }
  6437. return this;
  6438. }
  6439. /**
  6440. * Add many OrderShipmentUpdate.
  6441. * @param {OrderShipmentUpdate[]} shipmentUpdates
  6442. * @throws {Error}
  6443. * @returns {OrderShipmentListUpdate}
  6444. */
  6445. addShipmentUpdates(shipmentUpdates) {
  6446. var i;
  6447. var l;
  6448. if (!util.isArray(shipmentUpdates)) {
  6449. throw new Error(util.format('Expecting an array of OrderShipmentUpdate but got %s',
  6450. typeof shipmentUpdates));
  6451. }
  6452. for (i = 0, l = shipmentUpdates.length; i < l; i++) {
  6453. if (util.isInstanceOf(shipmentUpdates[i], models.OrderShipmentUpdate)) {
  6454. this.shipmentUpdates.push(shipmentUpdates[i]);
  6455. } else if (util.isObject(shipmentUpdates[i])) {
  6456. this.shipmentUpdates.push(new models.OrderShipmentUpdate(shipmentUpdates[i]));
  6457. } else {
  6458. throw new Error(util.format('Expected array of OrderShipmentUpdate or an array of Object but got %s',
  6459. typeof shipmentUpdates[i]));
  6460. }
  6461. }
  6462. return this;
  6463. }
  6464. /**
  6465. * Reduce the request to a an object.
  6466. * @override
  6467. * @returns {Object}
  6468. */
  6469. toObject() {
  6470. var i;
  6471. var l;
  6472. var data = super.toObject();
  6473. if (util.isArray(this.shipmentUpdates)) {
  6474. data['Shipment_Updates'] = [];
  6475. for (i = 0, l = this.shipmentUpdates.length; i < l; i++) {
  6476. data['Shipment_Updates'].push(this.shipmentUpdates[i].toObject());
  6477. }
  6478. }
  6479. return data;
  6480. }
  6481. /**
  6482. * Create a response object from the response data.
  6483. * @override
  6484. * @returns {Response}
  6485. */
  6486. createResponse(data) {
  6487. return new responses.OrderShipmentListUpdate(this, data);
  6488. }
  6489. }
  6490. /**
  6491. * Handles API Request Order_Create. Scope: Store.
  6492. * @see https://docs.miva.com/json-api/functions/order_create
  6493. */
  6494. class OrderCreate extends Request {
  6495. /**
  6496. * OrderCreate Constructor.
  6497. * @param {?Client} client
  6498. * @param {?Customer} customer
  6499. */
  6500. constructor(client, customer = null) {
  6501. super(client);
  6502. this.function = 'Order_Create';
  6503. this.scope = Request.REQUEST_SCOPE_STORE;
  6504. this.customerLogin = null;
  6505. this.customerId = null;
  6506. this.shipFirstName = null;
  6507. this.shipLastName = null;
  6508. this.shipEmail = null;
  6509. this.shipPhone = null;
  6510. this.shipFax = null;
  6511. this.shipCompany = null;
  6512. this.shipAddress1 = null;
  6513. this.shipAddress2 = null;
  6514. this.shipCity = null;
  6515. this.shipState = null;
  6516. this.shipZip = null;
  6517. this.shipCountry = null;
  6518. this.shipResidential = null;
  6519. this.billFirstName = null;
  6520. this.billLastName = null;
  6521. this.billEmail = null;
  6522. this.billPhone = null;
  6523. this.billFax = null;
  6524. this.billCompany = null;
  6525. this.billAddress1 = null;
  6526. this.billAddress2 = null;
  6527. this.billCity = null;
  6528. this.billState = null;
  6529. this.billZip = null;
  6530. this.billCountry = null;
  6531. this.items = [];
  6532. this.products = [];
  6533. this.charges = [];
  6534. this.customFieldValues = new models.CustomFieldValues();
  6535. this.shippingModuleCode = null;
  6536. this.shippingModuleData = null;
  6537. this.calculateCharges = null;
  6538. this.triggerFulfillmentModules = null;
  6539. if (util.isInstanceOf(customer, models.Customer)) {
  6540. if (customer.getId()) {
  6541. this.setCustomerId(customer.getId());
  6542. } else if (customer.getLogin()) {
  6543. this.setCustomerLogin(customer.getLogin());
  6544. }
  6545. }
  6546. }
  6547. /**
  6548. * Get Customer_Login.
  6549. * @returns {string}
  6550. */
  6551. getCustomerLogin() {
  6552. return this.customerLogin;
  6553. }
  6554. /**
  6555. * Get Customer_ID.
  6556. * @returns {number}
  6557. */
  6558. getCustomerId() {
  6559. return this.customerId;
  6560. }
  6561. /**
  6562. * Get ShipFirstName.
  6563. * @returns {string}
  6564. */
  6565. getShipFirstName() {
  6566. return this.shipFirstName;
  6567. }
  6568. /**
  6569. * Get ShipLastName.
  6570. * @returns {string}
  6571. */
  6572. getShipLastName() {
  6573. return this.shipLastName;
  6574. }
  6575. /**
  6576. * Get ShipEmail.
  6577. * @returns {string}
  6578. */
  6579. getShipEmail() {
  6580. return this.shipEmail;
  6581. }
  6582. /**
  6583. * Get ShipPhone.
  6584. * @returns {string}
  6585. */
  6586. getShipPhone() {
  6587. return this.shipPhone;
  6588. }
  6589. /**
  6590. * Get ShipFax.
  6591. * @returns {string}
  6592. */
  6593. getShipFax() {
  6594. return this.shipFax;
  6595. }
  6596. /**
  6597. * Get ShipCompany.
  6598. * @returns {string}
  6599. */
  6600. getShipCompany() {
  6601. return this.shipCompany;
  6602. }
  6603. /**
  6604. * Get ShipAddress1.
  6605. * @returns {string}
  6606. */
  6607. getShipAddress1() {
  6608. return this.shipAddress1;
  6609. }
  6610. /**
  6611. * Get ShipAddress2.
  6612. * @returns {string}
  6613. */
  6614. getShipAddress2() {
  6615. return this.shipAddress2;
  6616. }
  6617. /**
  6618. * Get ShipCity.
  6619. * @returns {string}
  6620. */
  6621. getShipCity() {
  6622. return this.shipCity;
  6623. }
  6624. /**
  6625. * Get ShipState.
  6626. * @returns {string}
  6627. */
  6628. getShipState() {
  6629. return this.shipState;
  6630. }
  6631. /**
  6632. * Get ShipZip.
  6633. * @returns {string}
  6634. */
  6635. getShipZip() {
  6636. return this.shipZip;
  6637. }
  6638. /**
  6639. * Get ShipCountry.
  6640. * @returns {string}
  6641. */
  6642. getShipCountry() {
  6643. return this.shipCountry;
  6644. }
  6645. /**
  6646. * Get ShipResidential.
  6647. * @returns {boolean}
  6648. */
  6649. getShipResidential() {
  6650. return this.shipResidential;
  6651. }
  6652. /**
  6653. * Get BillFirstName.
  6654. * @returns {string}
  6655. */
  6656. getBillFirstName() {
  6657. return this.billFirstName;
  6658. }
  6659. /**
  6660. * Get BillLastName.
  6661. * @returns {string}
  6662. */
  6663. getBillLastName() {
  6664. return this.billLastName;
  6665. }
  6666. /**
  6667. * Get BillEmail.
  6668. * @returns {string}
  6669. */
  6670. getBillEmail() {
  6671. return this.billEmail;
  6672. }
  6673. /**
  6674. * Get BillPhone.
  6675. * @returns {string}
  6676. */
  6677. getBillPhone() {
  6678. return this.billPhone;
  6679. }
  6680. /**
  6681. * Get BillFax.
  6682. * @returns {string}
  6683. */
  6684. getBillFax() {
  6685. return this.billFax;
  6686. }
  6687. /**
  6688. * Get BillCompany.
  6689. * @returns {string}
  6690. */
  6691. getBillCompany() {
  6692. return this.billCompany;
  6693. }
  6694. /**
  6695. * Get BillAddress1.
  6696. * @returns {string}
  6697. */
  6698. getBillAddress1() {
  6699. return this.billAddress1;
  6700. }
  6701. /**
  6702. * Get BillAddress2.
  6703. * @returns {string}
  6704. */
  6705. getBillAddress2() {
  6706. return this.billAddress2;
  6707. }
  6708. /**
  6709. * Get BillCity.
  6710. * @returns {string}
  6711. */
  6712. getBillCity() {
  6713. return this.billCity;
  6714. }
  6715. /**
  6716. * Get BillState.
  6717. * @returns {string}
  6718. */
  6719. getBillState() {
  6720. return this.billState;
  6721. }
  6722. /**
  6723. * Get BillZip.
  6724. * @returns {string}
  6725. */
  6726. getBillZip() {
  6727. return this.billZip;
  6728. }
  6729. /**
  6730. * Get BillCountry.
  6731. * @returns {string}
  6732. */
  6733. getBillCountry() {
  6734. return this.billCountry;
  6735. }
  6736. /**
  6737. * Get Items.
  6738. * @returns {OrderItem[]}
  6739. */
  6740. getItems() {
  6741. return this.items;
  6742. }
  6743. /**
  6744. * Get Products.
  6745. * @returns {OrderProduct[]}
  6746. */
  6747. getProducts() {
  6748. return this.products;
  6749. }
  6750. /**
  6751. * Get Charges.
  6752. * @returns {OrderCharge[]}
  6753. */
  6754. getCharges() {
  6755. return this.charges;
  6756. }
  6757. /**
  6758. * Get CustomField_Values.
  6759. * @returns {?CustomFieldValues}
  6760. */
  6761. getCustomFieldValues() {
  6762. return this.customFieldValues;
  6763. }
  6764. /**
  6765. * Get Shipping_Module_Code.
  6766. * @returns {string}
  6767. */
  6768. getShippingModuleCode() {
  6769. return this.shippingModuleCode;
  6770. }
  6771. /**
  6772. * Get Shipping_Module_Data.
  6773. * @returns {string}
  6774. */
  6775. getShippingModuleData() {
  6776. return this.shippingModuleData;
  6777. }
  6778. /**
  6779. * Get CalculateCharges.
  6780. * @returns {boolean}
  6781. */
  6782. getCalculateCharges() {
  6783. return this.calculateCharges;
  6784. }
  6785. /**
  6786. * Get TriggerFulfillmentModules.
  6787. * @returns {boolean}
  6788. */
  6789. getTriggerFulfillmentModules() {
  6790. return this.triggerFulfillmentModules;
  6791. }
  6792. /**
  6793. * Set Customer_Login.
  6794. * @param {string} customerLogin
  6795. * @returns {OrderCreate}
  6796. */
  6797. setCustomerLogin(customerLogin) {
  6798. this.customerLogin = customerLogin;
  6799. return this;
  6800. }
  6801. /**
  6802. * Set Customer_ID.
  6803. * @param {number} customerId
  6804. * @returns {OrderCreate}
  6805. */
  6806. setCustomerId(customerId) {
  6807. this.customerId = customerId;
  6808. return this;
  6809. }
  6810. /**
  6811. * Set ShipFirstName.
  6812. * @param {string} shipFirstName
  6813. * @returns {OrderCreate}
  6814. */
  6815. setShipFirstName(shipFirstName) {
  6816. this.shipFirstName = shipFirstName;
  6817. return this;
  6818. }
  6819. /**
  6820. * Set ShipLastName.
  6821. * @param {string} shipLastName
  6822. * @returns {OrderCreate}
  6823. */
  6824. setShipLastName(shipLastName) {
  6825. this.shipLastName = shipLastName;
  6826. return this;
  6827. }
  6828. /**
  6829. * Set ShipEmail.
  6830. * @param {string} shipEmail
  6831. * @returns {OrderCreate}
  6832. */
  6833. setShipEmail(shipEmail) {
  6834. this.shipEmail = shipEmail;
  6835. return this;
  6836. }
  6837. /**
  6838. * Set ShipPhone.
  6839. * @param {string} shipPhone
  6840. * @returns {OrderCreate}
  6841. */
  6842. setShipPhone(shipPhone) {
  6843. this.shipPhone = shipPhone;
  6844. return this;
  6845. }
  6846. /**
  6847. * Set ShipFax.
  6848. * @param {string} shipFax
  6849. * @returns {OrderCreate}
  6850. */
  6851. setShipFax(shipFax) {
  6852. this.shipFax = shipFax;
  6853. return this;
  6854. }
  6855. /**
  6856. * Set ShipCompany.
  6857. * @param {string} shipCompany
  6858. * @returns {OrderCreate}
  6859. */
  6860. setShipCompany(shipCompany) {
  6861. this.shipCompany = shipCompany;
  6862. return this;
  6863. }
  6864. /**
  6865. * Set ShipAddress1.
  6866. * @param {string} shipAddress1
  6867. * @returns {OrderCreate}
  6868. */
  6869. setShipAddress1(shipAddress1) {
  6870. this.shipAddress1 = shipAddress1;
  6871. return this;
  6872. }
  6873. /**
  6874. * Set ShipAddress2.
  6875. * @param {string} shipAddress2
  6876. * @returns {OrderCreate}
  6877. */
  6878. setShipAddress2(shipAddress2) {
  6879. this.shipAddress2 = shipAddress2;
  6880. return this;
  6881. }
  6882. /**
  6883. * Set ShipCity.
  6884. * @param {string} shipCity
  6885. * @returns {OrderCreate}
  6886. */
  6887. setShipCity(shipCity) {
  6888. this.shipCity = shipCity;
  6889. return this;
  6890. }
  6891. /**
  6892. * Set ShipState.
  6893. * @param {string} shipState
  6894. * @returns {OrderCreate}
  6895. */
  6896. setShipState(shipState) {
  6897. this.shipState = shipState;
  6898. return this;
  6899. }
  6900. /**
  6901. * Set ShipZip.
  6902. * @param {string} shipZip
  6903. * @returns {OrderCreate}
  6904. */
  6905. setShipZip(shipZip) {
  6906. this.shipZip = shipZip;
  6907. return this;
  6908. }
  6909. /**
  6910. * Set ShipCountry.
  6911. * @param {string} shipCountry
  6912. * @returns {OrderCreate}
  6913. */
  6914. setShipCountry(shipCountry) {
  6915. this.shipCountry = shipCountry;
  6916. return this;
  6917. }
  6918. /**
  6919. * Set ShipResidential.
  6920. * @param {boolean} shipResidential
  6921. * @returns {OrderCreate}
  6922. */
  6923. setShipResidential(shipResidential) {
  6924. this.shipResidential = shipResidential;
  6925. return this;
  6926. }
  6927. /**
  6928. * Set BillFirstName.
  6929. * @param {string} billFirstName
  6930. * @returns {OrderCreate}
  6931. */
  6932. setBillFirstName(billFirstName) {
  6933. this.billFirstName = billFirstName;
  6934. return this;
  6935. }
  6936. /**
  6937. * Set BillLastName.
  6938. * @param {string} billLastName
  6939. * @returns {OrderCreate}
  6940. */
  6941. setBillLastName(billLastName) {
  6942. this.billLastName = billLastName;
  6943. return this;
  6944. }
  6945. /**
  6946. * Set BillEmail.
  6947. * @param {string} billEmail
  6948. * @returns {OrderCreate}
  6949. */
  6950. setBillEmail(billEmail) {
  6951. this.billEmail = billEmail;
  6952. return this;
  6953. }
  6954. /**
  6955. * Set BillPhone.
  6956. * @param {string} billPhone
  6957. * @returns {OrderCreate}
  6958. */
  6959. setBillPhone(billPhone) {
  6960. this.billPhone = billPhone;
  6961. return this;
  6962. }
  6963. /**
  6964. * Set BillFax.
  6965. * @param {string} billFax
  6966. * @returns {OrderCreate}
  6967. */
  6968. setBillFax(billFax) {
  6969. this.billFax = billFax;
  6970. return this;
  6971. }
  6972. /**
  6973. * Set BillCompany.
  6974. * @param {string} billCompany
  6975. * @returns {OrderCreate}
  6976. */
  6977. setBillCompany(billCompany) {
  6978. this.billCompany = billCompany;
  6979. return this;
  6980. }
  6981. /**
  6982. * Set BillAddress1.
  6983. * @param {string} billAddress1
  6984. * @returns {OrderCreate}
  6985. */
  6986. setBillAddress1(billAddress1) {
  6987. this.billAddress1 = billAddress1;
  6988. return this;
  6989. }
  6990. /**
  6991. * Set BillAddress2.
  6992. * @param {string} billAddress2
  6993. * @returns {OrderCreate}
  6994. */
  6995. setBillAddress2(billAddress2) {
  6996. this.billAddress2 = billAddress2;
  6997. return this;
  6998. }
  6999. /**
  7000. * Set BillCity.
  7001. * @param {string} billCity
  7002. * @returns {OrderCreate}
  7003. */
  7004. setBillCity(billCity) {
  7005. this.billCity = billCity;
  7006. return this;
  7007. }
  7008. /**
  7009. * Set BillState.
  7010. * @param {string} billState
  7011. * @returns {OrderCreate}
  7012. */
  7013. setBillState(billState) {
  7014. this.billState = billState;
  7015. return this;
  7016. }
  7017. /**
  7018. * Set BillZip.
  7019. * @param {string} billZip
  7020. * @returns {OrderCreate}
  7021. */
  7022. setBillZip(billZip) {
  7023. this.billZip = billZip;
  7024. return this;
  7025. }
  7026. /**
  7027. * Set BillCountry.
  7028. * @param {string} billCountry
  7029. * @returns {OrderCreate}
  7030. */
  7031. setBillCountry(billCountry) {
  7032. this.billCountry = billCountry;
  7033. return this;
  7034. }
  7035. /**
  7036. * Set Items.
  7037. * @param {OrderItem[]} items
  7038. * @throws {Error}
  7039. * @returns {OrderCreate}
  7040. */
  7041. setItems(items) {
  7042. var i;
  7043. var l;
  7044. if (!util.isArray(items)) {
  7045. throw new Error(util.format('Expected an array but got %s', typeof items));
  7046. }
  7047. for (i = 0, l = items.length; i < l; i++) {
  7048. if (!util.isInstanceOf(items[i], models.OrderItem) && util.isObject(items[i])) {
  7049. items[i] = new models.OrderItem(items[i]);
  7050. } else if (!util.isInstanceOf(items[i], models.OrderItem)) {
  7051. throw new Error(util.format('Expected instance of OrderItem or an Object but got %s',
  7052. typeof items[i]));
  7053. }
  7054. }
  7055. this.items = items;
  7056. return this;
  7057. }
  7058. /**
  7059. * Set Products.
  7060. * @param {OrderProduct[]} products
  7061. * @throws {Error}
  7062. * @returns {OrderCreate}
  7063. */
  7064. setProducts(products) {
  7065. var i;
  7066. var l;
  7067. if (!util.isArray(products)) {
  7068. throw new Error(util.format('Expected an array but got %s', typeof products));
  7069. }
  7070. for (i = 0, l = products.length; i < l; i++) {
  7071. if (!util.isInstanceOf(products[i], models.OrderProduct) && util.isObject(products[i])) {
  7072. products[i] = new models.OrderProduct(products[i]);
  7073. } else if (!util.isInstanceOf(products[i], models.OrderProduct)) {
  7074. throw new Error(util.format('Expected instance of OrderProduct or an Object but got %s',
  7075. typeof products[i]));
  7076. }
  7077. }
  7078. this.products = products;
  7079. return this;
  7080. }
  7081. /**
  7082. * Set Charges.
  7083. * @param {OrderCharge[]} charges
  7084. * @throws {Error}
  7085. * @returns {OrderCreate}
  7086. */
  7087. setCharges(charges) {
  7088. var i;
  7089. var l;
  7090. if (!util.isArray(charges)) {
  7091. throw new Error(util.format('Expected an array but got %s', typeof charges));
  7092. }
  7093. for (i = 0, l = charges.length; i < l; i++) {
  7094. if (!util.isInstanceOf(charges[i], models.OrderCharge) && util.isObject(charges[i])) {
  7095. charges[i] = new models.OrderCharge(charges[i]);
  7096. } else if (!util.isInstanceOf(charges[i], models.OrderCharge)) {
  7097. throw new Error(util.format('Expected instance of OrderCharge or an Object but got %s',
  7098. typeof charges[i]));
  7099. }
  7100. }
  7101. this.charges = charges;
  7102. return this;
  7103. }
  7104. /**
  7105. * Set CustomField_Values.
  7106. * @param {?CustomFieldValues} customFieldValues
  7107. * @throws {Error}
  7108. * @returns {OrderCreate}
  7109. */
  7110. setCustomFieldValues(customFieldValues) {
  7111. if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues) && util.isObject(customFieldValues)) {
  7112. customFieldValues = new models.CustomFieldValues(customFieldValues);
  7113. } else if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues)) {
  7114. throw new Error(util.format('Expected instance of CustomFieldValues or an Object but got %s',
  7115. typeof customFieldValues));
  7116. }
  7117. this.customFieldValues = customFieldValues;
  7118. return this;
  7119. }
  7120. /**
  7121. * Set Shipping_Module_Code.
  7122. * @param {string} shippingModuleCode
  7123. * @returns {OrderCreate}
  7124. */
  7125. setShippingModuleCode(shippingModuleCode) {
  7126. this.shippingModuleCode = shippingModuleCode;
  7127. return this;
  7128. }
  7129. /**
  7130. * Set Shipping_Module_Data.
  7131. * @param {string} shippingModuleData
  7132. * @returns {OrderCreate}
  7133. */
  7134. setShippingModuleData(shippingModuleData) {
  7135. this.shippingModuleData = shippingModuleData;
  7136. return this;
  7137. }
  7138. /**
  7139. * Set CalculateCharges.
  7140. * @param {boolean} calculateCharges
  7141. * @returns {OrderCreate}
  7142. */
  7143. setCalculateCharges(calculateCharges) {
  7144. this.calculateCharges = calculateCharges;
  7145. return this;
  7146. }
  7147. /**
  7148. * Set TriggerFulfillmentModules.
  7149. * @param {boolean} triggerFulfillmentModules
  7150. * @returns {OrderCreate}
  7151. */
  7152. setTriggerFulfillmentModules(triggerFulfillmentModules) {
  7153. this.triggerFulfillmentModules = triggerFulfillmentModules;
  7154. return this;
  7155. }
  7156. /**
  7157. * Add Items.
  7158. * @param {OrderItem} item
  7159. * @throws {Error}
  7160. * @returns {OrderCreate}
  7161. */
  7162. addItem(item) {
  7163. if (util.isInstanceOf(item, models.OrderItem)) {
  7164. this.items.push(item);
  7165. } else if (util.isObject(item)) {
  7166. this.items.push(new models.OrderItem(item));
  7167. } else {
  7168. throw new Error(util.format('Expected instance of OrderItem or Object but got %s',
  7169. typeof item));
  7170. }
  7171. return this;
  7172. }
  7173. /**
  7174. * Add many OrderItem.
  7175. * @param {OrderItem[]} items
  7176. * @throws {Error}
  7177. * @returns {OrderCreate}
  7178. */
  7179. addItems(items) {
  7180. var i;
  7181. var l;
  7182. if (!util.isArray(items)) {
  7183. throw new Error(util.format('Expecting an array of OrderItem but got %s',
  7184. typeof items));
  7185. }
  7186. for (i = 0, l = items.length; i < l; i++) {
  7187. if (util.isInstanceOf(items[i], models.OrderItem)) {
  7188. this.items.push(items[i]);
  7189. } else if (util.isObject(items[i])) {
  7190. this.items.push(new models.OrderItem(items[i]));
  7191. } else {
  7192. throw new Error(util.format('Expected array of OrderItem or an array of Object but got %s',
  7193. typeof items[i]));
  7194. }
  7195. }
  7196. return this;
  7197. }
  7198. /**
  7199. * Add Products.
  7200. * @param {OrderProduct} product
  7201. * @throws {Error}
  7202. * @returns {OrderCreate}
  7203. */
  7204. addProduct(product) {
  7205. if (util.isInstanceOf(product, models.OrderProduct)) {
  7206. this.products.push(product);
  7207. } else if (util.isObject(product)) {
  7208. this.products.push(new models.OrderProduct(product));
  7209. } else {
  7210. throw new Error(util.format('Expected instance of OrderProduct or Object but got %s',
  7211. typeof product));
  7212. }
  7213. return this;
  7214. }
  7215. /**
  7216. * Add many OrderProduct.
  7217. * @param {OrderProduct[]} products
  7218. * @throws {Error}
  7219. * @returns {OrderCreate}
  7220. */
  7221. addProducts(products) {
  7222. var i;
  7223. var l;
  7224. if (!util.isArray(products)) {
  7225. throw new Error(util.format('Expecting an array of OrderProduct but got %s',
  7226. typeof products));
  7227. }
  7228. for (i = 0, l = products.length; i < l; i++) {
  7229. if (util.isInstanceOf(products[i], models.OrderProduct)) {
  7230. this.products.push(products[i]);
  7231. } else if (util.isObject(products[i])) {
  7232. this.products.push(new models.OrderProduct(products[i]));
  7233. } else {
  7234. throw new Error(util.format('Expected array of OrderProduct or an array of Object but got %s',
  7235. typeof products[i]));
  7236. }
  7237. }
  7238. return this;
  7239. }
  7240. /**
  7241. * Add Charges.
  7242. * @param {OrderCharge} charge
  7243. * @throws {Error}
  7244. * @returns {OrderCreate}
  7245. */
  7246. addCharge(charge) {
  7247. if (util.isInstanceOf(charge, models.OrderCharge)) {
  7248. this.charges.push(charge);
  7249. } else if (util.isObject(charge)) {
  7250. this.charges.push(new models.OrderCharge(charge));
  7251. } else {
  7252. throw new Error(util.format('Expected instance of OrderCharge or Object but got %s',
  7253. typeof charge));
  7254. }
  7255. return this;
  7256. }
  7257. /**
  7258. * Add many OrderCharge.
  7259. * @param {OrderCharge[]} charges
  7260. * @throws {Error}
  7261. * @returns {OrderCreate}
  7262. */
  7263. addCharges(charges) {
  7264. var i;
  7265. var l;
  7266. if (!util.isArray(charges)) {
  7267. throw new Error(util.format('Expecting an array of OrderCharge but got %s',
  7268. typeof charges));
  7269. }
  7270. for (i = 0, l = charges.length; i < l; i++) {
  7271. if (util.isInstanceOf(charges[i], models.OrderCharge)) {
  7272. this.charges.push(charges[i]);
  7273. } else if (util.isObject(charges[i])) {
  7274. this.charges.push(new models.OrderCharge(charges[i]));
  7275. } else {
  7276. throw new Error(util.format('Expected array of OrderCharge or an array of Object but got %s',
  7277. typeof charges[i]));
  7278. }
  7279. }
  7280. return this;
  7281. }
  7282. /**
  7283. * Reduce the request to a an object.
  7284. * @override
  7285. * @returns {Object}
  7286. */
  7287. toObject() {
  7288. var i;
  7289. var l;
  7290. var data = super.toObject();
  7291. if (!util.isNullOrUndefined(this.customerId)) {
  7292. data['Customer_ID'] = this.customerId;
  7293. } else if (!util.isNullOrUndefined(this.customerLogin)) {
  7294. data['Customer_Login'] = this.customerLogin;
  7295. }
  7296. if (!util.isNullOrUndefined(this.shipFirstName)) {
  7297. data['ShipFirstName'] = this.shipFirstName;
  7298. }
  7299. if (!util.isNullOrUndefined(this.shipLastName)) {
  7300. data['ShipLastName'] = this.shipLastName;
  7301. }
  7302. if (!util.isNullOrUndefined(this.shipEmail)) {
  7303. data['ShipEmail'] = this.shipEmail;
  7304. }
  7305. if (!util.isNullOrUndefined(this.shipPhone)) {
  7306. data['ShipPhone'] = this.shipPhone;
  7307. }
  7308. if (!util.isNullOrUndefined(this.shipFax)) {
  7309. data['ShipFax'] = this.shipFax;
  7310. }
  7311. if (!util.isNullOrUndefined(this.shipCompany)) {
  7312. data['ShipCompany'] = this.shipCompany;
  7313. }
  7314. if (!util.isNullOrUndefined(this.shipAddress1)) {
  7315. data['ShipAddress1'] = this.shipAddress1;
  7316. }
  7317. if (!util.isNullOrUndefined(this.shipAddress2)) {
  7318. data['ShipAddress2'] = this.shipAddress2;
  7319. }
  7320. if (!util.isNullOrUndefined(this.shipCity)) {
  7321. data['ShipCity'] = this.shipCity;
  7322. }
  7323. if (!util.isNullOrUndefined(this.shipState)) {
  7324. data['ShipState'] = this.shipState;
  7325. }
  7326. if (!util.isNullOrUndefined(this.shipZip)) {
  7327. data['ShipZip'] = this.shipZip;
  7328. }
  7329. if (!util.isNullOrUndefined(this.shipCountry)) {
  7330. data['ShipCountry'] = this.shipCountry;
  7331. }
  7332. if (!util.isNullOrUndefined(this.shipResidential)) {
  7333. data['ShipResidential'] = this.shipResidential;
  7334. }
  7335. if (!util.isNullOrUndefined(this.billFirstName)) {
  7336. data['BillFirstName'] = this.billFirstName;
  7337. }
  7338. if (!util.isNullOrUndefined(this.billLastName)) {
  7339. data['BillLastName'] = this.billLastName;
  7340. }
  7341. if (!util.isNullOrUndefined(this.billEmail)) {
  7342. data['BillEmail'] = this.billEmail;
  7343. }
  7344. if (!util.isNullOrUndefined(this.billPhone)) {
  7345. data['BillPhone'] = this.billPhone;
  7346. }
  7347. if (!util.isNullOrUndefined(this.billFax)) {
  7348. data['BillFax'] = this.billFax;
  7349. }
  7350. if (!util.isNullOrUndefined(this.billCompany)) {
  7351. data['BillCompany'] = this.billCompany;
  7352. }
  7353. if (!util.isNullOrUndefined(this.billAddress1)) {
  7354. data['BillAddress1'] = this.billAddress1;
  7355. }
  7356. if (!util.isNullOrUndefined(this.billAddress2)) {
  7357. data['BillAddress2'] = this.billAddress2;
  7358. }
  7359. if (!util.isNullOrUndefined(this.billCity)) {
  7360. data['BillCity'] = this.billCity;
  7361. }
  7362. if (!util.isNullOrUndefined(this.billState)) {
  7363. data['BillState'] = this.billState;
  7364. }
  7365. if (!util.isNullOrUndefined(this.billZip)) {
  7366. data['BillZip'] = this.billZip;
  7367. }
  7368. if (!util.isNullOrUndefined(this.billCountry)) {
  7369. data['BillCountry'] = this.billCountry;
  7370. }
  7371. if (util.isArray(this.items)) {
  7372. data['Items'] = [];
  7373. for (i = 0, l = this.items.length; i < l; i++) {
  7374. if (util.isObject(this.items[i])) {
  7375. data['Items'].push(this.items[i].toObject());
  7376. }
  7377. }
  7378. }
  7379. if (util.isArray(this.products)) {
  7380. data['Products'] = [];
  7381. for (i = 0, l = this.products.length; i < l; i++) {
  7382. if (util.isObject(this.products[i])) {
  7383. data['Products'].push(this.products[i].toObject());
  7384. }
  7385. }
  7386. }
  7387. if (util.isArray(this.charges)) {
  7388. data['Charges'] = [];
  7389. for (i = 0, l = this.charges.length; i < l; i++) {
  7390. if (util.isObject(this.charges[i])) {
  7391. data['Charges'].push(this.charges[i].toObject());
  7392. }
  7393. }
  7394. }
  7395. if (this.customFieldValues && util.isObject(this.customFieldValues)) {
  7396. data['CustomField_Values'] = this.customFieldValues.toObject();
  7397. }
  7398. if (!util.isNullOrUndefined(this.shippingModuleCode)) {
  7399. data['Shipping_Module_Code'] = this.shippingModuleCode;
  7400. }
  7401. if (!util.isNullOrUndefined(this.shippingModuleData)) {
  7402. data['Shipping_Module_Data'] = this.shippingModuleData;
  7403. }
  7404. if (!util.isNullOrUndefined(this.calculateCharges)) {
  7405. data['CalculateCharges'] = this.calculateCharges;
  7406. }
  7407. if (!util.isNullOrUndefined(this.triggerFulfillmentModules)) {
  7408. data['TriggerFulfillmentModules'] = this.triggerFulfillmentModules;
  7409. }
  7410. return data;
  7411. }
  7412. /**
  7413. * Create a response object from the response data.
  7414. * @override
  7415. * @returns {Response}
  7416. */
  7417. createResponse(data) {
  7418. return new responses.OrderCreate(this, data);
  7419. }
  7420. }
  7421. /**
  7422. * Handles API Request Order_Delete. Scope: Store.
  7423. * @see https://docs.miva.com/json-api/functions/order_delete
  7424. */
  7425. class OrderDelete extends Request {
  7426. /**
  7427. * OrderDelete Constructor.
  7428. * @param {?Client} client
  7429. * @param {?Order} order
  7430. */
  7431. constructor(client, order = null) {
  7432. super(client);
  7433. this.function = 'Order_Delete';
  7434. this.scope = Request.REQUEST_SCOPE_STORE;
  7435. this.orderId = null;
  7436. if (util.isInstanceOf(order, models.Order)) {
  7437. this.setOrderId(order.getId());
  7438. }
  7439. }
  7440. /**
  7441. * Get Order_ID.
  7442. * @returns {number}
  7443. */
  7444. getOrderId() {
  7445. return this.orderId;
  7446. }
  7447. /**
  7448. * Set Order_ID.
  7449. * @param {number} orderId
  7450. * @returns {OrderDelete}
  7451. */
  7452. setOrderId(orderId) {
  7453. this.orderId = orderId;
  7454. return this;
  7455. }
  7456. /**
  7457. * Reduce the request to a an object.
  7458. * @override
  7459. * @returns {Object}
  7460. */
  7461. toObject() {
  7462. var data = super.toObject();
  7463. data['Order_ID'] = this.orderId;
  7464. return data;
  7465. }
  7466. /**
  7467. * Create a response object from the response data.
  7468. * @override
  7469. * @returns {Response}
  7470. */
  7471. createResponse(data) {
  7472. return new responses.OrderDelete(this, data);
  7473. }
  7474. }
  7475. /**
  7476. * Handles API Request Order_Update_Customer_Information. Scope: Store.
  7477. * @see https://docs.miva.com/json-api/functions/order_update_customer_information
  7478. */
  7479. class OrderUpdateCustomerInformation extends Request {
  7480. /**
  7481. * OrderUpdateCustomerInformation Constructor.
  7482. * @param {?Client} client
  7483. * @param {?Order} order
  7484. */
  7485. constructor(client, order = null) {
  7486. super(client);
  7487. this.function = 'Order_Update_Customer_Information';
  7488. this.scope = Request.REQUEST_SCOPE_STORE;
  7489. this.orderId = null;
  7490. this.customerId = null;
  7491. this.shipResidential = null;
  7492. this.shipFirstName = null;
  7493. this.shipLastName = null;
  7494. this.shipEmail = null;
  7495. this.shipPhone = null;
  7496. this.shipFax = null;
  7497. this.shipCompany = null;
  7498. this.shipAddress1 = null;
  7499. this.shipAddress2 = null;
  7500. this.shipCity = null;
  7501. this.shipState = null;
  7502. this.shipZip = null;
  7503. this.shipCountry = null;
  7504. this.billFirstName = null;
  7505. this.billLastName = null;
  7506. this.billEmail = null;
  7507. this.billPhone = null;
  7508. this.billFax = null;
  7509. this.billCompany = null;
  7510. this.billAddress1 = null;
  7511. this.billAddress2 = null;
  7512. this.billCity = null;
  7513. this.billState = null;
  7514. this.billZip = null;
  7515. this.billCountry = null;
  7516. if (util.isInstanceOf(order, models.Order)) {
  7517. this.setOrderId(order.getId());
  7518. }
  7519. }
  7520. /**
  7521. * Get Order_ID.
  7522. * @returns {number}
  7523. */
  7524. getOrderId() {
  7525. return this.orderId;
  7526. }
  7527. /**
  7528. * Get Customer_ID.
  7529. * @returns {number}
  7530. */
  7531. getCustomerId() {
  7532. return this.customerId;
  7533. }
  7534. /**
  7535. * Get Ship_Residential.
  7536. * @returns {boolean}
  7537. */
  7538. getShipResidential() {
  7539. return this.shipResidential;
  7540. }
  7541. /**
  7542. * Get Ship_FirstName.
  7543. * @returns {string}
  7544. */
  7545. getShipFirstName() {
  7546. return this.shipFirstName;
  7547. }
  7548. /**
  7549. * Get Ship_LastName.
  7550. * @returns {string}
  7551. */
  7552. getShipLastName() {
  7553. return this.shipLastName;
  7554. }
  7555. /**
  7556. * Get Ship_Email.
  7557. * @returns {string}
  7558. */
  7559. getShipEmail() {
  7560. return this.shipEmail;
  7561. }
  7562. /**
  7563. * Get Ship_Phone.
  7564. * @returns {string}
  7565. */
  7566. getShipPhone() {
  7567. return this.shipPhone;
  7568. }
  7569. /**
  7570. * Get Ship_Fax.
  7571. * @returns {string}
  7572. */
  7573. getShipFax() {
  7574. return this.shipFax;
  7575. }
  7576. /**
  7577. * Get Ship_Company.
  7578. * @returns {string}
  7579. */
  7580. getShipCompany() {
  7581. return this.shipCompany;
  7582. }
  7583. /**
  7584. * Get Ship_Address1.
  7585. * @returns {string}
  7586. */
  7587. getShipAddress1() {
  7588. return this.shipAddress1;
  7589. }
  7590. /**
  7591. * Get Ship_Address2.
  7592. * @returns {string}
  7593. */
  7594. getShipAddress2() {
  7595. return this.shipAddress2;
  7596. }
  7597. /**
  7598. * Get Ship_City.
  7599. * @returns {string}
  7600. */
  7601. getShipCity() {
  7602. return this.shipCity;
  7603. }
  7604. /**
  7605. * Get Ship_State.
  7606. * @returns {string}
  7607. */
  7608. getShipState() {
  7609. return this.shipState;
  7610. }
  7611. /**
  7612. * Get Ship_Zip.
  7613. * @returns {string}
  7614. */
  7615. getShipZip() {
  7616. return this.shipZip;
  7617. }
  7618. /**
  7619. * Get Ship_Country.
  7620. * @returns {string}
  7621. */
  7622. getShipCountry() {
  7623. return this.shipCountry;
  7624. }
  7625. /**
  7626. * Get Bill_FirstName.
  7627. * @returns {string}
  7628. */
  7629. getBillFirstName() {
  7630. return this.billFirstName;
  7631. }
  7632. /**
  7633. * Get Bill_LastName.
  7634. * @returns {string}
  7635. */
  7636. getBillLastName() {
  7637. return this.billLastName;
  7638. }
  7639. /**
  7640. * Get Bill_Email.
  7641. * @returns {string}
  7642. */
  7643. getBillEmail() {
  7644. return this.billEmail;
  7645. }
  7646. /**
  7647. * Get Bill_Phone.
  7648. * @returns {string}
  7649. */
  7650. getBillPhone() {
  7651. return this.billPhone;
  7652. }
  7653. /**
  7654. * Get Bill_Fax.
  7655. * @returns {string}
  7656. */
  7657. getBillFax() {
  7658. return this.billFax;
  7659. }
  7660. /**
  7661. * Get Bill_Company.
  7662. * @returns {string}
  7663. */
  7664. getBillCompany() {
  7665. return this.billCompany;
  7666. }
  7667. /**
  7668. * Get Bill_Address1.
  7669. * @returns {string}
  7670. */
  7671. getBillAddress1() {
  7672. return this.billAddress1;
  7673. }
  7674. /**
  7675. * Get Bill_Address2.
  7676. * @returns {string}
  7677. */
  7678. getBillAddress2() {
  7679. return this.billAddress2;
  7680. }
  7681. /**
  7682. * Get Bill_City.
  7683. * @returns {string}
  7684. */
  7685. getBillCity() {
  7686. return this.billCity;
  7687. }
  7688. /**
  7689. * Get Bill_State.
  7690. * @returns {string}
  7691. */
  7692. getBillState() {
  7693. return this.billState;
  7694. }
  7695. /**
  7696. * Get Bill_Zip.
  7697. * @returns {string}
  7698. */
  7699. getBillZip() {
  7700. return this.billZip;
  7701. }
  7702. /**
  7703. * Get Bill_Country.
  7704. * @returns {string}
  7705. */
  7706. getBillCountry() {
  7707. return this.billCountry;
  7708. }
  7709. /**
  7710. * Set Order_ID.
  7711. * @param {number} orderId
  7712. * @returns {OrderUpdateCustomerInformation}
  7713. */
  7714. setOrderId(orderId) {
  7715. this.orderId = orderId;
  7716. return this;
  7717. }
  7718. /**
  7719. * Set Customer_ID.
  7720. * @param {number} customerId
  7721. * @returns {OrderUpdateCustomerInformation}
  7722. */
  7723. setCustomerId(customerId) {
  7724. this.customerId = customerId;
  7725. return this;
  7726. }
  7727. /**
  7728. * Set Ship_Residential.
  7729. * @param {boolean} shipResidential
  7730. * @returns {OrderUpdateCustomerInformation}
  7731. */
  7732. setShipResidential(shipResidential) {
  7733. this.shipResidential = shipResidential;
  7734. return this;
  7735. }
  7736. /**
  7737. * Set Ship_FirstName.
  7738. * @param {string} shipFirstName
  7739. * @returns {OrderUpdateCustomerInformation}
  7740. */
  7741. setShipFirstName(shipFirstName) {
  7742. this.shipFirstName = shipFirstName;
  7743. return this;
  7744. }
  7745. /**
  7746. * Set Ship_LastName.
  7747. * @param {string} shipLastName
  7748. * @returns {OrderUpdateCustomerInformation}
  7749. */
  7750. setShipLastName(shipLastName) {
  7751. this.shipLastName = shipLastName;
  7752. return this;
  7753. }
  7754. /**
  7755. * Set Ship_Email.
  7756. * @param {string} shipEmail
  7757. * @returns {OrderUpdateCustomerInformation}
  7758. */
  7759. setShipEmail(shipEmail) {
  7760. this.shipEmail = shipEmail;
  7761. return this;
  7762. }
  7763. /**
  7764. * Set Ship_Phone.
  7765. * @param {string} shipPhone
  7766. * @returns {OrderUpdateCustomerInformation}
  7767. */
  7768. setShipPhone(shipPhone) {
  7769. this.shipPhone = shipPhone;
  7770. return this;
  7771. }
  7772. /**
  7773. * Set Ship_Fax.
  7774. * @param {string} shipFax
  7775. * @returns {OrderUpdateCustomerInformation}
  7776. */
  7777. setShipFax(shipFax) {
  7778. this.shipFax = shipFax;
  7779. return this;
  7780. }
  7781. /**
  7782. * Set Ship_Company.
  7783. * @param {string} shipCompany
  7784. * @returns {OrderUpdateCustomerInformation}
  7785. */
  7786. setShipCompany(shipCompany) {
  7787. this.shipCompany = shipCompany;
  7788. return this;
  7789. }
  7790. /**
  7791. * Set Ship_Address1.
  7792. * @param {string} shipAddress1
  7793. * @returns {OrderUpdateCustomerInformation}
  7794. */
  7795. setShipAddress1(shipAddress1) {
  7796. this.shipAddress1 = shipAddress1;
  7797. return this;
  7798. }
  7799. /**
  7800. * Set Ship_Address2.
  7801. * @param {string} shipAddress2
  7802. * @returns {OrderUpdateCustomerInformation}
  7803. */
  7804. setShipAddress2(shipAddress2) {
  7805. this.shipAddress2 = shipAddress2;
  7806. return this;
  7807. }
  7808. /**
  7809. * Set Ship_City.
  7810. * @param {string} shipCity
  7811. * @returns {OrderUpdateCustomerInformation}
  7812. */
  7813. setShipCity(shipCity) {
  7814. this.shipCity = shipCity;
  7815. return this;
  7816. }
  7817. /**
  7818. * Set Ship_State.
  7819. * @param {string} shipState
  7820. * @returns {OrderUpdateCustomerInformation}
  7821. */
  7822. setShipState(shipState) {
  7823. this.shipState = shipState;
  7824. return this;
  7825. }
  7826. /**
  7827. * Set Ship_Zip.
  7828. * @param {string} shipZip
  7829. * @returns {OrderUpdateCustomerInformation}
  7830. */
  7831. setShipZip(shipZip) {
  7832. this.shipZip = shipZip;
  7833. return this;
  7834. }
  7835. /**
  7836. * Set Ship_Country.
  7837. * @param {string} shipCountry
  7838. * @returns {OrderUpdateCustomerInformation}
  7839. */
  7840. setShipCountry(shipCountry) {
  7841. this.shipCountry = shipCountry;
  7842. return this;
  7843. }
  7844. /**
  7845. * Set Bill_FirstName.
  7846. * @param {string} billFirstName
  7847. * @returns {OrderUpdateCustomerInformation}
  7848. */
  7849. setBillFirstName(billFirstName) {
  7850. this.billFirstName = billFirstName;
  7851. return this;
  7852. }
  7853. /**
  7854. * Set Bill_LastName.
  7855. * @param {string} billLastName
  7856. * @returns {OrderUpdateCustomerInformation}
  7857. */
  7858. setBillLastName(billLastName) {
  7859. this.billLastName = billLastName;
  7860. return this;
  7861. }
  7862. /**
  7863. * Set Bill_Email.
  7864. * @param {string} billEmail
  7865. * @returns {OrderUpdateCustomerInformation}
  7866. */
  7867. setBillEmail(billEmail) {
  7868. this.billEmail = billEmail;
  7869. return this;
  7870. }
  7871. /**
  7872. * Set Bill_Phone.
  7873. * @param {string} billPhone
  7874. * @returns {OrderUpdateCustomerInformation}
  7875. */
  7876. setBillPhone(billPhone) {
  7877. this.billPhone = billPhone;
  7878. return this;
  7879. }
  7880. /**
  7881. * Set Bill_Fax.
  7882. * @param {string} billFax
  7883. * @returns {OrderUpdateCustomerInformation}
  7884. */
  7885. setBillFax(billFax) {
  7886. this.billFax = billFax;
  7887. return this;
  7888. }
  7889. /**
  7890. * Set Bill_Company.
  7891. * @param {string} billCompany
  7892. * @returns {OrderUpdateCustomerInformation}
  7893. */
  7894. setBillCompany(billCompany) {
  7895. this.billCompany = billCompany;
  7896. return this;
  7897. }
  7898. /**
  7899. * Set Bill_Address1.
  7900. * @param {string} billAddress1
  7901. * @returns {OrderUpdateCustomerInformation}
  7902. */
  7903. setBillAddress1(billAddress1) {
  7904. this.billAddress1 = billAddress1;
  7905. return this;
  7906. }
  7907. /**
  7908. * Set Bill_Address2.
  7909. * @param {string} billAddress2
  7910. * @returns {OrderUpdateCustomerInformation}
  7911. */
  7912. setBillAddress2(billAddress2) {
  7913. this.billAddress2 = billAddress2;
  7914. return this;
  7915. }
  7916. /**
  7917. * Set Bill_City.
  7918. * @param {string} billCity
  7919. * @returns {OrderUpdateCustomerInformation}
  7920. */
  7921. setBillCity(billCity) {
  7922. this.billCity = billCity;
  7923. return this;
  7924. }
  7925. /**
  7926. * Set Bill_State.
  7927. * @param {string} billState
  7928. * @returns {OrderUpdateCustomerInformation}
  7929. */
  7930. setBillState(billState) {
  7931. this.billState = billState;
  7932. return this;
  7933. }
  7934. /**
  7935. * Set Bill_Zip.
  7936. * @param {string} billZip
  7937. * @returns {OrderUpdateCustomerInformation}
  7938. */
  7939. setBillZip(billZip) {
  7940. this.billZip = billZip;
  7941. return this;
  7942. }
  7943. /**
  7944. * Set Bill_Country.
  7945. * @param {string} billCountry
  7946. * @returns {OrderUpdateCustomerInformation}
  7947. */
  7948. setBillCountry(billCountry) {
  7949. this.billCountry = billCountry;
  7950. return this;
  7951. }
  7952. /**
  7953. * Reduce the request to a an object.
  7954. * @override
  7955. * @returns {Object}
  7956. */
  7957. toObject() {
  7958. var data = super.toObject();
  7959. data['Order_ID'] = this.orderId;
  7960. if (!util.isNullOrUndefined(this.customerId)) {
  7961. data['Customer_ID'] = this.customerId;
  7962. }
  7963. if (!util.isNullOrUndefined(this.shipResidential)) {
  7964. data['Ship_Residential'] = this.shipResidential;
  7965. }
  7966. if (!util.isNullOrUndefined(this.shipFirstName)) {
  7967. data['Ship_FirstName'] = this.shipFirstName;
  7968. }
  7969. if (!util.isNullOrUndefined(this.shipLastName)) {
  7970. data['Ship_LastName'] = this.shipLastName;
  7971. }
  7972. if (!util.isNullOrUndefined(this.shipEmail)) {
  7973. data['Ship_Email'] = this.shipEmail;
  7974. }
  7975. if (!util.isNullOrUndefined(this.shipPhone)) {
  7976. data['Ship_Phone'] = this.shipPhone;
  7977. }
  7978. if (!util.isNullOrUndefined(this.shipFax)) {
  7979. data['Ship_Fax'] = this.shipFax;
  7980. }
  7981. if (!util.isNullOrUndefined(this.shipCompany)) {
  7982. data['Ship_Company'] = this.shipCompany;
  7983. }
  7984. if (!util.isNullOrUndefined(this.shipAddress1)) {
  7985. data['Ship_Address1'] = this.shipAddress1;
  7986. }
  7987. if (!util.isNullOrUndefined(this.shipAddress2)) {
  7988. data['Ship_Address2'] = this.shipAddress2;
  7989. }
  7990. if (!util.isNullOrUndefined(this.shipCity)) {
  7991. data['Ship_City'] = this.shipCity;
  7992. }
  7993. if (!util.isNullOrUndefined(this.shipState)) {
  7994. data['Ship_State'] = this.shipState;
  7995. }
  7996. if (!util.isNullOrUndefined(this.shipZip)) {
  7997. data['Ship_Zip'] = this.shipZip;
  7998. }
  7999. if (!util.isNullOrUndefined(this.shipCountry)) {
  8000. data['Ship_Country'] = this.shipCountry;
  8001. }
  8002. if (!util.isNullOrUndefined(this.billFirstName)) {
  8003. data['Bill_FirstName'] = this.billFirstName;
  8004. }
  8005. if (!util.isNullOrUndefined(this.billLastName)) {
  8006. data['Bill_LastName'] = this.billLastName;
  8007. }
  8008. if (!util.isNullOrUndefined(this.billEmail)) {
  8009. data['Bill_Email'] = this.billEmail;
  8010. }
  8011. if (!util.isNullOrUndefined(this.billPhone)) {
  8012. data['Bill_Phone'] = this.billPhone;
  8013. }
  8014. if (!util.isNullOrUndefined(this.billFax)) {
  8015. data['Bill_Fax'] = this.billFax;
  8016. }
  8017. if (!util.isNullOrUndefined(this.billCompany)) {
  8018. data['Bill_Company'] = this.billCompany;
  8019. }
  8020. if (!util.isNullOrUndefined(this.billAddress1)) {
  8021. data['Bill_Address1'] = this.billAddress1;
  8022. }
  8023. if (!util.isNullOrUndefined(this.billAddress2)) {
  8024. data['Bill_Address2'] = this.billAddress2;
  8025. }
  8026. if (!util.isNullOrUndefined(this.billCity)) {
  8027. data['Bill_City'] = this.billCity;
  8028. }
  8029. if (!util.isNullOrUndefined(this.billState)) {
  8030. data['Bill_State'] = this.billState;
  8031. }
  8032. if (!util.isNullOrUndefined(this.billZip)) {
  8033. data['Bill_Zip'] = this.billZip;
  8034. }
  8035. if (!util.isNullOrUndefined(this.billCountry)) {
  8036. data['Bill_Country'] = this.billCountry;
  8037. }
  8038. return data;
  8039. }
  8040. /**
  8041. * Create a response object from the response data.
  8042. * @override
  8043. * @returns {Response}
  8044. */
  8045. createResponse(data) {
  8046. return new responses.OrderUpdateCustomerInformation(this, data);
  8047. }
  8048. }
  8049. /**
  8050. * Handles API Request PriceGroupCustomer_Update_Assigned. Scope: Store.
  8051. * @see https://docs.miva.com/json-api/functions/pricegroupcustomer_update_assigned
  8052. */
  8053. class PriceGroupCustomerUpdateAssigned extends Request {
  8054. /**
  8055. * PriceGroupCustomerUpdateAssigned Constructor.
  8056. * @param {?Client} client
  8057. * @param {?PriceGroup} priceGroup
  8058. */
  8059. constructor(client, priceGroup = null) {
  8060. super(client);
  8061. this.function = 'PriceGroupCustomer_Update_Assigned';
  8062. this.scope = Request.REQUEST_SCOPE_STORE;
  8063. this.priceGroupId = null;
  8064. this.priceGroupName = null;
  8065. this.editCustomer = null;
  8066. this.customerId = null;
  8067. this.customerLogin = null;
  8068. this.assigned = null;
  8069. if (util.isInstanceOf(priceGroup, models.PriceGroup)) {
  8070. if (priceGroup.getId()) {
  8071. this.setPriceGroupId(priceGroup.getId());
  8072. } else if (priceGroup.getName()) {
  8073. this.setPriceGroupName(priceGroup.getName());
  8074. }
  8075. }
  8076. }
  8077. /**
  8078. * Get PriceGroup_ID.
  8079. * @returns {number}
  8080. */
  8081. getPriceGroupId() {
  8082. return this.priceGroupId;
  8083. }
  8084. /**
  8085. * Get PriceGroup_Name.
  8086. * @returns {string}
  8087. */
  8088. getPriceGroupName() {
  8089. return this.priceGroupName;
  8090. }
  8091. /**
  8092. * Get Edit_Customer.
  8093. * @returns {string}
  8094. */
  8095. getEditCustomer() {
  8096. return this.editCustomer;
  8097. }
  8098. /**
  8099. * Get Customer_ID.
  8100. * @returns {number}
  8101. */
  8102. getCustomerId() {
  8103. return this.customerId;
  8104. }
  8105. /**
  8106. * Get Customer_Login.
  8107. * @returns {string}
  8108. */
  8109. getCustomerLogin() {
  8110. return this.customerLogin;
  8111. }
  8112. /**
  8113. * Get Assigned.
  8114. * @returns {boolean}
  8115. */
  8116. getAssigned() {
  8117. return this.assigned;
  8118. }
  8119. /**
  8120. * Set PriceGroup_ID.
  8121. * @param {number} priceGroupId
  8122. * @returns {PriceGroupCustomerUpdateAssigned}
  8123. */
  8124. setPriceGroupId(priceGroupId) {
  8125. this.priceGroupId = priceGroupId;
  8126. return this;
  8127. }
  8128. /**
  8129. * Set PriceGroup_Name.
  8130. * @param {string} priceGroupName
  8131. * @returns {PriceGroupCustomerUpdateAssigned}
  8132. */
  8133. setPriceGroupName(priceGroupName) {
  8134. this.priceGroupName = priceGroupName;
  8135. return this;
  8136. }
  8137. /**
  8138. * Set Edit_Customer.
  8139. * @param {string} editCustomer
  8140. * @returns {PriceGroupCustomerUpdateAssigned}
  8141. */
  8142. setEditCustomer(editCustomer) {
  8143. this.editCustomer = editCustomer;
  8144. return this;
  8145. }
  8146. /**
  8147. * Set Customer_ID.
  8148. * @param {number} customerId
  8149. * @returns {PriceGroupCustomerUpdateAssigned}
  8150. */
  8151. setCustomerId(customerId) {
  8152. this.customerId = customerId;
  8153. return this;
  8154. }
  8155. /**
  8156. * Set Customer_Login.
  8157. * @param {string} customerLogin
  8158. * @returns {PriceGroupCustomerUpdateAssigned}
  8159. */
  8160. setCustomerLogin(customerLogin) {
  8161. this.customerLogin = customerLogin;
  8162. return this;
  8163. }
  8164. /**
  8165. * Set Assigned.
  8166. * @param {boolean} assigned
  8167. * @returns {PriceGroupCustomerUpdateAssigned}
  8168. */
  8169. setAssigned(assigned) {
  8170. this.assigned = assigned;
  8171. return this;
  8172. }
  8173. /**
  8174. * Reduce the request to a an object.
  8175. * @override
  8176. * @returns {Object}
  8177. */
  8178. toObject() {
  8179. var data = super.toObject();
  8180. if (!util.isNullOrUndefined(this.priceGroupId)) {
  8181. data['PriceGroup_ID'] = this.priceGroupId;
  8182. } else if (!util.isNullOrUndefined(this.priceGroupName)) {
  8183. data['PriceGroup_Name'] = this.priceGroupName;
  8184. }
  8185. if (!util.isNullOrUndefined(this.customerId)) {
  8186. data['Customer_ID'] = this.customerId;
  8187. } else if (!util.isNullOrUndefined(this.editCustomer)) {
  8188. data['Edit_Customer'] = this.editCustomer;
  8189. } else if (!util.isNullOrUndefined(this.customerLogin)) {
  8190. data['Customer_Login'] = this.customerLogin;
  8191. }
  8192. if (!util.isNullOrUndefined(this.assigned)) {
  8193. data['Assigned'] = this.assigned;
  8194. }
  8195. return data;
  8196. }
  8197. /**
  8198. * Create a response object from the response data.
  8199. * @override
  8200. * @returns {Response}
  8201. */
  8202. createResponse(data) {
  8203. return new responses.PriceGroupCustomerUpdateAssigned(this, data);
  8204. }
  8205. }
  8206. /**
  8207. * Handles API Request PriceGroupList_Load_Query. Scope: Store.
  8208. * @see https://docs.miva.com/json-api/functions/pricegrouplist_load_query
  8209. */
  8210. class PriceGroupListLoadQuery extends ListQueryRequest {
  8211. /**
  8212. * PriceGroupListLoadQuery Constructor.
  8213. * @param {?Client} client
  8214. */
  8215. constructor(client) {
  8216. super(client);
  8217. this.function = 'PriceGroupList_Load_Query';
  8218. this.scope = Request.REQUEST_SCOPE_STORE;
  8219. this.availableSearchFields = [
  8220. 'id',
  8221. 'name',
  8222. 'type',
  8223. 'module_id',
  8224. 'custscope',
  8225. 'rate',
  8226. 'discount',
  8227. 'markup',
  8228. 'dt_start',
  8229. 'dt_end',
  8230. 'priority',
  8231. 'exclusion',
  8232. 'descrip',
  8233. 'display',
  8234. 'qmn_subtot',
  8235. 'qmx_subtot',
  8236. 'qmn_quan',
  8237. 'qmx_quan',
  8238. 'qmn_weight',
  8239. 'qmx_weight',
  8240. 'bmn_subtot',
  8241. 'bmx_subtot',
  8242. 'bmn_quan',
  8243. 'bmx_quan',
  8244. 'bmn_weight',
  8245. 'bmx_weight'
  8246. ];
  8247. this.availableSortFields = [
  8248. 'id',
  8249. 'name',
  8250. 'type',
  8251. 'module_id',
  8252. 'custscope',
  8253. 'rate',
  8254. 'discount',
  8255. 'markup',
  8256. 'dt_start',
  8257. 'dt_end',
  8258. 'priority',
  8259. 'exclusion',
  8260. 'descrip',
  8261. 'display',
  8262. 'qmn_subtot',
  8263. 'qmx_subtot',
  8264. 'qmn_quan',
  8265. 'qmx_quan',
  8266. 'qmn_weight',
  8267. 'qmx_weight',
  8268. 'bmn_subtot',
  8269. 'bmx_subtot',
  8270. 'bmn_quan',
  8271. 'bmx_quan',
  8272. 'bmn_weight',
  8273. 'bmx_weight'
  8274. ];
  8275. }
  8276. /**
  8277. * Create a response object from the response data.
  8278. * @override
  8279. * @returns {Response}
  8280. */
  8281. createResponse(data) {
  8282. return new responses.PriceGroupListLoadQuery(this, data);
  8283. }
  8284. }
  8285. /**
  8286. * Handles API Request PriceGroupProduct_Update_Assigned. Scope: Store.
  8287. * @see https://docs.miva.com/json-api/functions/pricegroupproduct_update_assigned
  8288. */
  8289. class PriceGroupProductUpdateAssigned extends Request {
  8290. /**
  8291. * PriceGroupProductUpdateAssigned Constructor.
  8292. * @param {?Client} client
  8293. * @param {?PriceGroup} priceGroup
  8294. */
  8295. constructor(client, priceGroup = null) {
  8296. super(client);
  8297. this.function = 'PriceGroupProduct_Update_Assigned';
  8298. this.scope = Request.REQUEST_SCOPE_STORE;
  8299. this.priceGroupId = null;
  8300. this.priceGroupName = null;
  8301. this.editProduct = null;
  8302. this.productId = null;
  8303. this.productCode = null;
  8304. this.productSku = null;
  8305. this.assigned = null;
  8306. if (util.isInstanceOf(priceGroup, models.PriceGroup)) {
  8307. if (priceGroup.getId()) {
  8308. this.setPriceGroupId(priceGroup.getId());
  8309. } else if (priceGroup.getName()) {
  8310. this.setPriceGroupName(priceGroup.getName());
  8311. }
  8312. this.setPriceGroupName(priceGroup.getName());
  8313. }
  8314. }
  8315. /**
  8316. * Get PriceGroup_ID.
  8317. * @returns {number}
  8318. */
  8319. getPriceGroupId() {
  8320. return this.priceGroupId;
  8321. }
  8322. /**
  8323. * Get PriceGroup_Name.
  8324. * @returns {string}
  8325. */
  8326. getPriceGroupName() {
  8327. return this.priceGroupName;
  8328. }
  8329. /**
  8330. * Get Edit_Product.
  8331. * @returns {string}
  8332. */
  8333. getEditProduct() {
  8334. return this.editProduct;
  8335. }
  8336. /**
  8337. * Get Product_ID.
  8338. * @returns {number}
  8339. */
  8340. getProductId() {
  8341. return this.productId;
  8342. }
  8343. /**
  8344. * Get Product_Code.
  8345. * @returns {string}
  8346. */
  8347. getProductCode() {
  8348. return this.productCode;
  8349. }
  8350. /**
  8351. * Get Product_SKU.
  8352. * @returns {string}
  8353. */
  8354. getProductSku() {
  8355. return this.productSku;
  8356. }
  8357. /**
  8358. * Get Assigned.
  8359. * @returns {boolean}
  8360. */
  8361. getAssigned() {
  8362. return this.assigned;
  8363. }
  8364. /**
  8365. * Set PriceGroup_ID.
  8366. * @param {number} priceGroupId
  8367. * @returns {PriceGroupProductUpdateAssigned}
  8368. */
  8369. setPriceGroupId(priceGroupId) {
  8370. this.priceGroupId = priceGroupId;
  8371. return this;
  8372. }
  8373. /**
  8374. * Set PriceGroup_Name.
  8375. * @param {string} priceGroupName
  8376. * @returns {PriceGroupProductUpdateAssigned}
  8377. */
  8378. setPriceGroupName(priceGroupName) {
  8379. this.priceGroupName = priceGroupName;
  8380. return this;
  8381. }
  8382. /**
  8383. * Set Edit_Product.
  8384. * @param {string} editProduct
  8385. * @returns {PriceGroupProductUpdateAssigned}
  8386. */
  8387. setEditProduct(editProduct) {
  8388. this.editProduct = editProduct;
  8389. return this;
  8390. }
  8391. /**
  8392. * Set Product_ID.
  8393. * @param {number} productId
  8394. * @returns {PriceGroupProductUpdateAssigned}
  8395. */
  8396. setProductId(productId) {
  8397. this.productId = productId;
  8398. return this;
  8399. }
  8400. /**
  8401. * Set Product_Code.
  8402. * @param {string} productCode
  8403. * @returns {PriceGroupProductUpdateAssigned}
  8404. */
  8405. setProductCode(productCode) {
  8406. this.productCode = productCode;
  8407. return this;
  8408. }
  8409. /**
  8410. * Set Product_SKU.
  8411. * @param {string} productSku
  8412. * @returns {PriceGroupProductUpdateAssigned}
  8413. */
  8414. setProductSku(productSku) {
  8415. this.productSku = productSku;
  8416. return this;
  8417. }
  8418. /**
  8419. * Set Assigned.
  8420. * @param {boolean} assigned
  8421. * @returns {PriceGroupProductUpdateAssigned}
  8422. */
  8423. setAssigned(assigned) {
  8424. this.assigned = assigned;
  8425. return this;
  8426. }
  8427. /**
  8428. * Reduce the request to a an object.
  8429. * @override
  8430. * @returns {Object}
  8431. */
  8432. toObject() {
  8433. var data = super.toObject();
  8434. if (!util.isNullOrUndefined(this.priceGroupId)) {
  8435. data['PriceGroup_ID'] = this.priceGroupId;
  8436. } else if (!util.isNullOrUndefined(this.priceGroupName)) {
  8437. data['PriceGroup_Name'] = this.priceGroupName;
  8438. }
  8439. if (!util.isNullOrUndefined(this.productId)) {
  8440. data['Product_ID'] = this.productId;
  8441. } else if (!util.isNullOrUndefined(this.editProduct)) {
  8442. data['Edit_Product'] = this.editProduct;
  8443. } else if (!util.isNullOrUndefined(this.productId)) {
  8444. data['Product_ID'] = this.productId;
  8445. } else if (!util.isNullOrUndefined(this.productCode)) {
  8446. data['Product_Code'] = this.productCode;
  8447. } else if (!util.isNullOrUndefined(this.productSku)) {
  8448. data['Product_SKU'] = this.productSku;
  8449. }
  8450. if (!util.isNullOrUndefined(this.priceGroupName)) {
  8451. data['PriceGroup_Name'] = this.priceGroupName;
  8452. }
  8453. if (!util.isNullOrUndefined(this.assigned)) {
  8454. data['Assigned'] = this.assigned;
  8455. }
  8456. return data;
  8457. }
  8458. /**
  8459. * Create a response object from the response data.
  8460. * @override
  8461. * @returns {Response}
  8462. */
  8463. createResponse(data) {
  8464. return new responses.PriceGroupProductUpdateAssigned(this, data);
  8465. }
  8466. }
  8467. /**
  8468. * Handles API Request ProductImage_Add. Scope: Store.
  8469. * @see https://docs.miva.com/json-api/functions/productimage_add
  8470. */
  8471. class ProductImageAdd extends Request {
  8472. /**
  8473. * ProductImageAdd Constructor.
  8474. * @param {?Client} client
  8475. * @param {?Product} product
  8476. */
  8477. constructor(client, product = null) {
  8478. super(client);
  8479. this.function = 'ProductImage_Add';
  8480. this.scope = Request.REQUEST_SCOPE_STORE;
  8481. this.productCode = null;
  8482. this.productId = null;
  8483. this.editProduct = null;
  8484. this.productSku = null;
  8485. this.filepath = null;
  8486. this.imageTypeId = null;
  8487. if (util.isInstanceOf(product, models.Product)) {
  8488. if (product.getId()) {
  8489. this.setProductId(product.getId());
  8490. } else if (product.getCode()) {
  8491. this.setEditProduct(product.getCode());
  8492. } else if (product.getSku()) {
  8493. this.setProductSku(product.getSku());
  8494. }
  8495. }
  8496. }
  8497. /**
  8498. * Get Product_Code.
  8499. * @returns {string}
  8500. */
  8501. getProductCode() {
  8502. return this.productCode;
  8503. }
  8504. /**
  8505. * Get Product_ID.
  8506. * @returns {number}
  8507. */
  8508. getProductId() {
  8509. return this.productId;
  8510. }
  8511. /**
  8512. * Get Edit_Product.
  8513. * @returns {string}
  8514. */
  8515. getEditProduct() {
  8516. return this.editProduct;
  8517. }
  8518. /**
  8519. * Get Product_SKU.
  8520. * @returns {string}
  8521. */
  8522. getProductSku() {
  8523. return this.productSku;
  8524. }
  8525. /**
  8526. * Get Filepath.
  8527. * @returns {string}
  8528. */
  8529. getFilepath() {
  8530. return this.filepath;
  8531. }
  8532. /**
  8533. * Get ImageType_ID.
  8534. * @returns {number}
  8535. */
  8536. getImageTypeId() {
  8537. return this.imageTypeId;
  8538. }
  8539. /**
  8540. * Set Product_Code.
  8541. * @param {string} productCode
  8542. * @returns {ProductImageAdd}
  8543. */
  8544. setProductCode(productCode) {
  8545. this.productCode = productCode;
  8546. return this;
  8547. }
  8548. /**
  8549. * Set Product_ID.
  8550. * @param {number} productId
  8551. * @returns {ProductImageAdd}
  8552. */
  8553. setProductId(productId) {
  8554. this.productId = productId;
  8555. return this;
  8556. }
  8557. /**
  8558. * Set Edit_Product.
  8559. * @param {string} editProduct
  8560. * @returns {ProductImageAdd}
  8561. */
  8562. setEditProduct(editProduct) {
  8563. this.editProduct = editProduct;
  8564. return this;
  8565. }
  8566. /**
  8567. * Set Product_SKU.
  8568. * @param {string} productSku
  8569. * @returns {ProductImageAdd}
  8570. */
  8571. setProductSku(productSku) {
  8572. this.productSku = productSku;
  8573. return this;
  8574. }
  8575. /**
  8576. * Set Filepath.
  8577. * @param {string} filepath
  8578. * @returns {ProductImageAdd}
  8579. */
  8580. setFilepath(filepath) {
  8581. this.filepath = filepath;
  8582. return this;
  8583. }
  8584. /**
  8585. * Set ImageType_ID.
  8586. * @param {number} imageTypeId
  8587. * @returns {ProductImageAdd}
  8588. */
  8589. setImageTypeId(imageTypeId) {
  8590. this.imageTypeId = imageTypeId;
  8591. return this;
  8592. }
  8593. /**
  8594. * Reduce the request to a an object.
  8595. * @override
  8596. * @returns {Object}
  8597. */
  8598. toObject() {
  8599. var data = super.toObject();
  8600. if (!util.isNullOrUndefined(this.productId)) {
  8601. data['Product_ID'] = this.productId;
  8602. } else if (!util.isNullOrUndefined(this.editProduct)) {
  8603. data['Edit_Product'] = this.editProduct;
  8604. } else if (!util.isNullOrUndefined(this.productCode)) {
  8605. data['Product_Code'] = this.productCode;
  8606. } else if (!util.isNullOrUndefined(this.productSku)) {
  8607. data['Product_SKU'] = this.productSku;
  8608. }
  8609. data['Filepath'] = this.filepath;
  8610. data['ImageType_ID'] = this.imageTypeId;
  8611. return data;
  8612. }
  8613. /**
  8614. * Create a response object from the response data.
  8615. * @override
  8616. * @returns {Response}
  8617. */
  8618. createResponse(data) {
  8619. return new responses.ProductImageAdd(this, data);
  8620. }
  8621. }
  8622. /**
  8623. * Handles API Request ProductImage_Delete. Scope: Store.
  8624. * @see https://docs.miva.com/json-api/functions/productimage_delete
  8625. */
  8626. class ProductImageDelete extends Request {
  8627. /**
  8628. * ProductImageDelete Constructor.
  8629. * @param {?Client} client
  8630. * @param {?ProductImageData} productImageData
  8631. */
  8632. constructor(client, productImageData = null) {
  8633. super(client);
  8634. this.function = 'ProductImage_Delete';
  8635. this.scope = Request.REQUEST_SCOPE_STORE;
  8636. this.productImageId = null;
  8637. if (util.isInstanceOf(productImageData, models.ProductImageData)) {
  8638. this.setProductImageId(productImageData.getId());
  8639. }
  8640. }
  8641. /**
  8642. * Get ProductImage_ID.
  8643. * @returns {number}
  8644. */
  8645. getProductImageId() {
  8646. return this.productImageId;
  8647. }
  8648. /**
  8649. * Set ProductImage_ID.
  8650. * @param {number} productImageId
  8651. * @returns {ProductImageDelete}
  8652. */
  8653. setProductImageId(productImageId) {
  8654. this.productImageId = productImageId;
  8655. return this;
  8656. }
  8657. /**
  8658. * Reduce the request to a an object.
  8659. * @override
  8660. * @returns {Object}
  8661. */
  8662. toObject() {
  8663. var data = super.toObject();
  8664. data['ProductImage_ID'] = this.productImageId;
  8665. return data;
  8666. }
  8667. /**
  8668. * Create a response object from the response data.
  8669. * @override
  8670. * @returns {Response}
  8671. */
  8672. createResponse(data) {
  8673. return new responses.ProductImageDelete(this, data);
  8674. }
  8675. }
  8676. /**
  8677. * Handles API Request ProductList_Adjust_Inventory. Scope: Store.
  8678. * @see https://docs.miva.com/json-api/functions/productlist_adjust_inventory
  8679. */
  8680. class ProductListAdjustInventory extends Request {
  8681. /**
  8682. * ProductListAdjustInventory Constructor.
  8683. * @param {?Client} client
  8684. */
  8685. constructor(client) {
  8686. super(client);
  8687. this.function = 'ProductList_Adjust_Inventory';
  8688. this.scope = Request.REQUEST_SCOPE_STORE;
  8689. this.inventoryAdjustments = [];
  8690. }
  8691. /**
  8692. * Get Inventory_Adjustments.
  8693. * @returns {ProductInventoryAdjustment[]}
  8694. */
  8695. getInventoryAdjustments() {
  8696. return this.inventoryAdjustments;
  8697. }
  8698. /**
  8699. * Set Inventory_Adjustments.
  8700. * @param {ProductInventoryAdjustment[]} inventoryAdjustments
  8701. * @throws {Error}
  8702. * @returns {ProductListAdjustInventory}
  8703. */
  8704. setInventoryAdjustments(inventoryAdjustments) {
  8705. var i;
  8706. var l;
  8707. if (!util.isArray(inventoryAdjustments)) {
  8708. throw new Error(util.format('Expected an array but got %s', typeof inventoryAdjustments));
  8709. }
  8710. for (i = 0, l = inventoryAdjustments.length; i < l; i++) {
  8711. if (!util.isInstanceOf(inventoryAdjustments[i], models.ProductInventoryAdjustment) && util.isObject(inventoryAdjustments[i])) {
  8712. inventoryAdjustments[i] = new models.ProductInventoryAdjustment(inventoryAdjustments[i]);
  8713. } else if (!util.isInstanceOf(inventoryAdjustments[i], models.ProductInventoryAdjustment)) {
  8714. throw new Error(util.format('Expected instance of ProductInventoryAdjustment or an Object but got %s',
  8715. typeof inventoryAdjustments[i]));
  8716. }
  8717. }
  8718. this.inventoryAdjustments = inventoryAdjustments;
  8719. return this;
  8720. }
  8721. /**
  8722. * Add Inventory_Adjustments.
  8723. * @param {ProductInventoryAdjustment} inventoryAdjustment
  8724. * @throws {Error}
  8725. * @returns {ProductListAdjustInventory}
  8726. */
  8727. addInventoryAdjustment(inventoryAdjustment) {
  8728. if (util.isInstanceOf(inventoryAdjustment, models.ProductInventoryAdjustment)) {
  8729. this.inventoryAdjustments.push(inventoryAdjustment);
  8730. } else if (util.isObject(inventoryAdjustment)) {
  8731. this.inventoryAdjustments.push(new models.ProductInventoryAdjustment(inventoryAdjustment));
  8732. } else {
  8733. throw new Error(util.format('Expected instance of ProductInventoryAdjustment or Object but got %s',
  8734. typeof inventoryAdjustment));
  8735. }
  8736. return this;
  8737. }
  8738. /**
  8739. * Add many ProductInventoryAdjustment.
  8740. * @param {ProductInventoryAdjustment[]} inventoryAdjustments
  8741. * @throws {Error}
  8742. * @returns {ProductListAdjustInventory}
  8743. */
  8744. addInventoryAdjustments(inventoryAdjustments) {
  8745. var i;
  8746. var l;
  8747. if (!util.isArray(inventoryAdjustments)) {
  8748. throw new Error(util.format('Expecting an array of ProductInventoryAdjustment but got %s',
  8749. typeof inventoryAdjustments));
  8750. }
  8751. for (i = 0, l = inventoryAdjustments.length; i < l; i++) {
  8752. if (util.isInstanceOf(inventoryAdjustments[i], models.ProductInventoryAdjustment)) {
  8753. this.inventoryAdjustments.push(inventoryAdjustments[i]);
  8754. } else if (util.isObject(inventoryAdjustments[i])) {
  8755. this.inventoryAdjustments.push(new models.ProductInventoryAdjustment(inventoryAdjustments[i]));
  8756. } else {
  8757. throw new Error(util.format('Expected array of ProductInventoryAdjustment or an array of Object but got %s',
  8758. typeof inventoryAdjustments[i]));
  8759. }
  8760. }
  8761. return this;
  8762. }
  8763. /**
  8764. * Reduce the request to a an object.
  8765. * @override
  8766. * @returns {Object}
  8767. */
  8768. toObject() {
  8769. var i;
  8770. var l;
  8771. var data = super.toObject();
  8772. if (util.isArray(this.inventoryAdjustments)) {
  8773. data['Inventory_Adjustments'] = [];
  8774. for (i = 0, l = this.inventoryAdjustments.length; i < l; i++) {
  8775. data['Inventory_Adjustments'].push(this.inventoryAdjustments[i].toObject());
  8776. }
  8777. }
  8778. return data;
  8779. }
  8780. /**
  8781. * Create a response object from the response data.
  8782. * @override
  8783. * @returns {Response}
  8784. */
  8785. createResponse(data) {
  8786. return new responses.ProductListAdjustInventory(this, data);
  8787. }
  8788. }
  8789. /** PRODUCT_SHOW constants. */
  8790. /** @ignore */
  8791. const PRODUCT_SHOW_ALL = 'All';
  8792. /** @ignore */
  8793. const PRODUCT_SHOW_UNCATEGORIZED = 'Uncategorized';
  8794. /** @ignore */
  8795. const PRODUCT_SHOW_ACTIVE = 'Active';
  8796. /**
  8797. * Handles API Request ProductList_Load_Query. Scope: Store.
  8798. * @see https://docs.miva.com/json-api/functions/productlist_load_query
  8799. */
  8800. class ProductListLoadQuery extends ListQueryRequest {
  8801. /**
  8802. * ProductListLoadQuery Constructor.
  8803. * @param {?Client} client
  8804. */
  8805. constructor(client) {
  8806. super(client);
  8807. this.function = 'ProductList_Load_Query';
  8808. this.scope = Request.REQUEST_SCOPE_STORE;
  8809. this.availableSearchFields = [
  8810. 'id',
  8811. 'code',
  8812. 'sku',
  8813. 'cancat_code',
  8814. 'page_code',
  8815. 'name',
  8816. 'thumbnail',
  8817. 'image',
  8818. 'price',
  8819. 'cost',
  8820. 'descrip',
  8821. 'weight',
  8822. 'taxable',
  8823. 'active',
  8824. 'page_title',
  8825. 'dt_created',
  8826. 'dt_updated',
  8827. 'category',
  8828. 'product_inventory'
  8829. ];
  8830. this.availableSortFields = [
  8831. 'id',
  8832. 'code',
  8833. 'sku',
  8834. 'cancat_code',
  8835. 'page_code',
  8836. 'name',
  8837. 'thumbnail',
  8838. 'image',
  8839. 'price',
  8840. 'cost',
  8841. 'descrip',
  8842. 'weight',
  8843. 'taxable',
  8844. 'active',
  8845. 'page_title',
  8846. 'dt_created',
  8847. 'dt_updated'
  8848. ];
  8849. this.availableOnDemandColumns = [
  8850. 'descrip',
  8851. 'catcount',
  8852. 'productinventorysettings',
  8853. 'attributes',
  8854. 'productimagedata',
  8855. 'categories',
  8856. 'productshippingrules',
  8857. 'relatedproducts',
  8858. 'uris'
  8859. ];
  8860. this.availableCustomFilters = {
  8861. Product_Show : [
  8862. PRODUCT_SHOW_ALL,
  8863. PRODUCT_SHOW_UNCATEGORIZED,
  8864. PRODUCT_SHOW_ACTIVE
  8865. ],
  8866. };
  8867. }
  8868. /**
  8869. * Constant PRODUCT_SHOW_ALL
  8870. * @returns {string}
  8871. * @const
  8872. * @static
  8873. */
  8874. static get PRODUCT_SHOW_ALL() {
  8875. return PRODUCT_SHOW_ALL;
  8876. }
  8877. /**
  8878. * Constant PRODUCT_SHOW_UNCATEGORIZED
  8879. * @returns {string}
  8880. * @const
  8881. * @static
  8882. */
  8883. static get PRODUCT_SHOW_UNCATEGORIZED() {
  8884. return PRODUCT_SHOW_UNCATEGORIZED;
  8885. }
  8886. /**
  8887. * Constant PRODUCT_SHOW_ACTIVE
  8888. * @returns {string}
  8889. * @const
  8890. * @static
  8891. */
  8892. static get PRODUCT_SHOW_ACTIVE() {
  8893. return PRODUCT_SHOW_ACTIVE;
  8894. }
  8895. /**
  8896. * Create a response object from the response data.
  8897. * @override
  8898. * @returns {Response}
  8899. */
  8900. createResponse(data) {
  8901. return new responses.ProductListLoadQuery(this, data);
  8902. }
  8903. }
  8904. /**
  8905. * Handles API Request ProductVariantList_Load_Product. Scope: Store.
  8906. * @see https://docs.miva.com/json-api/functions/productvariantlist_load_product
  8907. */
  8908. class ProductVariantListLoadProduct extends Request {
  8909. /**
  8910. * ProductVariantListLoadProduct Constructor.
  8911. * @param {?Client} client
  8912. * @param {?Product} product
  8913. */
  8914. constructor(client, product = null) {
  8915. super(client);
  8916. this.function = 'ProductVariantList_Load_Product';
  8917. this.scope = Request.REQUEST_SCOPE_STORE;
  8918. this.productId = null;
  8919. this.productCode = null;
  8920. this.editProduct = null;
  8921. this.productSku = null;
  8922. this.includeDefaultVariant = null;
  8923. this.limits = [];
  8924. this.exclusions = [];
  8925. if (util.isInstanceOf(product, models.Product)) {
  8926. if (product.getId()) {
  8927. this.setProductId(product.getId());
  8928. } else if (product.getCode()) {
  8929. this.setEditProduct(product.getCode());
  8930. } else if (product.getSku()) {
  8931. this.setProductSku(product.getSku());
  8932. }
  8933. }
  8934. }
  8935. /**
  8936. * Get Product_ID.
  8937. * @returns {number}
  8938. */
  8939. getProductId() {
  8940. return this.productId;
  8941. }
  8942. /**
  8943. * Get Product_Code.
  8944. * @returns {string}
  8945. */
  8946. getProductCode() {
  8947. return this.productCode;
  8948. }
  8949. /**
  8950. * Get Edit_Product.
  8951. * @returns {string}
  8952. */
  8953. getEditProduct() {
  8954. return this.editProduct;
  8955. }
  8956. /**
  8957. * Get Product_SKU.
  8958. * @returns {string}
  8959. */
  8960. getProductSku() {
  8961. return this.productSku;
  8962. }
  8963. /**
  8964. * Get Include_Default_Variant.
  8965. * @returns {boolean}
  8966. */
  8967. getIncludeDefaultVariant() {
  8968. return this.includeDefaultVariant;
  8969. }
  8970. /**
  8971. * Get Limits.
  8972. * @returns {ProductVariantLimit[]}
  8973. */
  8974. getLimits() {
  8975. return this.limits;
  8976. }
  8977. /**
  8978. * Get Exclusions.
  8979. * @returns {ProductVariantExclusion[]}
  8980. */
  8981. getExclusions() {
  8982. return this.exclusions;
  8983. }
  8984. /**
  8985. * Set Product_ID.
  8986. * @param {number} productId
  8987. * @returns {ProductVariantListLoadProduct}
  8988. */
  8989. setProductId(productId) {
  8990. this.productId = productId;
  8991. return this;
  8992. }
  8993. /**
  8994. * Set Product_Code.
  8995. * @param {string} productCode
  8996. * @returns {ProductVariantListLoadProduct}
  8997. */
  8998. setProductCode(productCode) {
  8999. this.productCode = productCode;
  9000. return this;
  9001. }
  9002. /**
  9003. * Set Edit_Product.
  9004. * @param {string} editProduct
  9005. * @returns {ProductVariantListLoadProduct}
  9006. */
  9007. setEditProduct(editProduct) {
  9008. this.editProduct = editProduct;
  9009. return this;
  9010. }
  9011. /**
  9012. * Set Product_SKU.
  9013. * @param {string} productSku
  9014. * @returns {ProductVariantListLoadProduct}
  9015. */
  9016. setProductSku(productSku) {
  9017. this.productSku = productSku;
  9018. return this;
  9019. }
  9020. /**
  9021. * Set Include_Default_Variant.
  9022. * @param {boolean} includeDefaultVariant
  9023. * @returns {ProductVariantListLoadProduct}
  9024. */
  9025. setIncludeDefaultVariant(includeDefaultVariant) {
  9026. this.includeDefaultVariant = includeDefaultVariant;
  9027. return this;
  9028. }
  9029. /**
  9030. * Set Limits.
  9031. * @param {ProductVariantLimit[]} limits
  9032. * @throws {Error}
  9033. * @returns {ProductVariantListLoadProduct}
  9034. */
  9035. setLimits(limits) {
  9036. var i;
  9037. var l;
  9038. if (!util.isArray(limits)) {
  9039. throw new Error(util.format('Expected an array but got %s', typeof limits));
  9040. }
  9041. for (i = 0, l = limits.length; i < l; i++) {
  9042. if (!util.isInstanceOf(limits[i], models.ProductVariantLimit) && util.isObject(limits[i])) {
  9043. limits[i] = new models.ProductVariantLimit(limits[i]);
  9044. } else if (!util.isInstanceOf(limits[i], models.ProductVariantLimit)) {
  9045. throw new Error(util.format('Expected instance of ProductVariantLimit or an Object but got %s',
  9046. typeof limits[i]));
  9047. }
  9048. }
  9049. this.limits = limits;
  9050. return this;
  9051. }
  9052. /**
  9053. * Set Exclusions.
  9054. * @param {ProductVariantExclusion[]} exclusions
  9055. * @throws {Error}
  9056. * @returns {ProductVariantListLoadProduct}
  9057. */
  9058. setExclusions(exclusions) {
  9059. var i;
  9060. var l;
  9061. if (!util.isArray(exclusions)) {
  9062. throw new Error(util.format('Expected an array but got %s', typeof exclusions));
  9063. }
  9064. for (i = 0, l = exclusions.length; i < l; i++) {
  9065. if (!util.isInstanceOf(exclusions[i], models.ProductVariantExclusion) && util.isObject(exclusions[i])) {
  9066. exclusions[i] = new models.ProductVariantExclusion(exclusions[i]);
  9067. } else if (!util.isInstanceOf(exclusions[i], models.ProductVariantExclusion)) {
  9068. throw new Error(util.format('Expected instance of ProductVariantExclusion or an Object but got %s',
  9069. typeof exclusions[i]));
  9070. }
  9071. }
  9072. this.exclusions = exclusions;
  9073. return this;
  9074. }
  9075. /**
  9076. * Add Limits.
  9077. * @param {ProductVariantLimit} limit
  9078. * @throws {Error}
  9079. * @returns {ProductVariantListLoadProduct}
  9080. */
  9081. addLimit(limit) {
  9082. if (util.isInstanceOf(limit, models.ProductVariantLimit)) {
  9083. this.limits.push(limit);
  9084. } else if (util.isObject(limit)) {
  9085. this.limits.push(new models.ProductVariantLimit(limit));
  9086. } else {
  9087. throw new Error(util.format('Expected instance of ProductVariantLimit or Object but got %s',
  9088. typeof limit));
  9089. }
  9090. return this;
  9091. }
  9092. /**
  9093. * Add many ProductVariantLimit.
  9094. * @param {ProductVariantLimit[]} limits
  9095. * @throws {Error}
  9096. * @returns {ProductVariantListLoadProduct}
  9097. */
  9098. addLimits(limits) {
  9099. var i;
  9100. var l;
  9101. if (!util.isArray(limits)) {
  9102. throw new Error(util.format('Expecting an array of ProductVariantLimit but got %s',
  9103. typeof limits));
  9104. }
  9105. for (i = 0, l = limits.length; i < l; i++) {
  9106. if (util.isInstanceOf(limits[i], models.ProductVariantLimit)) {
  9107. this.limits.push(limits[i]);
  9108. } else if (util.isObject(limits[i])) {
  9109. this.limits.push(new models.ProductVariantLimit(limits[i]));
  9110. } else {
  9111. throw new Error(util.format('Expected array of ProductVariantLimit or an array of Object but got %s',
  9112. typeof limits[i]));
  9113. }
  9114. }
  9115. return this;
  9116. }
  9117. /**
  9118. * Add Exclusions.
  9119. * @param {ProductVariantExclusion} exclusion
  9120. * @throws {Error}
  9121. * @returns {ProductVariantListLoadProduct}
  9122. */
  9123. addExclusion(exclusion) {
  9124. if (util.isInstanceOf(exclusion, models.ProductVariantExclusion)) {
  9125. this.exclusions.push(exclusion);
  9126. } else if (util.isObject(exclusion)) {
  9127. this.exclusions.push(new models.ProductVariantExclusion(exclusion));
  9128. } else {
  9129. throw new Error(util.format('Expected instance of ProductVariantExclusion or Object but got %s',
  9130. typeof exclusion));
  9131. }
  9132. return this;
  9133. }
  9134. /**
  9135. * Add many ProductVariantExclusion.
  9136. * @param {ProductVariantExclusion[]} exclusions
  9137. * @throws {Error}
  9138. * @returns {ProductVariantListLoadProduct}
  9139. */
  9140. addExclusions(exclusions) {
  9141. var i;
  9142. var l;
  9143. if (!util.isArray(exclusions)) {
  9144. throw new Error(util.format('Expecting an array of ProductVariantExclusion but got %s',
  9145. typeof exclusions));
  9146. }
  9147. for (i = 0, l = exclusions.length; i < l; i++) {
  9148. if (util.isInstanceOf(exclusions[i], models.ProductVariantExclusion)) {
  9149. this.exclusions.push(exclusions[i]);
  9150. } else if (util.isObject(exclusions[i])) {
  9151. this.exclusions.push(new models.ProductVariantExclusion(exclusions[i]));
  9152. } else {
  9153. throw new Error(util.format('Expected array of ProductVariantExclusion or an array of Object but got %s',
  9154. typeof exclusions[i]));
  9155. }
  9156. }
  9157. return this;
  9158. }
  9159. /**
  9160. * Reduce the request to a an object.
  9161. * @override
  9162. * @returns {Object}
  9163. */
  9164. toObject() {
  9165. var i;
  9166. var l;
  9167. var data = super.toObject();
  9168. if (!util.isNullOrUndefined(this.productId)) {
  9169. data['Product_ID'] = this.productId;
  9170. } else if (!util.isNullOrUndefined(this.productCode)) {
  9171. data['Product_Code'] = this.productCode;
  9172. } else if (!util.isNullOrUndefined(this.editProduct)) {
  9173. data['Edit_Product'] = this.editProduct;
  9174. } else if (!util.isNullOrUndefined(this.productSku)) {
  9175. data['Product_SKU'] = this.productSku;
  9176. }
  9177. if (!util.isNullOrUndefined(this.includeDefaultVariant)) {
  9178. data['Include_Default_Variant'] = this.includeDefaultVariant;
  9179. }
  9180. if (util.isArray(this.limits)) {
  9181. data['Limits'] = [];
  9182. for (i = 0, l = this.limits.length; i < l; i++) {
  9183. if (util.isObject(this.limits[i])) {
  9184. data['Limits'].push(this.limits[i].toObject());
  9185. }
  9186. }
  9187. }
  9188. if (util.isArray(this.exclusions)) {
  9189. data['Exclusions'] = [];
  9190. for (i = 0, l = this.exclusions.length; i < l; i++) {
  9191. if (util.isObject(this.exclusions[i])) {
  9192. data['Exclusions'].push(this.exclusions[i].toObject());
  9193. }
  9194. }
  9195. }
  9196. return data;
  9197. }
  9198. /**
  9199. * Create a response object from the response data.
  9200. * @override
  9201. * @returns {Response}
  9202. */
  9203. createResponse(data) {
  9204. return new responses.ProductVariantListLoadProduct(this, data);
  9205. }
  9206. }
  9207. /**
  9208. * Handles API Request Product_Insert. Scope: Store.
  9209. * @see https://docs.miva.com/json-api/functions/product_insert
  9210. */
  9211. class ProductInsert extends Request {
  9212. /**
  9213. * ProductInsert Constructor.
  9214. * @param {?Client} client
  9215. * @param {?Product} product
  9216. */
  9217. constructor(client, product = null) {
  9218. super(client);
  9219. this.function = 'Product_Insert';
  9220. this.scope = Request.REQUEST_SCOPE_STORE;
  9221. this.productCode = null;
  9222. this.productSku = null;
  9223. this.productName = null;
  9224. this.productDescription = null;
  9225. this.productCanonicalCategoryCode = null;
  9226. this.productAlternateDisplayPage = null;
  9227. this.productPageTitle = null;
  9228. this.productThumbnail = null;
  9229. this.productImage = null;
  9230. this.productPrice = null;
  9231. this.productCost = null;
  9232. this.productWeight = null;
  9233. this.productInventory = null;
  9234. this.productTaxable = null;
  9235. this.productActive = null;
  9236. this.customFieldValues = new models.CustomFieldValues();
  9237. if (util.isInstanceOf(product, models.Product)) {
  9238. this.setProductCode(product.getCode());
  9239. this.setProductSku(product.getSku());
  9240. this.setProductName(product.getName());
  9241. this.setProductDescription(product.getDescription());
  9242. this.setProductCanonicalCategoryCode(product.getCanonicalCategoryCode());
  9243. this.setProductAlternateDisplayPage(product.getPageCode());
  9244. this.setProductPageTitle(product.getPageTitle());
  9245. this.setProductThumbnail(product.getThumbnail());
  9246. this.setProductImage(product.getImage());
  9247. this.setProductPrice(product.getPrice());
  9248. this.setProductCost(product.getCost());
  9249. this.setProductWeight(product.getWeight());
  9250. this.setProductInventory(product.getProductInventory());
  9251. this.setProductTaxable(product.getTaxable());
  9252. this.setProductActive(product.getActive());
  9253. if (product.getCustomFieldValues()) {
  9254. this.setCustomFieldValues(product.getCustomFieldValues());
  9255. }
  9256. }
  9257. }
  9258. /**
  9259. * Get Product_Code.
  9260. * @returns {string}
  9261. */
  9262. getProductCode() {
  9263. return this.productCode;
  9264. }
  9265. /**
  9266. * Get Product_SKU.
  9267. * @returns {string}
  9268. */
  9269. getProductSku() {
  9270. return this.productSku;
  9271. }
  9272. /**
  9273. * Get Product_Name.
  9274. * @returns {string}
  9275. */
  9276. getProductName() {
  9277. return this.productName;
  9278. }
  9279. /**
  9280. * Get Product_Description.
  9281. * @returns {string}
  9282. */
  9283. getProductDescription() {
  9284. return this.productDescription;
  9285. }
  9286. /**
  9287. * Get Product_Canonical_Category_Code.
  9288. * @returns {string}
  9289. */
  9290. getProductCanonicalCategoryCode() {
  9291. return this.productCanonicalCategoryCode;
  9292. }
  9293. /**
  9294. * Get Product_Alternate_Display_Page.
  9295. * @returns {string}
  9296. */
  9297. getProductAlternateDisplayPage() {
  9298. return this.productAlternateDisplayPage;
  9299. }
  9300. /**
  9301. * Get Product_Page_Title.
  9302. * @returns {string}
  9303. */
  9304. getProductPageTitle() {
  9305. return this.productPageTitle;
  9306. }
  9307. /**
  9308. * Get Product_Thumbnail.
  9309. * @returns {string}
  9310. */
  9311. getProductThumbnail() {
  9312. return this.productThumbnail;
  9313. }
  9314. /**
  9315. * Get Product_Image.
  9316. * @returns {string}
  9317. */
  9318. getProductImage() {
  9319. return this.productImage;
  9320. }
  9321. /**
  9322. * Get Product_Price.
  9323. * @returns {number}
  9324. */
  9325. getProductPrice() {
  9326. return this.productPrice;
  9327. }
  9328. /**
  9329. * Get Product_Cost.
  9330. * @returns {number}
  9331. */
  9332. getProductCost() {
  9333. return this.productCost;
  9334. }
  9335. /**
  9336. * Get Product_Weight.
  9337. * @returns {number}
  9338. */
  9339. getProductWeight() {
  9340. return this.productWeight;
  9341. }
  9342. /**
  9343. * Get Product_Inventory.
  9344. * @returns {number}
  9345. */
  9346. getProductInventory() {
  9347. return this.productInventory;
  9348. }
  9349. /**
  9350. * Get Product_Taxable.
  9351. * @returns {boolean}
  9352. */
  9353. getProductTaxable() {
  9354. return this.productTaxable;
  9355. }
  9356. /**
  9357. * Get Product_Active.
  9358. * @returns {boolean}
  9359. */
  9360. getProductActive() {
  9361. return this.productActive;
  9362. }
  9363. /**
  9364. * Get CustomField_Values.
  9365. * @returns {?CustomFieldValues}
  9366. */
  9367. getCustomFieldValues() {
  9368. return this.customFieldValues;
  9369. }
  9370. /**
  9371. * Set Product_Code.
  9372. * @param {string} productCode
  9373. * @returns {ProductInsert}
  9374. */
  9375. setProductCode(productCode) {
  9376. this.productCode = productCode;
  9377. return this;
  9378. }
  9379. /**
  9380. * Set Product_SKU.
  9381. * @param {string} productSku
  9382. * @returns {ProductInsert}
  9383. */
  9384. setProductSku(productSku) {
  9385. this.productSku = productSku;
  9386. return this;
  9387. }
  9388. /**
  9389. * Set Product_Name.
  9390. * @param {string} productName
  9391. * @returns {ProductInsert}
  9392. */
  9393. setProductName(productName) {
  9394. this.productName = productName;
  9395. return this;
  9396. }
  9397. /**
  9398. * Set Product_Description.
  9399. * @param {string} productDescription
  9400. * @returns {ProductInsert}
  9401. */
  9402. setProductDescription(productDescription) {
  9403. this.productDescription = productDescription;
  9404. return this;
  9405. }
  9406. /**
  9407. * Set Product_Canonical_Category_Code.
  9408. * @param {string} productCanonicalCategoryCode
  9409. * @returns {ProductInsert}
  9410. */
  9411. setProductCanonicalCategoryCode(productCanonicalCategoryCode) {
  9412. this.productCanonicalCategoryCode = productCanonicalCategoryCode;
  9413. return this;
  9414. }
  9415. /**
  9416. * Set Product_Alternate_Display_Page.
  9417. * @param {string} productAlternateDisplayPage
  9418. * @returns {ProductInsert}
  9419. */
  9420. setProductAlternateDisplayPage(productAlternateDisplayPage) {
  9421. this.productAlternateDisplayPage = productAlternateDisplayPage;
  9422. return this;
  9423. }
  9424. /**
  9425. * Set Product_Page_Title.
  9426. * @param {string} productPageTitle
  9427. * @returns {ProductInsert}
  9428. */
  9429. setProductPageTitle(productPageTitle) {
  9430. this.productPageTitle = productPageTitle;
  9431. return this;
  9432. }
  9433. /**
  9434. * Set Product_Thumbnail.
  9435. * @param {string} productThumbnail
  9436. * @returns {ProductInsert}
  9437. */
  9438. setProductThumbnail(productThumbnail) {
  9439. this.productThumbnail = productThumbnail;
  9440. return this;
  9441. }
  9442. /**
  9443. * Set Product_Image.
  9444. * @param {string} productImage
  9445. * @returns {ProductInsert}
  9446. */
  9447. setProductImage(productImage) {
  9448. this.productImage = productImage;
  9449. return this;
  9450. }
  9451. /**
  9452. * Set Product_Price.
  9453. * @param {number} productPrice
  9454. * @returns {ProductInsert}
  9455. */
  9456. setProductPrice(productPrice) {
  9457. this.productPrice = productPrice;
  9458. return this;
  9459. }
  9460. /**
  9461. * Set Product_Cost.
  9462. * @param {number} productCost
  9463. * @returns {ProductInsert}
  9464. */
  9465. setProductCost(productCost) {
  9466. this.productCost = productCost;
  9467. return this;
  9468. }
  9469. /**
  9470. * Set Product_Weight.
  9471. * @param {number} productWeight
  9472. * @returns {ProductInsert}
  9473. */
  9474. setProductWeight(productWeight) {
  9475. this.productWeight = productWeight;
  9476. return this;
  9477. }
  9478. /**
  9479. * Set Product_Inventory.
  9480. * @param {number} productInventory
  9481. * @returns {ProductInsert}
  9482. */
  9483. setProductInventory(productInventory) {
  9484. this.productInventory = productInventory;
  9485. return this;
  9486. }
  9487. /**
  9488. * Set Product_Taxable.
  9489. * @param {boolean} productTaxable
  9490. * @returns {ProductInsert}
  9491. */
  9492. setProductTaxable(productTaxable) {
  9493. this.productTaxable = productTaxable;
  9494. return this;
  9495. }
  9496. /**
  9497. * Set Product_Active.
  9498. * @param {boolean} productActive
  9499. * @returns {ProductInsert}
  9500. */
  9501. setProductActive(productActive) {
  9502. this.productActive = productActive;
  9503. return this;
  9504. }
  9505. /**
  9506. * Set CustomField_Values.
  9507. * @param {?CustomFieldValues} customFieldValues
  9508. * @throws {Error}
  9509. * @returns {ProductInsert}
  9510. */
  9511. setCustomFieldValues(customFieldValues) {
  9512. if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues) && util.isObject(customFieldValues)) {
  9513. customFieldValues = new models.CustomFieldValues(customFieldValues);
  9514. } else if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues)) {
  9515. throw new Error(util.format('Expected instance of CustomFieldValues or an Object but got %s',
  9516. typeof customFieldValues));
  9517. }
  9518. this.customFieldValues = customFieldValues;
  9519. return this;
  9520. }
  9521. /**
  9522. * Reduce the request to a an object.
  9523. * @override
  9524. * @returns {Object}
  9525. */
  9526. toObject() {
  9527. var data = super.toObject();
  9528. data['Product_Code'] = this.productCode;
  9529. data['Product_SKU'] = this.productSku;
  9530. data['Product_Name'] = this.productName;
  9531. if (!util.isNullOrUndefined(this.productDescription)) {
  9532. data['Product_Description'] = this.productDescription;
  9533. }
  9534. if (!util.isNullOrUndefined(this.productCanonicalCategoryCode)) {
  9535. data['Product_Canonical_Category_Code'] = this.productCanonicalCategoryCode;
  9536. }
  9537. if (!util.isNullOrUndefined(this.productAlternateDisplayPage)) {
  9538. data['Product_Alternate_Display_Page'] = this.productAlternateDisplayPage;
  9539. }
  9540. if (!util.isNullOrUndefined(this.productPageTitle)) {
  9541. data['Product_Page_Title'] = this.productPageTitle;
  9542. }
  9543. if (!util.isNullOrUndefined(this.productThumbnail)) {
  9544. data['Product_Thumbnail'] = this.productThumbnail;
  9545. }
  9546. if (!util.isNullOrUndefined(this.productImage)) {
  9547. data['Product_Image'] = this.productImage;
  9548. }
  9549. if (!util.isNullOrUndefined(this.productPrice)) {
  9550. data['Product_Price'] = this.productPrice;
  9551. }
  9552. if (!util.isNullOrUndefined(this.productCost)) {
  9553. data['Product_Cost'] = this.productCost;
  9554. }
  9555. if (!util.isNullOrUndefined(this.productWeight)) {
  9556. data['Product_Weight'] = this.productWeight;
  9557. }
  9558. if (!util.isNullOrUndefined(this.productInventory)) {
  9559. data['Product_Inventory'] = this.productInventory;
  9560. }
  9561. if (!util.isNullOrUndefined(this.productTaxable)) {
  9562. data['Product_Taxable'] = this.productTaxable;
  9563. }
  9564. if (!util.isNullOrUndefined(this.productActive)) {
  9565. data['Product_Active'] = this.productActive;
  9566. }
  9567. if (this.customFieldValues && util.isObject(this.customFieldValues)) {
  9568. data['CustomField_Values'] = this.customFieldValues.toObject();
  9569. }
  9570. return data;
  9571. }
  9572. /**
  9573. * Create a response object from the response data.
  9574. * @override
  9575. * @returns {Response}
  9576. */
  9577. createResponse(data) {
  9578. return new responses.ProductInsert(this, data);
  9579. }
  9580. }
  9581. /**
  9582. * Handles API Request Product_Delete. Scope: Store.
  9583. * @see https://docs.miva.com/json-api/functions/product_delete
  9584. */
  9585. class ProductDelete extends Request {
  9586. /**
  9587. * ProductDelete Constructor.
  9588. * @param {?Client} client
  9589. * @param {?Product} product
  9590. */
  9591. constructor(client, product = null) {
  9592. super(client);
  9593. this.function = 'Product_Delete';
  9594. this.scope = Request.REQUEST_SCOPE_STORE;
  9595. this.productCode = null;
  9596. this.productId = null;
  9597. this.editProduct = null;
  9598. this.productSku = null;
  9599. if (util.isInstanceOf(product, models.Product)) {
  9600. if (product.getId()) {
  9601. this.setProductId(product.getId());
  9602. } else if (product.getCode()) {
  9603. this.setEditProduct(product.getCode());
  9604. } else if (product.getSku()) {
  9605. this.setProductSku(product.getSku());
  9606. }
  9607. }
  9608. }
  9609. /**
  9610. * Get Product_Code.
  9611. * @returns {string}
  9612. */
  9613. getProductCode() {
  9614. return this.productCode;
  9615. }
  9616. /**
  9617. * Get Product_ID.
  9618. * @returns {number}
  9619. */
  9620. getProductId() {
  9621. return this.productId;
  9622. }
  9623. /**
  9624. * Get Edit_Product.
  9625. * @returns {string}
  9626. */
  9627. getEditProduct() {
  9628. return this.editProduct;
  9629. }
  9630. /**
  9631. * Get Product_SKU.
  9632. * @returns {string}
  9633. */
  9634. getProductSku() {
  9635. return this.productSku;
  9636. }
  9637. /**
  9638. * Set Product_Code.
  9639. * @param {string} productCode
  9640. * @returns {ProductDelete}
  9641. */
  9642. setProductCode(productCode) {
  9643. this.productCode = productCode;
  9644. return this;
  9645. }
  9646. /**
  9647. * Set Product_ID.
  9648. * @param {number} productId
  9649. * @returns {ProductDelete}
  9650. */
  9651. setProductId(productId) {
  9652. this.productId = productId;
  9653. return this;
  9654. }
  9655. /**
  9656. * Set Edit_Product.
  9657. * @param {string} editProduct
  9658. * @returns {ProductDelete}
  9659. */
  9660. setEditProduct(editProduct) {
  9661. this.editProduct = editProduct;
  9662. return this;
  9663. }
  9664. /**
  9665. * Set Product_SKU.
  9666. * @param {string} productSku
  9667. * @returns {ProductDelete}
  9668. */
  9669. setProductSku(productSku) {
  9670. this.productSku = productSku;
  9671. return this;
  9672. }
  9673. /**
  9674. * Reduce the request to a an object.
  9675. * @override
  9676. * @returns {Object}
  9677. */
  9678. toObject() {
  9679. var data = super.toObject();
  9680. if (!util.isNullOrUndefined(this.productId)) {
  9681. data['Product_ID'] = this.productId;
  9682. } else if (!util.isNullOrUndefined(this.editProduct)) {
  9683. data['Edit_Product'] = this.editProduct;
  9684. } else if (!util.isNullOrUndefined(this.productCode)) {
  9685. data['Product_Code'] = this.productCode;
  9686. } else if (!util.isNullOrUndefined(this.productSku)) {
  9687. data['Product_SKU'] = this.productSku;
  9688. }
  9689. return data;
  9690. }
  9691. /**
  9692. * Create a response object from the response data.
  9693. * @override
  9694. * @returns {Response}
  9695. */
  9696. createResponse(data) {
  9697. return new responses.ProductDelete(this, data);
  9698. }
  9699. }
  9700. /**
  9701. * Handles API Request Product_Update. Scope: Store.
  9702. * @see https://docs.miva.com/json-api/functions/product_update
  9703. */
  9704. class ProductUpdate extends Request {
  9705. /**
  9706. * ProductUpdate Constructor.
  9707. * @param {?Client} client
  9708. * @param {?Product} product
  9709. */
  9710. constructor(client, product = null) {
  9711. super(client);
  9712. this.function = 'Product_Update';
  9713. this.scope = Request.REQUEST_SCOPE_STORE;
  9714. this.productId = null;
  9715. this.productCode = null;
  9716. this.editProduct = null;
  9717. this.productSku = null;
  9718. this.productName = null;
  9719. this.productDescription = null;
  9720. this.productCanonicalCategoryCode = null;
  9721. this.productAlternateDisplayPage = null;
  9722. this.productPageTitle = null;
  9723. this.productThumbnail = null;
  9724. this.productImage = null;
  9725. this.productPrice = null;
  9726. this.productCost = null;
  9727. this.productWeight = null;
  9728. this.productInventory = null;
  9729. this.productTaxable = null;
  9730. this.productActive = null;
  9731. this.customFieldValues = new models.CustomFieldValues();
  9732. if (util.isInstanceOf(product, models.Product)) {
  9733. if (product.getId()) {
  9734. this.setProductId(product.getId());
  9735. } else if (product.getCode()) {
  9736. this.setEditProduct(product.getCode());
  9737. }
  9738. this.setProductCode(product.getCode());
  9739. this.setProductSku(product.getSku());
  9740. this.setProductName(product.getName());
  9741. this.setProductDescription(product.getDescription());
  9742. this.setProductCanonicalCategoryCode(product.getCanonicalCategoryCode());
  9743. this.setProductAlternateDisplayPage(product.getPageCode());
  9744. this.setProductPageTitle(product.getPageTitle());
  9745. this.setProductThumbnail(product.getThumbnail());
  9746. this.setProductImage(product.getImage());
  9747. this.setProductPrice(product.getPrice());
  9748. this.setProductCost(product.getCost());
  9749. this.setProductWeight(product.getWeight());
  9750. this.setProductInventory(product.getProductInventory());
  9751. this.setProductTaxable(product.getTaxable());
  9752. this.setProductActive(product.getActive());
  9753. if (product.getCustomFieldValues()) {
  9754. this.setCustomFieldValues(product.getCustomFieldValues());
  9755. }
  9756. }
  9757. }
  9758. /**
  9759. * Get Product_ID.
  9760. * @returns {number}
  9761. */
  9762. getProductId() {
  9763. return this.productId;
  9764. }
  9765. /**
  9766. * Get Product_Code.
  9767. * @returns {string}
  9768. */
  9769. getProductCode() {
  9770. return this.productCode;
  9771. }
  9772. /**
  9773. * Get Edit_Product.
  9774. * @returns {string}
  9775. */
  9776. getEditProduct() {
  9777. return this.editProduct;
  9778. }
  9779. /**
  9780. * Get Product_SKU.
  9781. * @returns {string}
  9782. */
  9783. getProductSku() {
  9784. return this.productSku;
  9785. }
  9786. /**
  9787. * Get Product_Name.
  9788. * @returns {string}
  9789. */
  9790. getProductName() {
  9791. return this.productName;
  9792. }
  9793. /**
  9794. * Get Product_Description.
  9795. * @returns {string}
  9796. */
  9797. getProductDescription() {
  9798. return this.productDescription;
  9799. }
  9800. /**
  9801. * Get Product_Canonical_Category_Code.
  9802. * @returns {string}
  9803. */
  9804. getProductCanonicalCategoryCode() {
  9805. return this.productCanonicalCategoryCode;
  9806. }
  9807. /**
  9808. * Get Product_Alternate_Display_Page.
  9809. * @returns {string}
  9810. */
  9811. getProductAlternateDisplayPage() {
  9812. return this.productAlternateDisplayPage;
  9813. }
  9814. /**
  9815. * Get Product_Page_Title.
  9816. * @returns {string}
  9817. */
  9818. getProductPageTitle() {
  9819. return this.productPageTitle;
  9820. }
  9821. /**
  9822. * Get Product_Thumbnail.
  9823. * @returns {string}
  9824. */
  9825. getProductThumbnail() {
  9826. return this.productThumbnail;
  9827. }
  9828. /**
  9829. * Get Product_Image.
  9830. * @returns {string}
  9831. */
  9832. getProductImage() {
  9833. return this.productImage;
  9834. }
  9835. /**
  9836. * Get Product_Price.
  9837. * @returns {number}
  9838. */
  9839. getProductPrice() {
  9840. return this.productPrice;
  9841. }
  9842. /**
  9843. * Get Product_Cost.
  9844. * @returns {number}
  9845. */
  9846. getProductCost() {
  9847. return this.productCost;
  9848. }
  9849. /**
  9850. * Get Product_Weight.
  9851. * @returns {number}
  9852. */
  9853. getProductWeight() {
  9854. return this.productWeight;
  9855. }
  9856. /**
  9857. * Get Product_Inventory.
  9858. * @returns {number}
  9859. */
  9860. getProductInventory() {
  9861. return this.productInventory;
  9862. }
  9863. /**
  9864. * Get Product_Taxable.
  9865. * @returns {boolean}
  9866. */
  9867. getProductTaxable() {
  9868. return this.productTaxable;
  9869. }
  9870. /**
  9871. * Get Product_Active.
  9872. * @returns {boolean}
  9873. */
  9874. getProductActive() {
  9875. return this.productActive;
  9876. }
  9877. /**
  9878. * Get CustomField_Values.
  9879. * @returns {?CustomFieldValues}
  9880. */
  9881. getCustomFieldValues() {
  9882. return this.customFieldValues;
  9883. }
  9884. /**
  9885. * Set Product_ID.
  9886. * @param {number} productId
  9887. * @returns {ProductUpdate}
  9888. */
  9889. setProductId(productId) {
  9890. this.productId = productId;
  9891. return this;
  9892. }
  9893. /**
  9894. * Set Product_Code.
  9895. * @param {string} productCode
  9896. * @returns {ProductUpdate}
  9897. */
  9898. setProductCode(productCode) {
  9899. this.productCode = productCode;
  9900. return this;
  9901. }
  9902. /**
  9903. * Set Edit_Product.
  9904. * @param {string} editProduct
  9905. * @returns {ProductUpdate}
  9906. */
  9907. setEditProduct(editProduct) {
  9908. this.editProduct = editProduct;
  9909. return this;
  9910. }
  9911. /**
  9912. * Set Product_SKU.
  9913. * @param {string} productSku
  9914. * @returns {ProductUpdate}
  9915. */
  9916. setProductSku(productSku) {
  9917. this.productSku = productSku;
  9918. return this;
  9919. }
  9920. /**
  9921. * Set Product_Name.
  9922. * @param {string} productName
  9923. * @returns {ProductUpdate}
  9924. */
  9925. setProductName(productName) {
  9926. this.productName = productName;
  9927. return this;
  9928. }
  9929. /**
  9930. * Set Product_Description.
  9931. * @param {string} productDescription
  9932. * @returns {ProductUpdate}
  9933. */
  9934. setProductDescription(productDescription) {
  9935. this.productDescription = productDescription;
  9936. return this;
  9937. }
  9938. /**
  9939. * Set Product_Canonical_Category_Code.
  9940. * @param {string} productCanonicalCategoryCode
  9941. * @returns {ProductUpdate}
  9942. */
  9943. setProductCanonicalCategoryCode(productCanonicalCategoryCode) {
  9944. this.productCanonicalCategoryCode = productCanonicalCategoryCode;
  9945. return this;
  9946. }
  9947. /**
  9948. * Set Product_Alternate_Display_Page.
  9949. * @param {string} productAlternateDisplayPage
  9950. * @returns {ProductUpdate}
  9951. */
  9952. setProductAlternateDisplayPage(productAlternateDisplayPage) {
  9953. this.productAlternateDisplayPage = productAlternateDisplayPage;
  9954. return this;
  9955. }
  9956. /**
  9957. * Set Product_Page_Title.
  9958. * @param {string} productPageTitle
  9959. * @returns {ProductUpdate}
  9960. */
  9961. setProductPageTitle(productPageTitle) {
  9962. this.productPageTitle = productPageTitle;
  9963. return this;
  9964. }
  9965. /**
  9966. * Set Product_Thumbnail.
  9967. * @param {string} productThumbnail
  9968. * @returns {ProductUpdate}
  9969. */
  9970. setProductThumbnail(productThumbnail) {
  9971. this.productThumbnail = productThumbnail;
  9972. return this;
  9973. }
  9974. /**
  9975. * Set Product_Image.
  9976. * @param {string} productImage
  9977. * @returns {ProductUpdate}
  9978. */
  9979. setProductImage(productImage) {
  9980. this.productImage = productImage;
  9981. return this;
  9982. }
  9983. /**
  9984. * Set Product_Price.
  9985. * @param {number} productPrice
  9986. * @returns {ProductUpdate}
  9987. */
  9988. setProductPrice(productPrice) {
  9989. this.productPrice = productPrice;
  9990. return this;
  9991. }
  9992. /**
  9993. * Set Product_Cost.
  9994. * @param {number} productCost
  9995. * @returns {ProductUpdate}
  9996. */
  9997. setProductCost(productCost) {
  9998. this.productCost = productCost;
  9999. return this;
  10000. }
  10001. /**
  10002. * Set Product_Weight.
  10003. * @param {number} productWeight
  10004. * @returns {ProductUpdate}
  10005. */
  10006. setProductWeight(productWeight) {
  10007. this.productWeight = productWeight;
  10008. return this;
  10009. }
  10010. /**
  10011. * Set Product_Inventory.
  10012. * @param {number} productInventory
  10013. * @returns {ProductUpdate}
  10014. */
  10015. setProductInventory(productInventory) {
  10016. this.productInventory = productInventory;
  10017. return this;
  10018. }
  10019. /**
  10020. * Set Product_Taxable.
  10021. * @param {boolean} productTaxable
  10022. * @returns {ProductUpdate}
  10023. */
  10024. setProductTaxable(productTaxable) {
  10025. this.productTaxable = productTaxable;
  10026. return this;
  10027. }
  10028. /**
  10029. * Set Product_Active.
  10030. * @param {boolean} productActive
  10031. * @returns {ProductUpdate}
  10032. */
  10033. setProductActive(productActive) {
  10034. this.productActive = productActive;
  10035. return this;
  10036. }
  10037. /**
  10038. * Set CustomField_Values.
  10039. * @param {?CustomFieldValues} customFieldValues
  10040. * @throws {Error}
  10041. * @returns {ProductUpdate}
  10042. */
  10043. setCustomFieldValues(customFieldValues) {
  10044. if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues) && util.isObject(customFieldValues)) {
  10045. customFieldValues = new models.CustomFieldValues(customFieldValues);
  10046. } else if (!util.isInstanceOf(customFieldValues, models.CustomFieldValues)) {
  10047. throw new Error(util.format('Expected instance of CustomFieldValues or an Object but got %s',
  10048. typeof customFieldValues));
  10049. }
  10050. this.customFieldValues = customFieldValues;
  10051. return this;
  10052. }
  10053. /**
  10054. * Reduce the request to a an object.
  10055. * @override
  10056. * @returns {Object}
  10057. */
  10058. toObject() {
  10059. var data = super.toObject();
  10060. if (!util.isNullOrUndefined(this.productId)) {
  10061. data['Product_ID'] = this.productId;
  10062. } else if (!util.isNullOrUndefined(this.editProduct)) {
  10063. data['Edit_Product'] = this.editProduct;
  10064. }
  10065. if (!util.isNullOrUndefined(this.productCode)) {
  10066. data['Product_Code'] = this.productCode;
  10067. }
  10068. if (!util.isNullOrUndefined(this.productSku)) {
  10069. data['Product_SKU'] = this.productSku;
  10070. }
  10071. if (!util.isNullOrUndefined(this.productName)) {
  10072. data['Product_Name'] = this.productName;
  10073. }
  10074. if (!util.isNullOrUndefined(this.productDescription)) {
  10075. data['Product_Description'] = this.productDescription;
  10076. }
  10077. if (!util.isNullOrUndefined(this.productCanonicalCategoryCode)) {
  10078. data['Product_Canonical_Category_Code'] = this.productCanonicalCategoryCode;
  10079. }
  10080. if (!util.isNullOrUndefined(this.productAlternateDisplayPage)) {
  10081. data['Product_Alternate_Display_Page'] = this.productAlternateDisplayPage;
  10082. }
  10083. if (!util.isNullOrUndefined(this.productPageTitle)) {
  10084. data['Product_Page_Title'] = this.productPageTitle;
  10085. }
  10086. if (!util.isNullOrUndefined(this.productThumbnail)) {
  10087. data['Product_Thumbnail'] = this.productThumbnail;
  10088. }
  10089. if (!util.isNullOrUndefined(this.productImage)) {
  10090. data['Product_Image'] = this.productImage;
  10091. }
  10092. if (!util.isNullOrUndefined(this.productPrice)) {
  10093. data['Product_Price'] = this.productPrice;
  10094. }
  10095. if (!util.isNullOrUndefined(this.productCost)) {
  10096. data['Product_Cost'] = this.productCost;
  10097. }
  10098. if (!util.isNullOrUndefined(this.productWeight)) {
  10099. data['Product_Weight'] = this.productWeight;
  10100. }
  10101. if (!util.isNullOrUndefined(this.productInventory)) {
  10102. data['Product_Inventory'] = this.productInventory;
  10103. }
  10104. if (!util.isNullOrUndefined(this.productTaxable)) {
  10105. data['Product_Taxable'] = this.productTaxable;
  10106. }
  10107. if (!util.isNullOrUndefined(this.productActive)) {
  10108. data['Product_Active'] = this.productActive;
  10109. }
  10110. if (this.customFieldValues && util.isObject(this.customFieldValues)) {
  10111. data['CustomField_Values'] = this.customFieldValues.toObject();
  10112. }
  10113. return data;
  10114. }
  10115. /**
  10116. * Create a response object from the response data.
  10117. * @override
  10118. * @returns {Response}
  10119. */
  10120. createResponse(data) {
  10121. return new responses.ProductUpdate(this, data);
  10122. }
  10123. }
  10124. /**
  10125. * Handles API Request Provision_Domain. Scope: Domain.
  10126. * @see https://docs.miva.com/json-api/functions/provision_domain
  10127. */
  10128. class ProvisionDomain extends Request {
  10129. /**
  10130. * ProvisionDomain Constructor.
  10131. * @param {?Client} client
  10132. */
  10133. constructor(client) {
  10134. super(client);
  10135. this.function = 'Provision_Domain';
  10136. this.scope = Request.REQUEST_SCOPE_DOMAIN;
  10137. this.xml = null;
  10138. }
  10139. /**
  10140. * Get xml.
  10141. * @returns {string}
  10142. */
  10143. getXml() {
  10144. return this.xml;
  10145. }
  10146. /**
  10147. * Set xml.
  10148. * @param {string} xml
  10149. * @returns {ProvisionDomain}
  10150. */
  10151. setXml(xml) {
  10152. this.xml = xml;
  10153. return this;
  10154. }
  10155. /**
  10156. * Reduce the request to a an object.
  10157. * @override
  10158. * @returns {Object}
  10159. */
  10160. toObject() {
  10161. var data = super.toObject();
  10162. data['XML'] = this.xml;
  10163. return data;
  10164. }
  10165. /**
  10166. * Create a response object from the response data.
  10167. * @override
  10168. * @returns {Response}
  10169. */
  10170. createResponse(data) {
  10171. return new responses.ProvisionDomain(this, data);
  10172. }
  10173. }
  10174. /**
  10175. * Handles API Request Provision_Store. Scope: Store.
  10176. * @see https://docs.miva.com/json-api/functions/provision_store
  10177. */
  10178. class ProvisionStore extends Request {
  10179. /**
  10180. * ProvisionStore Constructor.
  10181. * @param {?Client} client
  10182. */
  10183. constructor(client) {
  10184. super(client);
  10185. this.function = 'Provision_Store';
  10186. this.scope = Request.REQUEST_SCOPE_STORE;
  10187. this.xml = null;
  10188. }
  10189. /**
  10190. * Get xml.
  10191. * @returns {string}
  10192. */
  10193. getXml() {
  10194. return this.xml;
  10195. }
  10196. /**
  10197. * Set xml.
  10198. * @param {string} xml
  10199. * @returns {ProvisionStore}
  10200. */
  10201. setXml(xml) {
  10202. this.xml = xml;
  10203. return this;
  10204. }
  10205. /**
  10206. * Reduce the request to a an object.
  10207. * @override
  10208. * @returns {Object}
  10209. */
  10210. toObject() {
  10211. var data = super.toObject();
  10212. data['XML'] = this.xml;
  10213. return data;
  10214. }
  10215. /**
  10216. * Create a response object from the response data.
  10217. * @override
  10218. * @returns {Response}
  10219. */
  10220. createResponse(data) {
  10221. return new responses.ProvisionStore(this, data);
  10222. }
  10223. }
  10224. /**
  10225. * Handles API Request CustomerAddressList_Load_Query. Scope: Store.
  10226. * @see https://docs.miva.com/json-api/functions/customeraddresslist_load_query
  10227. */
  10228. class CustomerAddressListLoadQuery extends ListQueryRequest {
  10229. /**
  10230. * CustomerAddressListLoadQuery Constructor.
  10231. * @param {?Client} client
  10232. * @param {?Customer} customer
  10233. */
  10234. constructor(client, customer = null) {
  10235. super(client);
  10236. this.function = 'CustomerAddressList_Load_Query';
  10237. this.scope = Request.REQUEST_SCOPE_STORE;
  10238. this.availableSearchFields = [
  10239. 'cust_id',
  10240. 'id',
  10241. 'descrip',
  10242. 'fname',
  10243. 'lname',
  10244. 'email',
  10245. 'comp',
  10246. 'phone',
  10247. 'fax',
  10248. 'addr1',
  10249. 'addr2',
  10250. 'city',
  10251. 'state',
  10252. 'zip',
  10253. 'cntry',
  10254. 'resdntl'
  10255. ];
  10256. this.availableSortFields = [
  10257. 'cust_id',
  10258. 'id',
  10259. 'descrip',
  10260. 'fname',
  10261. 'lname',
  10262. 'email',
  10263. 'comp',
  10264. 'phone',
  10265. 'fax',
  10266. 'addr1',
  10267. 'addr2',
  10268. 'city',
  10269. 'state',
  10270. 'zip',
  10271. 'cntry',
  10272. 'resdntl'
  10273. ];
  10274. this.customerId = null;
  10275. this.editCustomer = null;
  10276. this.customerLogin = null;
  10277. if (util.isInstanceOf(customer, models.Customer)) {
  10278. if (customer.getId()) {
  10279. this.setCustomerId(customer.getId());
  10280. } else if (customer.getLogin()) {
  10281. this.setEditCustomer(customer.getLogin());
  10282. }
  10283. }
  10284. }
  10285. /**
  10286. * Get Customer_ID.
  10287. * @returns {number}
  10288. */
  10289. getCustomerId() {
  10290. return this.customerId;
  10291. }
  10292. /**
  10293. * Get Edit_Customer.
  10294. * @returns {string}
  10295. */
  10296. getEditCustomer() {
  10297. return this.editCustomer;
  10298. }
  10299. /**
  10300. * Get Customer_Login.
  10301. * @returns {string}
  10302. */
  10303. getCustomerLogin() {
  10304. return this.customerLogin;
  10305. }
  10306. /**
  10307. * Set Customer_ID.
  10308. * @param {number} customerId
  10309. * @returns {CustomerAddressListLoadQuery}
  10310. */
  10311. setCustomerId(customerId) {
  10312. this.customerId = customerId;
  10313. return this;
  10314. }
  10315. /**
  10316. * Set Edit_Customer.
  10317. * @param {string} editCustomer
  10318. * @returns {CustomerAddressListLoadQuery}
  10319. */
  10320. setEditCustomer(editCustomer) {
  10321. this.editCustomer = editCustomer;
  10322. return this;
  10323. }
  10324. /**
  10325. * Set Customer_Login.
  10326. * @param {string} customerLogin
  10327. * @returns {CustomerAddressListLoadQuery}
  10328. */
  10329. setCustomerLogin(customerLogin) {
  10330. this.customerLogin = customerLogin;
  10331. return this;
  10332. }
  10333. /**
  10334. * Reduce the request to a an object.
  10335. * @override
  10336. * @returns {Object}
  10337. */
  10338. toObject() {
  10339. var data = super.toObject();
  10340. if (!util.isNullOrUndefined(this.customerId)) {
  10341. data['Customer_ID'] = this.customerId;
  10342. } else if (!util.isNullOrUndefined(this.editCustomer)) {
  10343. data['Edit_Customer'] = this.editCustomer;
  10344. } else if (!util.isNullOrUndefined(this.customerLogin)) {
  10345. data['Customer_Login'] = this.customerLogin;
  10346. }
  10347. return data;
  10348. }
  10349. /**
  10350. * Create a response object from the response data.
  10351. * @override
  10352. * @returns {Response}
  10353. */
  10354. createResponse(data) {
  10355. return new responses.CustomerAddressListLoadQuery(this, data);
  10356. }
  10357. }
  10358. /**
  10359. * Handles API Request PrintQueueList_Load_Query. Scope: Domain.
  10360. * @see https://docs.miva.com/json-api/functions/printqueuelist_load_query
  10361. */
  10362. class PrintQueueListLoadQuery extends ListQueryRequest {
  10363. /**
  10364. * PrintQueueListLoadQuery Constructor.
  10365. * @param {?Client} client
  10366. */
  10367. constructor(client) {
  10368. super(client);
  10369. this.function = 'PrintQueueList_Load_Query';
  10370. this.scope = Request.REQUEST_SCOPE_DOMAIN;
  10371. this.availableSearchFields = [
  10372. 'descrip'
  10373. ];
  10374. this.availableSortFields = [
  10375. 'descrip'
  10376. ];
  10377. }
  10378. /**
  10379. * Create a response object from the response data.
  10380. * @override
  10381. * @returns {Response}
  10382. */
  10383. createResponse(data) {
  10384. return new responses.PrintQueueListLoadQuery(this, data);
  10385. }
  10386. }
  10387. /**
  10388. * Handles API Request PrintQueueJobList_Load_Query. Scope: Domain.
  10389. * @see https://docs.miva.com/json-api/functions/printqueuejoblist_load_query
  10390. */
  10391. class PrintQueueJobListLoadQuery extends ListQueryRequest {
  10392. /**
  10393. * PrintQueueJobListLoadQuery Constructor.
  10394. * @param {?Client} client
  10395. * @param {?PrintQueue} printQueue
  10396. */
  10397. constructor(client, printQueue = null) {
  10398. super(client);
  10399. this.function = 'PrintQueueJobList_Load_Query';
  10400. this.scope = Request.REQUEST_SCOPE_DOMAIN;
  10401. this.availableSearchFields = [
  10402. 'id',
  10403. 'queue_id',
  10404. 'store_id',
  10405. 'user_id',
  10406. 'descrip',
  10407. 'job_fmt',
  10408. 'job_data',
  10409. 'dt_created'
  10410. ];
  10411. this.availableSortFields = [
  10412. 'id',
  10413. 'queue_id',
  10414. 'store_id',
  10415. 'user_id',
  10416. 'descrip',
  10417. 'job_fmt',
  10418. 'job_data',
  10419. 'dt_created'
  10420. ];
  10421. this.availableOnDemandColumns = [
  10422. 'job_data'
  10423. ];
  10424. this.printQueueId = null;
  10425. this.editPrintQueue = null;
  10426. this.printQueueDescription = null;
  10427. if (util.isInstanceOf(printQueue, models.PrintQueue)) {
  10428. if (printQueue.getId()) {
  10429. this.setPrintQueueId(printQueue.getId());
  10430. } else if (printQueue.getDescription()) {
  10431. this.setEditPrintQueue(printQueue.getDescription());
  10432. }
  10433. }
  10434. }
  10435. /**
  10436. * Get PrintQueue_ID.
  10437. * @returns {number}
  10438. */
  10439. getPrintQueueId() {
  10440. return this.printQueueId;
  10441. }
  10442. /**
  10443. * Get Edit_PrintQueue.
  10444. * @returns {string}
  10445. */
  10446. getEditPrintQueue() {
  10447. return this.editPrintQueue;
  10448. }
  10449. /**
  10450. * Get PrintQueue_Description.
  10451. * @returns {string}
  10452. */
  10453. getPrintQueueDescription() {
  10454. return this.printQueueDescription;
  10455. }
  10456. /**
  10457. * Set PrintQueue_ID.
  10458. * @param {number} printQueueId
  10459. * @returns {PrintQueueJobListLoadQuery}
  10460. */
  10461. setPrintQueueId(printQueueId) {
  10462. this.printQueueId = printQueueId;
  10463. return this;
  10464. }
  10465. /**
  10466. * Set Edit_PrintQueue.
  10467. * @param {string} editPrintQueue
  10468. * @returns {PrintQueueJobListLoadQuery}
  10469. */
  10470. setEditPrintQueue(editPrintQueue) {
  10471. this.editPrintQueue = editPrintQueue;
  10472. return this;
  10473. }
  10474. /**
  10475. * Set PrintQueue_Description.
  10476. * @param {string} printQueueDescription
  10477. * @returns {PrintQueueJobListLoadQuery}
  10478. */
  10479. setPrintQueueDescription(printQueueDescription) {
  10480. this.printQueueDescription = printQueueDescription;
  10481. return this;
  10482. }
  10483. /**
  10484. * Reduce the request to a an object.
  10485. * @override
  10486. * @returns {Object}
  10487. */
  10488. toObject() {
  10489. var data = super.toObject();
  10490. if (!util.isNullOrUndefined(this.printQueueId)) {
  10491. data['PrintQueue_ID'] = this.printQueueId;
  10492. } else if (!util.isNullOrUndefined(this.editPrintQueue)) {
  10493. data['Edit_PrintQueue'] = this.editPrintQueue;
  10494. } else if (!util.isNullOrUndefined(this.printQueueDescription)) {
  10495. data['PrintQueue_Description'] = this.printQueueDescription;
  10496. }
  10497. return data;
  10498. }
  10499. /**
  10500. * Create a response object from the response data.
  10501. * @override
  10502. * @returns {Response}
  10503. */
  10504. createResponse(data) {
  10505. return new responses.PrintQueueJobListLoadQuery(this, data);
  10506. }
  10507. }
  10508. /**
  10509. * Handles API Request PrintQueueJob_Delete. Scope: Store.
  10510. * @see https://docs.miva.com/json-api/functions/printqueuejob_delete
  10511. */
  10512. class PrintQueueJobDelete extends Request {
  10513. /**
  10514. * PrintQueueJobDelete Constructor.
  10515. * @param {?Client} client
  10516. * @param {?PrintQueueJob} printQueueJob
  10517. */
  10518. constructor(client, printQueueJob = null) {
  10519. super(client);
  10520. this.function = 'PrintQueueJob_Delete';
  10521. this.scope = Request.REQUEST_SCOPE_STORE;
  10522. this.printQueueJobId = null;
  10523. if (util.isInstanceOf(printQueueJob, models.PrintQueueJob)) {
  10524. if (printQueueJob.getId()) {
  10525. this.setPrintQueueJobId(printQueueJob.getId());
  10526. }
  10527. }
  10528. }
  10529. /**
  10530. * Get PrintQueueJob_ID.
  10531. * @returns {number}
  10532. */
  10533. getPrintQueueJobId() {
  10534. return this.printQueueJobId;
  10535. }
  10536. /**
  10537. * Set PrintQueueJob_ID.
  10538. * @param {number} printQueueJobId
  10539. * @returns {PrintQueueJobDelete}
  10540. */
  10541. setPrintQueueJobId(printQueueJobId) {
  10542. this.printQueueJobId = printQueueJobId;
  10543. return this;
  10544. }
  10545. /**
  10546. * Reduce the request to a an object.
  10547. * @override
  10548. * @returns {Object}
  10549. */
  10550. toObject() {
  10551. var data = super.toObject();
  10552. if (!util.isNullOrUndefined(this.printQueueJobId)) {
  10553. data['PrintQueueJob_ID'] = this.printQueueJobId;
  10554. }
  10555. return data;
  10556. }
  10557. /**
  10558. * Create a response object from the response data.
  10559. * @override
  10560. * @returns {Response}
  10561. */
  10562. createResponse(data) {
  10563. return new responses.PrintQueueJobDelete(this, data);
  10564. }
  10565. }
  10566. /**
  10567. * Handles API Request PrintQueueJob_Insert. Scope: Store.
  10568. * @see https://docs.miva.com/json-api/functions/printqueuejob_insert
  10569. */
  10570. class PrintQueueJobInsert extends Request {
  10571. /**
  10572. * PrintQueueJobInsert Constructor.
  10573. * @param {?Client} client
  10574. * @param {?PrintQueue} printQueue
  10575. */
  10576. constructor(client, printQueue = null) {
  10577. super(client);
  10578. this.function = 'PrintQueueJob_Insert';
  10579. this.scope = Request.REQUEST_SCOPE_STORE;
  10580. this.printQueueId = null;
  10581. this.editPrintQueue = null;
  10582. this.printQueueDescription = null;
  10583. this.printQueueJobDescription = null;
  10584. this.printQueueJobFormat = null;
  10585. this.printQueueJobData = null;
  10586. if (util.isInstanceOf(printQueue, models.PrintQueue)) {
  10587. if (printQueue.getId()) {
  10588. this.setPrintQueueId(printQueue.getId());
  10589. } else if (printQueue.getDescription()) {
  10590. this.setEditPrintQueue(printQueue.getDescription());
  10591. }
  10592. }
  10593. }
  10594. /**
  10595. * Get PrintQueue_ID.
  10596. * @returns {number}
  10597. */
  10598. getPrintQueueId() {
  10599. return this.printQueueId;
  10600. }
  10601. /**
  10602. * Get Edit_PrintQueue.
  10603. * @returns {string}
  10604. */
  10605. getEditPrintQueue() {
  10606. return this.editPrintQueue;
  10607. }
  10608. /**
  10609. * Get PrintQueue_Description.
  10610. * @returns {string}
  10611. */
  10612. getPrintQueueDescription() {
  10613. return this.printQueueDescription;
  10614. }
  10615. /**
  10616. * Get PrintQueueJob_Description.
  10617. * @returns {string}
  10618. */
  10619. getPrintQueueJobDescription() {
  10620. return this.printQueueJobDescription;
  10621. }
  10622. /**
  10623. * Get PrintQueueJob_Format.
  10624. * @returns {string}
  10625. */
  10626. getPrintQueueJobFormat() {
  10627. return this.printQueueJobFormat;
  10628. }
  10629. /**
  10630. * Get PrintQueueJob_Data.
  10631. * @returns {string}
  10632. */
  10633. getPrintQueueJobData() {
  10634. return this.printQueueJobData;
  10635. }
  10636. /**
  10637. * Set PrintQueue_ID.
  10638. * @param {number} printQueueId
  10639. * @returns {PrintQueueJobInsert}
  10640. */
  10641. setPrintQueueId(printQueueId) {
  10642. this.printQueueId = printQueueId;
  10643. return this;
  10644. }
  10645. /**
  10646. * Set Edit_PrintQueue.
  10647. * @param {string} editPrintQueue
  10648. * @returns {PrintQueueJobInsert}
  10649. */
  10650. setEditPrintQueue(editPrintQueue) {
  10651. this.editPrintQueue = editPrintQueue;
  10652. return this;
  10653. }
  10654. /**
  10655. * Set PrintQueue_Description.
  10656. * @param {string} printQueueDescription
  10657. * @returns {PrintQueueJobInsert}
  10658. */
  10659. setPrintQueueDescription(printQueueDescription) {
  10660. this.printQueueDescription = printQueueDescription;
  10661. return this;
  10662. }
  10663. /**
  10664. * Set PrintQueueJob_Description.
  10665. * @param {string} printQueueJobDescription
  10666. * @returns {PrintQueueJobInsert}
  10667. */
  10668. setPrintQueueJobDescription(printQueueJobDescription) {
  10669. this.printQueueJobDescription = printQueueJobDescription;
  10670. return this;
  10671. }
  10672. /**
  10673. * Set PrintQueueJob_Format.
  10674. * @param {string} printQueueJobFormat
  10675. * @returns {PrintQueueJobInsert}
  10676. */
  10677. setPrintQueueJobFormat(printQueueJobFormat) {
  10678. this.printQueueJobFormat = printQueueJobFormat;
  10679. return this;
  10680. }
  10681. /**
  10682. * Set PrintQueueJob_Data.
  10683. * @param {string} printQueueJobData
  10684. * @returns {PrintQueueJobInsert}
  10685. */
  10686. setPrintQueueJobData(printQueueJobData) {
  10687. this.printQueueJobData = printQueueJobData;
  10688. return this;
  10689. }
  10690. /**
  10691. * Reduce the request to a an object.
  10692. * @override
  10693. * @returns {Object}
  10694. */
  10695. toObject() {
  10696. var data = super.toObject();
  10697. if (!util.isNullOrUndefined(this.printQueueId)) {
  10698. data['PrintQueue_ID'] = this.printQueueId;
  10699. } else if (!util.isNullOrUndefined(this.editPrintQueue)) {
  10700. data['Edit_PrintQueue'] = this.editPrintQueue;
  10701. } else if (!util.isNullOrUndefined(this.printQueueDescription)) {
  10702. data['PrintQueue_Description'] = this.printQueueDescription;
  10703. }
  10704. if (!util.isNullOrUndefined(this.printQueueJobDescription)) {
  10705. data['PrintQueueJob_Description'] = this.printQueueJobDescription;
  10706. }
  10707. if (!util.isNullOrUndefined(this.printQueueJobFormat)) {
  10708. data['PrintQueueJob_Format'] = this.printQueueJobFormat;
  10709. }
  10710. if (!util.isNullOrUndefined(this.printQueueJobData)) {
  10711. data['PrintQueueJob_Data'] = this.printQueueJobData;
  10712. }
  10713. return data;
  10714. }
  10715. /**
  10716. * Create a response object from the response data.
  10717. * @override
  10718. * @returns {Response}
  10719. */
  10720. createResponse(data) {
  10721. return new responses.PrintQueueJobInsert(this, data);
  10722. }
  10723. }
  10724. /**
  10725. * Handles API Request PrintQueueJob_Status. Scope: Store.
  10726. * @see https://docs.miva.com/json-api/functions/printqueuejob_status
  10727. */
  10728. class PrintQueueJobStatus extends Request {
  10729. /**
  10730. * PrintQueueJobStatus Constructor.
  10731. * @param {?Client} client
  10732. * @param {?PrintQueueJob} printQueueJob
  10733. */
  10734. constructor(client, printQueueJob = null) {
  10735. super(client);
  10736. this.function = 'PrintQueueJob_Status';
  10737. this.scope = Request.REQUEST_SCOPE_STORE;
  10738. this.printQueueJobId = null;
  10739. if (util.isInstanceOf(printQueueJob, models.PrintQueueJob)) {
  10740. if (printQueueJob.getId()) {
  10741. this.setPrintQueueJobId(printQueueJob.getId());
  10742. }
  10743. }
  10744. }
  10745. /**
  10746. * Get PrintQueueJob_ID.
  10747. * @returns {number}
  10748. */
  10749. getPrintQueueJobId() {
  10750. return this.printQueueJobId;
  10751. }
  10752. /**
  10753. * Set PrintQueueJob_ID.
  10754. * @param {number} printQueueJobId
  10755. * @returns {PrintQueueJobStatus}
  10756. */
  10757. setPrintQueueJobId(printQueueJobId) {
  10758. this.printQueueJobId = printQueueJobId;
  10759. return this;
  10760. }
  10761. /**
  10762. * Reduce the request to a an object.
  10763. * @override
  10764. * @returns {Object}
  10765. */
  10766. toObject() {
  10767. var data = super.toObject();
  10768. if (!util.isNullOrUndefined(this.printQueueJobId)) {
  10769. data['PrintQueueJob_ID'] = this.printQueueJobId;
  10770. }
  10771. return data;
  10772. }
  10773. /**
  10774. * Create a response object from the response data.
  10775. * @override
  10776. * @returns {Response}
  10777. */
  10778. createResponse(data) {
  10779. return new responses.PrintQueueJobStatus(this, data);
  10780. }
  10781. }
  10782. /**
  10783. * Handles API Request PaymentMethodList_Load. Scope: Store.
  10784. * @see https://docs.miva.com/json-api/functions/paymentmethodlist_load
  10785. */
  10786. class PaymentMethodListLoad extends Request {
  10787. /**
  10788. * PaymentMethodListLoad Constructor.
  10789. * @param {?Client} client
  10790. * @param {?Order} order
  10791. */
  10792. constructor(client, order = null) {
  10793. super(client);
  10794. this.function = 'PaymentMethodList_Load';
  10795. this.scope = Request.REQUEST_SCOPE_STORE;
  10796. this.orderId = null;
  10797. if (util.isInstanceOf(order, models.Order)) {
  10798. this.setOrderId(order.getId());
  10799. }
  10800. }
  10801. /**
  10802. * Get Order_ID.
  10803. * @returns {number}
  10804. */
  10805. getOrderId() {
  10806. return this.orderId;
  10807. }
  10808. /**
  10809. * Set Order_ID.
  10810. * @param {number} orderId
  10811. * @returns {PaymentMethodListLoad}
  10812. */
  10813. setOrderId(orderId) {
  10814. this.orderId = orderId;
  10815. return this;
  10816. }
  10817. /**
  10818. * Reduce the request to a an object.
  10819. * @override
  10820. * @returns {Object}
  10821. */
  10822. toObject() {
  10823. var data = super.toObject();
  10824. if (!util.isNullOrUndefined(this.orderId)) {
  10825. data['Order_ID'] = this.orderId;
  10826. }
  10827. return data;
  10828. }
  10829. /**
  10830. * Create a response object from the response data.
  10831. * @override
  10832. * @returns {Response}
  10833. */
  10834. createResponse(data) {
  10835. return new responses.PaymentMethodListLoad(this, data);
  10836. }
  10837. }
  10838. /**
  10839. * Handles API Request Order_Create_FromOrder. Scope: Store.
  10840. * @see https://docs.miva.com/json-api/functions/order_create_fromorder
  10841. */
  10842. class OrderCreateFromOrder extends Request {
  10843. /**
  10844. * OrderCreateFromOrder Constructor.
  10845. * @param {?Client} client
  10846. * @param {?Order} order
  10847. */
  10848. constructor(client, order = null) {
  10849. super(client);
  10850. this.function = 'Order_Create_FromOrder';
  10851. this.scope = Request.REQUEST_SCOPE_STORE;
  10852. this.orderId = null;
  10853. if (util.isInstanceOf(order, models.Order)) {
  10854. if (order.getId()) {
  10855. this.setOrderId(order.getId());
  10856. }
  10857. }
  10858. }
  10859. /**
  10860. * Get Order_ID.
  10861. * @returns {number}
  10862. */
  10863. getOrderId() {
  10864. return this.orderId;
  10865. }
  10866. /**
  10867. * Set Order_ID.
  10868. * @param {number} orderId
  10869. * @returns {OrderCreateFromOrder}
  10870. */
  10871. setOrderId(orderId) {
  10872. this.orderId = orderId;
  10873. return this;
  10874. }
  10875. /**
  10876. * Reduce the request to a an object.
  10877. * @override
  10878. * @returns {Object}
  10879. */
  10880. toObject() {
  10881. var data = super.toObject();
  10882. if (!util.isNullOrUndefined(this.orderId)) {
  10883. data['Order_ID'] = this.orderId;
  10884. }
  10885. return data;
  10886. }
  10887. /**
  10888. * Create a response object from the response data.
  10889. * @override
  10890. * @returns {Response}
  10891. */
  10892. createResponse(data) {
  10893. return new responses.OrderCreateFromOrder(this, data);
  10894. }
  10895. }
  10896. /**
  10897. * Handles API Request Order_Authorize. Scope: Store.
  10898. * @see https://docs.miva.com/json-api/functions/order_authorize
  10899. */
  10900. class OrderAuthorize extends Request {
  10901. /**
  10902. * OrderAuthorize Constructor.
  10903. * @param {?Client} client
  10904. * @param {?Order} order
  10905. */
  10906. constructor(client, order = null) {
  10907. super(client);
  10908. this.function = 'Order_Authorize';
  10909. this.scope = Request.REQUEST_SCOPE_STORE;
  10910. this.orderId = null;
  10911. this.moduleId = null;
  10912. this.moduleData = null;
  10913. this.amount = null;
  10914. this.moduleFields = {};
  10915. if (util.isInstanceOf(order, models.Order)) {
  10916. if (order.getId()) {
  10917. this.setOrderId(order.getId());
  10918. }
  10919. }
  10920. }
  10921. /**
  10922. * Get Order_ID.
  10923. * @returns {number}
  10924. */
  10925. getOrderId() {
  10926. return this.orderId;
  10927. }
  10928. /**
  10929. * Get Module_ID.
  10930. * @returns {number}
  10931. */
  10932. getModuleId() {
  10933. return this.moduleId;
  10934. }
  10935. /**
  10936. * Get Module_Data.
  10937. * @returns {string}
  10938. */
  10939. getModuleData() {
  10940. return this.moduleData;
  10941. }
  10942. /**
  10943. * Get Amount.
  10944. * @returns {number}
  10945. */
  10946. getAmount() {
  10947. return this.amount;
  10948. }
  10949. /**
  10950. * Get Module_Fields.
  10951. * @returns {Object}
  10952. */
  10953. getModuleFields() {
  10954. return this.moduleFields;
  10955. }
  10956. /**
  10957. * Set Order_ID.
  10958. * @param {number} orderId
  10959. * @returns {OrderAuthorize}
  10960. */
  10961. setOrderId(orderId) {
  10962. this.orderId = orderId;
  10963. return this;
  10964. }
  10965. /**
  10966. * Set Module_ID.
  10967. * @param {number} moduleId
  10968. * @returns {OrderAuthorize}
  10969. */
  10970. setModuleId(moduleId) {
  10971. this.moduleId = moduleId;
  10972. return this;
  10973. }
  10974. /**
  10975. * Set Module_Data.
  10976. * @param {string} moduleData
  10977. * @returns {OrderAuthorize}
  10978. */
  10979. setModuleData(moduleData) {
  10980. this.moduleData = moduleData;
  10981. return this;
  10982. }
  10983. /**
  10984. * Set Amount.
  10985. * @param {number} amount
  10986. * @returns {OrderAuthorize}
  10987. */
  10988. setAmount(amount) {
  10989. this.amount = amount;
  10990. return this;
  10991. }
  10992. /**
  10993. * Set Module_Fields.
  10994. * @param {Object} moduleFields
  10995. * @returns {OrderAuthorize}
  10996. */
  10997. setModuleFields(moduleFields) {
  10998. this.moduleFields = moduleFields;
  10999. return this;
  11000. }
  11001. /**
  11002. * Add custom data to the request.
  11003. *
  11004. * @param {string}
  11005. * @param {*}
  11006. * @returns {OrderAuthorize}
  11007. */
  11008. setModuleField(field, value)
  11009. {
  11010. this.moduleFields[field] = value;
  11011. return this;
  11012. }
  11013. /**
  11014. * Reduce the request to a an object.
  11015. * @override
  11016. * @returns {Object}
  11017. */
  11018. toObject() {
  11019. var data = Object.assign(super.toObject(), this.getModuleFields());
  11020. if (!util.isNullOrUndefined(this.orderId)) {
  11021. data['Order_ID'] = this.orderId;
  11022. }
  11023. if (!util.isNullOrUndefined(this.moduleId)) {
  11024. data['Module_ID'] = this.moduleId;
  11025. }
  11026. if (!util.isNullOrUndefined(this.moduleData)) {
  11027. data['Module_Data'] = this.moduleData;
  11028. }
  11029. data['Amount'] = this.amount;
  11030. return data;
  11031. }
  11032. /**
  11033. * Create a response object from the response data.
  11034. * @override
  11035. * @returns {Response}
  11036. */
  11037. createResponse(data) {
  11038. return new responses.OrderAuthorize(this, data);
  11039. }
  11040. }
  11041. /**
  11042. * Handles API Request CustomerPaymentCardList_Load_Query. Scope: Store.
  11043. * @see https://docs.miva.com/json-api/functions/customerpaymentcardlist_load_query
  11044. */
  11045. class CustomerPaymentCardListLoadQuery extends ListQueryRequest {
  11046. /**
  11047. * CustomerPaymentCardListLoadQuery Constructor.
  11048. * @param {?Client} client
  11049. * @param {?Customer} customer
  11050. */
  11051. constructor(client, customer = null) {
  11052. super(client);
  11053. this.function = 'CustomerPaymentCardList_Load_Query';
  11054. this.scope = Request.REQUEST_SCOPE_STORE;
  11055. this.availableSearchFields = [
  11056. 'fname',
  11057. 'lname',
  11058. 'exp_month',
  11059. 'exp_year',
  11060. 'lastfour',
  11061. 'lastused',
  11062. 'type',
  11063. 'addr1',
  11064. 'addr2',
  11065. 'city',
  11066. 'state',
  11067. 'zip',
  11068. 'cntry',
  11069. 'refcount',
  11070. 'mod_code',
  11071. 'meth_code',
  11072. 'id'
  11073. ];
  11074. this.availableSortFields = [
  11075. 'fname',
  11076. 'lname',
  11077. 'expires',
  11078. 'lastfour',
  11079. 'lastused',
  11080. 'type',
  11081. 'addr1',
  11082. 'addr2',
  11083. 'city',
  11084. 'state',
  11085. 'zip',
  11086. 'cntry',
  11087. 'refcount',
  11088. 'mod_code',
  11089. 'meth_code',
  11090. 'id'
  11091. ];
  11092. this.customerId = null;
  11093. this.editCustomer = null;
  11094. this.customerLogin = null;
  11095. if (util.isInstanceOf(customer, models.Customer)) {
  11096. if (customer.getId()) {
  11097. this.setCustomerId(customer.getId());
  11098. } else if (customer.getLogin()) {
  11099. this.setCustomerLogin(customer.getLogin());
  11100. }
  11101. }
  11102. }
  11103. /**
  11104. * Get Customer_ID.
  11105. * @returns {number}
  11106. */
  11107. getCustomerId() {
  11108. return this.customerId;
  11109. }
  11110. /**
  11111. * Get Edit_Customer.
  11112. * @returns {string}
  11113. */
  11114. getEditCustomer() {
  11115. return this.editCustomer;
  11116. }
  11117. /**
  11118. * Get Customer_Login.
  11119. * @returns {string}
  11120. */
  11121. getCustomerLogin() {
  11122. return this.customerLogin;
  11123. }
  11124. /**
  11125. * Set Customer_ID.
  11126. * @param {number} customerId
  11127. * @returns {CustomerPaymentCardListLoadQuery}
  11128. */
  11129. setCustomerId(customerId) {
  11130. this.customerId = customerId;
  11131. return this;
  11132. }
  11133. /**
  11134. * Set Edit_Customer.
  11135. * @param {string} editCustomer
  11136. * @returns {CustomerPaymentCardListLoadQuery}
  11137. */
  11138. setEditCustomer(editCustomer) {
  11139. this.editCustomer = editCustomer;
  11140. return this;
  11141. }
  11142. /**
  11143. * Set Customer_Login.
  11144. * @param {string} customerLogin
  11145. * @returns {CustomerPaymentCardListLoadQuery}
  11146. */
  11147. setCustomerLogin(customerLogin) {
  11148. this.customerLogin = customerLogin;
  11149. return this;
  11150. }
  11151. /**
  11152. * Reduce the request to a an object.
  11153. * @override
  11154. * @returns {Object}
  11155. */
  11156. toObject() {
  11157. var data = super.toObject();
  11158. if (!util.isNullOrUndefined(this.customerId)) {
  11159. data['Customer_ID'] = this.customerId;
  11160. } else if (!util.isNullOrUndefined(this.editCustomer)) {
  11161. data['Edit_Customer'] = this.editCustomer;
  11162. } else if (!util.isNullOrUndefined(this.customerLogin)) {
  11163. data['Customer_Login'] = this.customerLogin;
  11164. }
  11165. return data;
  11166. }
  11167. /**
  11168. * Create a response object from the response data.
  11169. * @override
  11170. * @returns {Response}
  11171. */
  11172. createResponse(data) {
  11173. return new responses.CustomerPaymentCardListLoadQuery(this, data);
  11174. }
  11175. }
  11176. /**
  11177. * Handles API Request CategoryProductList_Load_Query. Scope: Store.
  11178. * @see https://docs.miva.com/json-api/functions/categoryproductlist_load_query
  11179. */
  11180. class CategoryProductListLoadQuery extends ProductListLoadQuery {
  11181. /**
  11182. * CategoryProductListLoadQuery Constructor.
  11183. * @param {?Client} client
  11184. * @param {?Category} category
  11185. */
  11186. constructor(client, category = null) {
  11187. super(client);
  11188. this.function = 'CategoryProductList_Load_Query';
  11189. this.scope = Request.REQUEST_SCOPE_STORE;
  11190. this.categoryId = null;
  11191. this.categoryCode = null;
  11192. this.editCategory = null;
  11193. this.assigned = null;
  11194. this.unassigned = null;
  11195. if (util.isInstanceOf(category, models.Category)) {
  11196. if (category.getId()) {
  11197. this.setCategoryId(category.getId());
  11198. } else if (category.getCode()) {
  11199. this.setEditCategory(category.getCode());
  11200. }
  11201. }
  11202. }
  11203. /**
  11204. * Get Category_ID.
  11205. * @returns {number}
  11206. */
  11207. getCategoryId() {
  11208. return this.categoryId;
  11209. }
  11210. /**
  11211. * Get Category_Code.
  11212. * @returns {string}
  11213. */
  11214. getCategoryCode() {
  11215. return this.categoryCode;
  11216. }
  11217. /**
  11218. * Get Edit_Category.
  11219. * @returns {string}
  11220. */
  11221. getEditCategory() {
  11222. return this.editCategory;
  11223. }
  11224. /**
  11225. * Get Assigned.
  11226. * @returns {boolean}
  11227. */
  11228. getAssigned() {
  11229. return this.assigned;
  11230. }
  11231. /**
  11232. * Get Unassigned.
  11233. * @returns {boolean}
  11234. */
  11235. getUnassigned() {
  11236. return this.unassigned;
  11237. }
  11238. /**
  11239. * Set Category_ID.
  11240. * @param {number} categoryId
  11241. * @returns {CategoryProductListLoadQuery}
  11242. */
  11243. setCategoryId(categoryId) {
  11244. this.categoryId = categoryId;
  11245. return this;
  11246. }
  11247. /**
  11248. * Set Category_Code.
  11249. * @param {string} categoryCode
  11250. * @returns {CategoryProductListLoadQuery}
  11251. */
  11252. setCategoryCode(categoryCode) {
  11253. this.categoryCode = categoryCode;
  11254. return this;
  11255. }
  11256. /**
  11257. * Set Edit_Category.
  11258. * @param {string} editCategory
  11259. * @returns {CategoryProductListLoadQuery}
  11260. */
  11261. setEditCategory(editCategory) {
  11262. this.editCategory = editCategory;
  11263. return this;
  11264. }
  11265. /**
  11266. * Set Assigned.
  11267. * @param {boolean} assigned
  11268. * @returns {CategoryProductListLoadQuery}
  11269. */
  11270. setAssigned(assigned) {
  11271. this.assigned = assigned;
  11272. return this;
  11273. }
  11274. /**
  11275. * Set Unassigned.
  11276. * @param {boolean} unassigned
  11277. * @returns {CategoryProductListLoadQuery}
  11278. */
  11279. setUnassigned(unassigned) {
  11280. this.unassigned = unassigned;
  11281. return this;
  11282. }
  11283. /**
  11284. * Reduce the request to a an object.
  11285. * @override
  11286. * @returns {Object}
  11287. */
  11288. toObject() {
  11289. var data = super.toObject();
  11290. if (!util.isNullOrUndefined(this.categoryId)) {
  11291. data['Category_ID'] = this.categoryId;
  11292. } else if (!util.isNullOrUndefined(this.editCategory)) {
  11293. data['Edit_Category'] = this.editCategory;
  11294. } else if (!util.isNullOrUndefined(this.categoryCode)) {
  11295. data['Category_Code'] = this.categoryCode;
  11296. }
  11297. if (!util.isNullOrUndefined(this.assigned)) {
  11298. data['Assigned'] = this.assigned;
  11299. }
  11300. if (!util.isNullOrUndefined(this.unassigned)) {
  11301. data['Unassigned'] = this.unassigned;
  11302. }
  11303. return data;
  11304. }
  11305. /**
  11306. * Create a response object from the response data.
  11307. * @override
  11308. * @returns {Response}
  11309. */
  11310. createResponse(data) {
  11311. return new responses.CategoryProductListLoadQuery(this, data);
  11312. }
  11313. }
  11314. /**
  11315. * Handles API Request CouponPriceGroupList_Load_Query. Scope: Store.
  11316. * @see https://docs.miva.com/json-api/functions/couponpricegrouplist_load_query
  11317. */
  11318. class CouponPriceGroupListLoadQuery extends PriceGroupListLoadQuery {
  11319. /**
  11320. * CouponPriceGroupListLoadQuery Constructor.
  11321. * @param {?Client} client
  11322. * @param {?Coupon} coupon
  11323. */
  11324. constructor(client, coupon = null) {
  11325. super(client);
  11326. this.function = 'CouponPriceGroupList_Load_Query';
  11327. this.scope = Request.REQUEST_SCOPE_STORE;
  11328. this.couponId = null;
  11329. this.editCoupon = null;
  11330. this.couponCode = null;
  11331. this.assigned = null;
  11332. this.unassigned = null;
  11333. if (util.isInstanceOf(coupon, models.Coupon)) {
  11334. if (coupon.getId()) {
  11335. this.setCouponId(coupon.getId());
  11336. } else if (coupon.getCode()) {
  11337. this.setEditCoupon(coupon.getCode());
  11338. }
  11339. }
  11340. }
  11341. /**
  11342. * Get Coupon_ID.
  11343. * @returns {number}
  11344. */
  11345. getCouponId() {
  11346. return this.couponId;
  11347. }
  11348. /**
  11349. * Get Edit_Coupon.
  11350. * @returns {string}
  11351. */
  11352. getEditCoupon() {
  11353. return this.editCoupon;
  11354. }
  11355. /**
  11356. * Get Coupon_Code.
  11357. * @returns {string}
  11358. */
  11359. getCouponCode() {
  11360. return this.couponCode;
  11361. }
  11362. /**
  11363. * Get Assigned.
  11364. * @returns {boolean}
  11365. */
  11366. getAssigned() {
  11367. return this.assigned;
  11368. }
  11369. /**
  11370. * Get Unassigned.
  11371. * @returns {boolean}
  11372. */
  11373. getUnassigned() {
  11374. return this.unassigned;
  11375. }
  11376. /**
  11377. * Set Coupon_ID.
  11378. * @param {number} couponId
  11379. * @returns {CouponPriceGroupListLoadQuery}
  11380. */
  11381. setCouponId(couponId) {
  11382. this.couponId = couponId;
  11383. return this;
  11384. }
  11385. /**
  11386. * Set Edit_Coupon.
  11387. * @param {string} editCoupon
  11388. * @returns {CouponPriceGroupListLoadQuery}
  11389. */
  11390. setEditCoupon(editCoupon) {
  11391. this.editCoupon = editCoupon;
  11392. return this;
  11393. }
  11394. /**
  11395. * Set Coupon_Code.
  11396. * @param {string} couponCode
  11397. * @returns {CouponPriceGroupListLoadQuery}
  11398. */
  11399. setCouponCode(couponCode) {
  11400. this.couponCode = couponCode;
  11401. return this;
  11402. }
  11403. /**
  11404. * Set Assigned.
  11405. * @param {boolean} assigned
  11406. * @returns {CouponPriceGroupListLoadQuery}
  11407. */
  11408. setAssigned(assigned) {
  11409. this.assigned = assigned;
  11410. return this;
  11411. }
  11412. /**
  11413. * Set Unassigned.
  11414. * @param {boolean} unassigned
  11415. * @returns {CouponPriceGroupListLoadQuery}
  11416. */
  11417. setUnassigned(unassigned) {
  11418. this.unassigned = unassigned;
  11419. return this;
  11420. }
  11421. /**
  11422. * Reduce the request to a an object.
  11423. * @override
  11424. * @returns {Object}
  11425. */
  11426. toObject() {
  11427. var data = super.toObject();
  11428. if (!util.isNullOrUndefined(this.couponId)) {
  11429. data['Coupon_ID'] = this.couponId;
  11430. } else if (!util.isNullOrUndefined(this.editCoupon)) {
  11431. data['Edit_Coupon'] = this.editCoupon;
  11432. } else if (!util.isNullOrUndefined(this.couponCode)) {
  11433. data['Coupon_Code'] = this.couponCode;
  11434. }
  11435. if (!util.isNullOrUndefined(this.assigned)) {
  11436. data['Assigned'] = this.assigned;
  11437. }
  11438. if (!util.isNullOrUndefined(this.unassigned)) {
  11439. data['Unassigned'] = this.unassigned;
  11440. }
  11441. return data;
  11442. }
  11443. /**
  11444. * Create a response object from the response data.
  11445. * @override
  11446. * @returns {Response}
  11447. */
  11448. createResponse(data) {
  11449. return new responses.CouponPriceGroupListLoadQuery(this, data);
  11450. }
  11451. }
  11452. /**
  11453. * Handles API Request PriceGroupCustomerList_Load_Query. Scope: Store.
  11454. * @see https://docs.miva.com/json-api/functions/pricegroupcustomerlist_load_query
  11455. */
  11456. class PriceGroupCustomerListLoadQuery extends CustomerListLoadQuery {
  11457. /**
  11458. * PriceGroupCustomerListLoadQuery Constructor.
  11459. * @param {?Client} client
  11460. * @param {?PriceGroup} priceGroup
  11461. */
  11462. constructor(client, priceGroup = null) {
  11463. super(client);
  11464. this.function = 'PriceGroupCustomerList_Load_Query';
  11465. this.scope = Request.REQUEST_SCOPE_STORE;
  11466. this.priceGroupId = null;
  11467. this.priceGroupName = null;
  11468. this.assigned = null;
  11469. this.unassigned = null;
  11470. if (util.isInstanceOf(priceGroup, models.PriceGroup)) {
  11471. if (priceGroup.getId()) {
  11472. this.setPriceGroupId(priceGroup.getId());
  11473. } else if (priceGroup.getName()) {
  11474. this.setPriceGroupName(priceGroup.getName());
  11475. }
  11476. }
  11477. }
  11478. /**
  11479. * Get PriceGroup_ID.
  11480. * @returns {number}
  11481. */
  11482. getPriceGroupId() {
  11483. return this.priceGroupId;
  11484. }
  11485. /**
  11486. * Get PriceGroup_Name.
  11487. * @returns {string}
  11488. */
  11489. getPriceGroupName() {
  11490. return this.priceGroupName;
  11491. }
  11492. /**
  11493. * Get Assigned.
  11494. * @returns {boolean}
  11495. */
  11496. getAssigned() {
  11497. return this.assigned;
  11498. }
  11499. /**
  11500. * Get Unassigned.
  11501. * @returns {boolean}
  11502. */
  11503. getUnassigned() {
  11504. return this.unassigned;
  11505. }
  11506. /**
  11507. * Set PriceGroup_ID.
  11508. * @param {number} priceGroupId
  11509. * @returns {PriceGroupCustomerListLoadQuery}
  11510. */
  11511. setPriceGroupId(priceGroupId) {
  11512. this.priceGroupId = priceGroupId;
  11513. return this;
  11514. }
  11515. /**
  11516. * Set PriceGroup_Name.
  11517. * @param {string} priceGroupName
  11518. * @returns {PriceGroupCustomerListLoadQuery}
  11519. */
  11520. setPriceGroupName(priceGroupName) {
  11521. this.priceGroupName = priceGroupName;
  11522. return this;
  11523. }
  11524. /**
  11525. * Set Assigned.
  11526. * @param {boolean} assigned
  11527. * @returns {PriceGroupCustomerListLoadQuery}
  11528. */
  11529. setAssigned(assigned) {
  11530. this.assigned = assigned;
  11531. return this;
  11532. }
  11533. /**
  11534. * Set Unassigned.
  11535. * @param {boolean} unassigned
  11536. * @returns {PriceGroupCustomerListLoadQuery}
  11537. */
  11538. setUnassigned(unassigned) {
  11539. this.unassigned = unassigned;
  11540. return this;
  11541. }
  11542. /**
  11543. * Reduce the request to a an object.
  11544. * @override
  11545. * @returns {Object}
  11546. */
  11547. toObject() {
  11548. var data = super.toObject();
  11549. if (!util.isNullOrUndefined(this.priceGroupId)) {
  11550. data['PriceGroup_ID'] = this.priceGroupId;
  11551. } else if (!util.isNullOrUndefined(this.priceGroupName)) {
  11552. data['PriceGroup_Name'] = this.priceGroupName;
  11553. }
  11554. if (!util.isNullOrUndefined(this.assigned)) {
  11555. data['Assigned'] = this.assigned;
  11556. }
  11557. if (!util.isNullOrUndefined(this.unassigned)) {
  11558. data['Unassigned'] = this.unassigned;
  11559. }
  11560. return data;
  11561. }
  11562. /**
  11563. * Create a response object from the response data.
  11564. * @override
  11565. * @returns {Response}
  11566. */
  11567. createResponse(data) {
  11568. return new responses.PriceGroupCustomerListLoadQuery(this, data);
  11569. }
  11570. }
  11571. /**
  11572. * Handles API Request PriceGroupProductList_Load_Query. Scope: Store.
  11573. * @see https://docs.miva.com/json-api/functions/pricegroupproductlist_load_query
  11574. */
  11575. class PriceGroupProductListLoadQuery extends ProductListLoadQuery {
  11576. /**
  11577. * PriceGroupProductListLoadQuery Constructor.
  11578. * @param {?Client} client
  11579. * @param {?PriceGroup} priceGroup
  11580. */
  11581. constructor(client, priceGroup = null) {
  11582. super(client);
  11583. this.function = 'PriceGroupProductList_Load_Query';
  11584. this.scope = Request.REQUEST_SCOPE_STORE;
  11585. this.priceGroupId = null;
  11586. this.priceGroupName = null;
  11587. this.assigned = null;
  11588. this.unassigned = null;
  11589. if (util.isInstanceOf(priceGroup, models.PriceGroup)) {
  11590. if (priceGroup.getId()) {
  11591. this.setPriceGroupId(priceGroup.getId());
  11592. } else if (priceGroup.getName()) {
  11593. this.setPriceGroupName(priceGroup.getName());
  11594. }
  11595. }
  11596. }
  11597. /**
  11598. * Get PriceGroup_ID.
  11599. * @returns {number}
  11600. */
  11601. getPriceGroupId() {
  11602. return this.priceGroupId;
  11603. }
  11604. /**
  11605. * Get PriceGroup_Name.
  11606. * @returns {string}
  11607. */
  11608. getPriceGroupName() {
  11609. return this.priceGroupName;
  11610. }
  11611. /**
  11612. * Get Assigned.
  11613. * @returns {boolean}
  11614. */
  11615. getAssigned() {
  11616. return this.assigned;
  11617. }
  11618. /**
  11619. * Get Unassigned.
  11620. * @returns {boolean}
  11621. */
  11622. getUnassigned() {
  11623. return this.unassigned;
  11624. }
  11625. /**
  11626. * Set PriceGroup_ID.
  11627. * @param {number} priceGroupId
  11628. * @returns {PriceGroupProductListLoadQuery}
  11629. */
  11630. setPriceGroupId(priceGroupId) {
  11631. this.priceGroupId = priceGroupId;
  11632. return this;
  11633. }
  11634. /**
  11635. * Set PriceGroup_Name.
  11636. * @param {string} priceGroupName
  11637. * @returns {PriceGroupProductListLoadQuery}
  11638. */
  11639. setPriceGroupName(priceGroupName) {
  11640. this.priceGroupName = priceGroupName;
  11641. return this;
  11642. }
  11643. /**
  11644. * Set Assigned.
  11645. * @param {boolean} assigned
  11646. * @returns {PriceGroupProductListLoadQuery}
  11647. */
  11648. setAssigned(assigned) {
  11649. this.assigned = assigned;
  11650. return this;
  11651. }
  11652. /**
  11653. * Set Unassigned.
  11654. * @param {boolean} unassigned
  11655. * @returns {PriceGroupProductListLoadQuery}
  11656. */
  11657. setUnassigned(unassigned) {
  11658. this.unassigned = unassigned;
  11659. return this;
  11660. }
  11661. /**
  11662. * Reduce the request to a an object.
  11663. * @override
  11664. * @returns {Object}
  11665. */
  11666. toObject() {
  11667. var data = super.toObject();
  11668. if (!util.isNullOrUndefined(this.priceGroupId)) {
  11669. data['PriceGroup_ID'] = this.priceGroupId;
  11670. } else if (!util.isNullOrUndefined(this.priceGroupName)) {
  11671. data['PriceGroup_Name'] = this.priceGroupName;
  11672. }
  11673. if (!util.isNullOrUndefined(this.assigned)) {
  11674. data['Assigned'] = this.assigned;
  11675. }
  11676. if (!util.isNullOrUndefined(this.unassigned)) {
  11677. data['Unassigned'] = this.unassigned;
  11678. }
  11679. return data;
  11680. }
  11681. /**
  11682. * Create a response object from the response data.
  11683. * @override
  11684. * @returns {Response}
  11685. */
  11686. createResponse(data) {
  11687. return new responses.PriceGroupProductListLoadQuery(this, data);
  11688. }
  11689. }
  11690. /**
  11691. * Handles API Request CustomerPriceGroupList_Load_Query. Scope: Store.
  11692. * @see https://docs.miva.com/json-api/functions/customerpricegrouplist_load_query
  11693. */
  11694. class CustomerPriceGroupListLoadQuery extends PriceGroupListLoadQuery {
  11695. /**
  11696. * CustomerPriceGroupListLoadQuery Constructor.
  11697. * @param {?Client} client
  11698. * @param {?Customer} customer
  11699. */
  11700. constructor(client, customer = null) {
  11701. super(client);
  11702. this.function = 'CustomerPriceGroupList_Load_Query';
  11703. this.scope = Request.REQUEST_SCOPE_STORE;
  11704. this.customerId = null;
  11705. this.editCustomer = null;
  11706. this.customerLogin = null;
  11707. this.assigned = null;
  11708. this.unassigned = null;
  11709. if (util.isInstanceOf(customer, models.Customer)) {
  11710. if (customer.getId()) {
  11711. this.setCustomerId(customer.getId());
  11712. } else if (customer.getLogin()) {
  11713. this.setEditCustomer(customer.getLogin());
  11714. }
  11715. }
  11716. }
  11717. /**
  11718. * Get Customer_ID.
  11719. * @returns {number}
  11720. */
  11721. getCustomerId() {
  11722. return this.customerId;
  11723. }
  11724. /**
  11725. * Get Edit_Customer.
  11726. * @returns {string}
  11727. */
  11728. getEditCustomer() {
  11729. return this.editCustomer;
  11730. }
  11731. /**
  11732. * Get Customer_Login.
  11733. * @returns {string}
  11734. */
  11735. getCustomerLogin() {
  11736. return this.customerLogin;
  11737. }
  11738. /**
  11739. * Get Assigned.
  11740. * @returns {boolean}
  11741. */
  11742. getAssigned() {
  11743. return this.assigned;
  11744. }
  11745. /**
  11746. * Get Unassigned.
  11747. * @returns {boolean}
  11748. */
  11749. getUnassigned() {
  11750. return this.unassigned;
  11751. }
  11752. /**
  11753. * Set Customer_ID.
  11754. * @param {number} customerId
  11755. * @returns {CustomerPriceGroupListLoadQuery}
  11756. */
  11757. setCustomerId(customerId) {
  11758. this.customerId = customerId;
  11759. return this;
  11760. }
  11761. /**
  11762. * Set Edit_Customer.
  11763. * @param {string} editCustomer
  11764. * @returns {CustomerPriceGroupListLoadQuery}
  11765. */
  11766. setEditCustomer(editCustomer) {
  11767. this.editCustomer = editCustomer;
  11768. return this;
  11769. }
  11770. /**
  11771. * Set Customer_Login.
  11772. * @param {string} customerLogin
  11773. * @returns {CustomerPriceGroupListLoadQuery}
  11774. */
  11775. setCustomerLogin(customerLogin) {
  11776. this.customerLogin = customerLogin;
  11777. return this;
  11778. }
  11779. /**
  11780. * Set Assigned.
  11781. * @param {boolean} assigned
  11782. * @returns {CustomerPriceGroupListLoadQuery}
  11783. */
  11784. setAssigned(assigned) {
  11785. this.assigned = assigned;
  11786. return this;
  11787. }
  11788. /**
  11789. * Set Unassigned.
  11790. * @param {boolean} unassigned
  11791. * @returns {CustomerPriceGroupListLoadQuery}
  11792. */
  11793. setUnassigned(unassigned) {
  11794. this.unassigned = unassigned;
  11795. return this;
  11796. }
  11797. /**
  11798. * Reduce the request to a an object.
  11799. * @override
  11800. * @returns {Object}
  11801. */
  11802. toObject() {
  11803. var data = super.toObject();
  11804. if (!util.isNullOrUndefined(this.customerId)) {
  11805. data['Customer_ID'] = this.customerId;
  11806. } else if (!util.isNullOrUndefined(this.editCustomer)) {
  11807. data['Edit_Customer'] = this.editCustomer;
  11808. } else if (!util.isNullOrUndefined(this.customerLogin)) {
  11809. data['Customer_Login'] = this.customerLogin;
  11810. }
  11811. if (!util.isNullOrUndefined(this.assigned)) {
  11812. data['Assigned'] = this.assigned;
  11813. }
  11814. if (!util.isNullOrUndefined(this.unassigned)) {
  11815. data['Unassigned'] = this.unassigned;
  11816. }
  11817. return data;
  11818. }
  11819. /**
  11820. * Create a response object from the response data.
  11821. * @override
  11822. * @returns {Response}
  11823. */
  11824. createResponse(data) {
  11825. return new responses.CustomerPriceGroupListLoadQuery(this, data);
  11826. }
  11827. }
  11828. /**
  11829. * This class is a utility to create custom requests.
  11830. */
  11831. class RequestBuilder extends Request
  11832. {
  11833. /**
  11834. * RequestBuilder Constructor.
  11835. * @param {?Client} client
  11836. * @param {string} apiFunction
  11837. * @param {?Object} data
  11838. */
  11839. constructor(client, apiFunction, data = {}) {
  11840. super(client);
  11841. this.setScope(Request.REQUEST_SCOPE_STORE);
  11842. this.setFunction(apiFunction);
  11843. if (util.isObject(data)) {
  11844. this.data = data;
  11845. }
  11846. }
  11847. /**
  11848. * Set the api function name to call.
  11849. * @param {string} apiFunction
  11850. * @returns {RequestBuilder}
  11851. */
  11852. setFunction(apiFunction) {
  11853. this.function = apiFunction;
  11854. return this;
  11855. }
  11856. /**
  11857. * Set the request scope. Use store or domain.
  11858. * @param {string} apiFunction
  11859. * @throws Error
  11860. * @returns {RequestBuilder}
  11861. */
  11862. setScope(scope) {
  11863. if (!util.isString(scope)) {
  11864. throw new Error(util.format('Expected a string but got %s', typeof scope));
  11865. }
  11866. scope = scope.toLowerCase();
  11867. if (scope != Request.REQUEST_SCOPE_DOMAIN && scope != Request.REQUEST_SCOPE_STORE) {
  11868. throw new Error('Invalid Request Scope Value');
  11869. }
  11870. this.scope = scope;
  11871. return this;
  11872. }
  11873. /**
  11874. * Set a field value.
  11875. * @param {string} field
  11876. * @param {*} value
  11877. * @returns {RequestBuilder}
  11878. */
  11879. set(field, value) {
  11880. if (!util.isString(field)) {
  11881. throw new Error(util.format('Expected string but got %s', typeof field));
  11882. }
  11883. var nameLower = field.toLowerCase();
  11884. if (nameLower == 'function') {
  11885. return this.setFunction(value);
  11886. } else if (nameLower == 'store_code') {
  11887. return this.setStoreCode(value);
  11888. }
  11889. this.data[field] = value;
  11890. return this;
  11891. }
  11892. /**
  11893. * Get a defined field value or defaultValue if it does not exist.
  11894. * @param {string} field
  11895. * @param {*} defaultValue
  11896. * @returns {*}
  11897. */
  11898. get(field, defaultValue = null) {
  11899. if (!util.isString(field)) {
  11900. throw new Error(util.format('Expected string but got %s', typeof field));
  11901. }
  11902. var nameLower = field.toLowerCase();
  11903. if (nameLower == 'function') {
  11904. return this.getFunction();
  11905. } else if (nameLower == 'store_code') {
  11906. return this.getStoreCode();
  11907. }
  11908. return field in this.data ?
  11909. this.data[field] : defaultValue;
  11910. }
  11911. /**
  11912. * Check if a field is defined in the request data.
  11913. * @param {string} field
  11914. * @returns {bool}
  11915. */
  11916. has(field) {
  11917. if (!util.isString(field)) {
  11918. throw new Error(util.format('Expected string but got %s', typeof field));
  11919. }
  11920. var nameLower = field.toLowerCase();
  11921. if (nameLower == 'function' || nameLower == 'store_code') {
  11922. return true;
  11923. }
  11924. return field in this.data;
  11925. }
  11926. /**
  11927. * Remove a field from the request data.
  11928. * @param {string} field
  11929. * @returns {RequestBuilder}
  11930. */
  11931. remove(field) {
  11932. if (!util.isString(field)) {
  11933. throw new Error(util.format('Expected string but got %s', typeof field));
  11934. }
  11935. var nameLower = field.toLowerCase();
  11936. if (nameLower == 'function' || nameLower == 'store_code') {
  11937. return this;
  11938. }
  11939. if (field in this.data) {
  11940. delete this.data[field];
  11941. }
  11942. return this;
  11943. }
  11944. /**
  11945. * Reduce the request to a an object.
  11946. * @override
  11947. * @returns {Object}
  11948. */
  11949. toObject() {
  11950. return Object.assign(super.toObject(), this.data);
  11951. }
  11952. /**
  11953. * Create a response object from the response data.
  11954. * @override
  11955. * @returns {Response}
  11956. */
  11957. createResponse(data) {
  11958. return new responses.RequestBuilder(this, data);
  11959. }
  11960. }
  11961. module.exports = {
  11962. RequestBuilder,
  11963. AvailabilityGroupBusinessAccountUpdateAssigned,
  11964. AvailabilityGroupCustomerUpdateAssigned,
  11965. AvailabilityGroupListLoadQuery,
  11966. AvailabilityGroupPaymentMethodUpdateAssigned,
  11967. AvailabilityGroupProductUpdateAssigned,
  11968. AvailabilityGroupShippingMethodUpdateAssigned,
  11969. CategoryListLoadParent,
  11970. CategoryListLoadQuery,
  11971. CategoryProductUpdateAssigned,
  11972. CategoryInsert,
  11973. CategoryDelete,
  11974. CategoryUpdate,
  11975. CouponListDelete,
  11976. CouponListLoadQuery,
  11977. CouponPriceGroupUpdateAssigned,
  11978. CouponInsert,
  11979. CouponUpdate,
  11980. CustomerListLoadQuery,
  11981. CustomerDelete,
  11982. CustomerInsert,
  11983. CustomerUpdate,
  11984. CustomerPaymentCardRegister,
  11985. Module,
  11986. NoteListLoadQuery,
  11987. NoteDelete,
  11988. NoteInsert,
  11989. NoteUpdate,
  11990. OrderCustomFieldListLoad,
  11991. OrderCustomFieldsUpdate,
  11992. OrderItemListBackOrder,
  11993. OrderItemListCancel,
  11994. OrderItemListCreateShipment,
  11995. OrderItemListDelete,
  11996. OrderItemAdd,
  11997. OrderItemUpdate,
  11998. OrderListLoadQuery,
  11999. OrderPaymentCapture,
  12000. OrderPaymentRefund,
  12001. OrderPaymentVoid,
  12002. OrderShipmentListUpdate,
  12003. OrderCreate,
  12004. OrderDelete,
  12005. OrderUpdateCustomerInformation,
  12006. PriceGroupCustomerUpdateAssigned,
  12007. PriceGroupListLoadQuery,
  12008. PriceGroupProductUpdateAssigned,
  12009. ProductImageAdd,
  12010. ProductImageDelete,
  12011. ProductListAdjustInventory,
  12012. ProductListLoadQuery,
  12013. ProductVariantListLoadProduct,
  12014. ProductInsert,
  12015. ProductDelete,
  12016. ProductUpdate,
  12017. ProvisionDomain,
  12018. ProvisionStore,
  12019. CustomerAddressListLoadQuery,
  12020. PrintQueueListLoadQuery,
  12021. PrintQueueJobListLoadQuery,
  12022. PrintQueueJobDelete,
  12023. PrintQueueJobInsert,
  12024. PrintQueueJobStatus,
  12025. PaymentMethodListLoad,
  12026. OrderCreateFromOrder,
  12027. OrderAuthorize,
  12028. CustomerPaymentCardListLoadQuery,
  12029. CategoryProductListLoadQuery,
  12030. CouponPriceGroupListLoadQuery,
  12031. PriceGroupCustomerListLoadQuery,
  12032. PriceGroupProductListLoadQuery,
  12033. CustomerPriceGroupListLoadQuery
  12034. };