Config.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <?php
  2. namespace Dotdigitalgroup\Email\Helper;
  3. /**
  4. * Store for core config data path. Keep the configuration path in one place for settings.
  5. */
  6. class Config extends \Magento\Framework\App\Helper\AbstractHelper
  7. {
  8. /**
  9. * API SECTION.
  10. */
  11. const XML_PATH_CONNECTOR_API_ENABLED = 'connector_api_credentials/api/enabled';
  12. const XML_PATH_CONNECTOR_API_USERNAME = 'connector_api_credentials/api/username';
  13. const XML_PATH_CONNECTOR_API_PASSWORD = 'connector_api_credentials/api/password';
  14. const XML_PATH_CONNECTOR_API_TRIAL_TEMPORARY_PASSCODE =
  15. 'connector_api_credentials/api/trial_temporary_passcode';
  16. const XML_PATH_CONNECTOR_API_TRIAL_TEMPORARY_PASSCODE_EXPIRY =
  17. 'connector_api_credentials/api/trial_temporary_passcode_expiry';
  18. /**
  19. * SYNC SECTION.
  20. */
  21. const XML_PATH_CONNECTOR_SYNC_CUSTOMER_ENABLED = 'sync_settings/sync/customer_enabled';
  22. const XML_PATH_CONNECTOR_SYNC_GUEST_ENABLED = 'sync_settings/sync/guest_enabled';
  23. const XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED = 'sync_settings/sync/subscriber_enabled';
  24. const XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED = 'sync_settings/sync/order_enabled';
  25. const XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED = 'sync_settings/sync/wishlist_enabled';
  26. const XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED = 'sync_settings/sync/review_enabled';
  27. const XML_PATH_CONNECTOR_SYNC_CATALOG_ENABLED = 'sync_settings/sync/catalog_enabled';
  28. const XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID = 'sync_settings/addressbook/customers';
  29. const XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID = 'sync_settings/addressbook/subscribers';
  30. const XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID = 'sync_settings/addressbook/guests';
  31. const XML_PATH_CONNECTOR_SYNC_ALLOW_NON_SUBSCRIBERS = 'sync_settings/addressbook/allow_non_subscribers';
  32. // Mapping
  33. const XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID = 'connector_data_mapping/customer_data/last_order_id';
  34. const XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID = 'connector_data_mapping/customer_data/last_quote_id';
  35. const XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID = 'connector_data_mapping/customer_data/customer_id';
  36. const XML_PATH_CONNECTOR_MAPPING_CUSTOM_DATAFIELDS = 'connector_data_mapping/customer_data/custom_attributes';
  37. const XML_PATH_CONNECTOR_MAPPING_CUSTOMER_STORENAME = 'connector_data_mapping/customer_data/store_name';
  38. const XML_PATH_CONNECTOR_MAPPING_CUSTOMER_TOTALREFUND = 'connector_data_mapping/customer_data/total_refund';
  39. /**
  40. * Datafields Mapping.
  41. */
  42. const XML_PATH_CONNECTOR_CUSTOMER_ID = 'connector_data_mapping/customer_data/customer_id';
  43. const XML_PATH_CONNECTOR_CUSTOMER_FIRSTNAME = 'connector_data_mapping/customer_data/firstname';
  44. const XML_PATH_CONNECTOR_CUSTOMER_LASTNAME = 'connector_data_mapping/customer_data/lastname';
  45. const XML_PATH_CONNECTOR_CUSTOMER_DOB = 'connector_data_mapping/customer_data/dob';
  46. const XML_PATH_CONNECTOR_CUSTOMER_GENDER = 'connector_data_mapping/customer_data/gender';
  47. const XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME = 'connector_data_mapping/customer_data/website_name';
  48. const XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME = 'connector_data_mapping/customer_data/store_name';
  49. const XML_PATH_CONNECTOR_CUSTOMER_CREATED_AT = 'connector_data_mapping/customer_data/created_at';
  50. const XML_PATH_CONNECTOR_CUSTOMER_LAST_LOGGED_DATE = 'connector_data_mapping/customer_data/last_logged_date';
  51. const XML_PATH_CONNECTOR_CUSTOMER_CUSTOMER_GROUP = 'connector_data_mapping/customer_data/customer_group';
  52. const XML_PATH_CONNECTOR_CUSTOMER_REVIEW_COUNT = 'connector_data_mapping/customer_data/review_count';
  53. const XML_PATH_CONNECTOR_CUSTOMER_LAST_REVIEW_DATE = 'connector_data_mapping/customer_data/last_review_date';
  54. const XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_1 = 'connector_data_mapping/customer_data/billing_address_1';
  55. const XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_2 = 'connector_data_mapping/customer_data/billing_address_2';
  56. const XML_PATH_CONNECTOR_CUSTOMER_BILLING_CITY = 'connector_data_mapping/customer_data/billing_city';
  57. const XML_PATH_CONNECTOR_CUSTOMER_BILLING_STATE = 'connector_data_mapping/customer_data/billing_state';
  58. const XML_PATH_CONNECTOR_CUSTOMER_BILLING_COUNTRY = 'connector_data_mapping/customer_data/billing_country';
  59. const XML_PATH_CONNECTOR_CUSTOMER_BILLING_POSTCODE = 'connector_data_mapping/customer_data/billing_postcode';
  60. const XML_PATH_CONNECTOR_CUSTOMER_BILLING_TELEPHONE = 'connector_data_mapping/customer_data/billing_telephone';
  61. const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_1 = 'connector_data_mapping/customer_data/delivery_address_1';
  62. const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_2 = 'connector_data_mapping/customer_data/delivery_address_2';
  63. const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_CITY = 'connector_data_mapping/customer_data/delivery_city';
  64. const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_STATE = 'connector_data_mapping/customer_data/delivery_state';
  65. const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_COUNTRY = 'connector_data_mapping/customer_data/delivery_country';
  66. const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_POSTCODE = 'connector_data_mapping/customer_data/delivery_postcode';
  67. const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_TELEPHONE = 'connector_data_mapping/customer_data/delivery_telephone';
  68. const XML_PATH_CONNECTOR_CUSTOMER_TOTAL_NUMBER_ORDER = 'connector_data_mapping/customer_data/number_of_orders';
  69. const XML_PATH_CONNECTOR_CUSTOMER_AOV = 'connector_data_mapping/customer_data/average_order_value';
  70. const XML_PATH_CONNECTOR_CUSTOMER_TOTAL_SPEND = 'connector_data_mapping/customer_data/total_spend';
  71. const XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE = 'connector_data_mapping/customer_data/last_order_date';
  72. const XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID = 'connector_data_mapping/customer_data/last_order_id';
  73. const XML_PATH_CONNECTOR_CUSTOMER_TOTAL_REFUND = 'connector_data_mapping/customer_data/total_refund';
  74. const XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_INCREMENT_ID =
  75. 'connector_data_mapping/customer_data/last_increment_id';
  76. const XML_PATH_CONNECTOR_CUSTOMER_MOST_PURCHASED_CATEGORY =
  77. 'connector_data_mapping/customer_data/most_pur_category';
  78. const XML_PATH_CONNECTOR_CUSTOMER_MOST_PURCHASED_BRAND =
  79. 'connector_data_mapping/customer_data/most_pur_brand';
  80. const XML_PATH_CONNECTOR_CUSTOMER_MOST_FREQUENT_PURCHASE_DAY =
  81. 'connector_data_mapping/customer_data/most_freq_pur_day';
  82. const XML_PATH_CONNECTOR_CUSTOMER_MOST_FREQUENT_PURCHASE_MONTH =
  83. 'connector_data_mapping/customer_data/most_freq_pur_mon';
  84. const XML_PATH_CONNECTOR_CUSTOMER_FIRST_CATEGORY_PURCHASED =
  85. 'connector_data_mapping/customer_data/first_category_pur';
  86. const XML_PATH_CONNECTOR_CUSTOMER_LAST_CATEGORY_PURCHASED =
  87. 'connector_data_mapping/customer_data/last_category_pur';
  88. const XML_PATH_CONNECTOR_CUSTOMER_FIRST_BRAND_PURCHASED = 'connector_data_mapping/customer_data/first_brand_pur';
  89. const XML_PATH_CONNECTOR_CUSTOMER_LAST_BRAND_PURCHASED = 'connector_data_mapping/customer_data/last_brand_pur';
  90. const XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS = 'connector_data_mapping/customer_data/subscriber_status';
  91. const XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME = 'connector_data_mapping/customer_data/abandoned_prod_name';
  92. const XML_PATH_CONNECTOR_CUSTOMER_BILLING_COMPANY_NAME = 'connector_data_mapping/customer_data/billing_company';
  93. const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_COMPANY_NAME = 'connector_data_mapping/customer_data/delivery_company';
  94. /**
  95. * Dynamic Content.
  96. */
  97. const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE =
  98. 'connector_dynamic_content/external_dynamic_content_urls/passcode';
  99. const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_WIHSLIST_DISPLAY =
  100. 'connector_dynamic_content/products/wishlist_display_type';
  101. const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_REVIEW_DISPLAY_TYPE =
  102. 'connector_dynamic_content/products/review_display_type';
  103. /**
  104. * CONFIGURATION SECTION.
  105. */
  106. const XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_STATUS = 'connector_configuration/data_fields/order_status';
  107. const XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_BRAND_ATTRIBUTE = 'connector_configuration/data_fields/brand_attribute';
  108. //Transactional Data
  109. const XML_PATH_CONNECTOR_SYNC_ORDER_STATUS = 'connector_configuration/transactional_data/order_statuses';
  110. const XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES =
  111. 'connector_configuration/transactional_data/order_custom_attributes';
  112. const XML_PATH_CONNECTOR_SYNC_ORDER_PRODUCT_ATTRIBUTES =
  113. 'connector_configuration/transactional_data/order_product_attributes';
  114. const XML_PATH_CONNECTOR_SYNC_ORDER_PRODUCT_CUSTOM_OPTIONS =
  115. 'connector_configuration/transactional_data/order_product_custom_options';
  116. //Admin
  117. const XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS = 'connector_configuration/admin/disable_newsletter_success';
  118. const XML_PATH_CONNECTOR_DISABLE_CUSTOMER_SUCCESS = 'connector_configuration/admin/disable_customer_success';
  119. //Dynamic Content Styling
  120. const XML_PATH_CONNECTOR_DYNAMIC_STYLING = 'connector_configuration/dynamic_content_style/dynamic_styling';
  121. const XML_PATH_CONNECTOR_DYNAMIC_NAME_COLOR = 'connector_configuration/dynamic_content_style/font_color';
  122. const XML_PATH_CONNECTOR_DYNAMIC_NAME_FONT_SIZE = 'connector_configuration/dynamic_content_style/font_size';
  123. const XML_PATH_CONNECTOR_DYNAMIC_NAME_STYLE = 'connector_configuration/dynamic_content_style/font_style';
  124. const XML_PATH_CONNECTOR_DYNAMIC_PRICE_COLOR = 'connector_configuration/dynamic_content_style/price_color';
  125. const XML_PATH_CONNECTOR_DYNAMIC_PRICE_FONT_SIZE = 'connector_configuration/dynamic_content_style/price_font_size';
  126. const XML_PATH_CONNECTOR_DYNAMIC_PRICE_STYLE = 'connector_configuration/dynamic_content_style/price_font_style';
  127. const XML_PATH_CONNECTOR_DYNAMIC_LINK_COLOR = 'connector_configuration/dynamic_content_style/product_link_color';
  128. const XML_PATH_CONNECTOR_DYNAMIC_LINK_FONT_SIZE
  129. = 'connector_configuration/dynamic_content_style/product_link_font_size';
  130. const XML_PATH_CONNECTOR_DYNAMIC_LINK_STYLE = 'connector_configuration/dynamic_content_style/link_style';
  131. const XML_PATH_CONNECTOR_DYNAMIC_DOC_FONT = 'connector_configuration/dynamic_content_style/font';
  132. const XML_PATH_CONNECTOR_DYNAMIC_DOC_BG_COLOR = 'connector_configuration/dynamic_content_style/color';
  133. const XML_PATH_CONNECTOR_DYNAMIC_OTHER_COLOR = 'connector_configuration/dynamic_content_style/other_color';
  134. const XML_PATH_CONNECTOR_DYNAMIC_OTHER_FONT_SIZE = 'connector_configuration/dynamic_content_style/other_font_size';
  135. const XML_PATH_CONNECTOR_DYNAMIC_OTHER_STYLE = 'connector_configuration/dynamic_content_style/other_font_style';
  136. const XML_PATH_CONNECTOR_DYNAMIC_COUPON_COLOR = 'connector_configuration/dynamic_content_style/coupon_font_color';
  137. const XML_PATH_CONNECTOR_DYNAMIC_COUPON_FONT_SIZE =
  138. 'connector_configuration/dynamic_content_style/coupon_font_size';
  139. const XML_PATH_CONNECTOR_DYNAMIC_COUPON_STYLE = 'connector_configuration/dynamic_content_style/coupon_font_style';
  140. const XML_PATH_CONNECTOR_DYNAMIC_COUPON_FONT = 'connector_configuration/dynamic_content_style/coupon_font_picker';
  141. const XML_PATH_CONNECTOR_DYNAMIC_COUPON_BG_COLOR =
  142. 'connector_configuration/dynamic_content_style/coupon_background_color';
  143. //dynamic content product review
  144. const XML_PATH_REVIEW_STATUS = 'connector_automation/review_settings/status';
  145. const XML_PATH_REVIEW_DELAY = 'connector_automation/review_settings/delay';
  146. const XML_PATH_REVIEW_NEW_PRODUCT = 'connector_automation/review_settings/new_product';
  147. const XML_PATH_REVIEW_CAMPAIGN = 'connector_automation/review_settings/campaign';
  148. const XML_PATH_REVIEW_ANCHOR = 'connector_automation/review_settings/anchor';
  149. const XML_PATH_REVIEW_DISPLAY_TYPE = 'connector_dynamic_content/products/review_display_type';
  150. const XML_PATH_REVIEW_ALLOW_NON_SUBSCRIBERS = 'connector_automation/review_settings/allow_non_subscribers';
  151. //Catalog
  152. const XML_PATH_CONNECTOR_SYNC_CATALOG_VALUES = 'connector_configuration/catalog_sync/catalog_values';
  153. const XML_PATH_CONNECTOR_SYNC_CATALOG_VISIBILITY = 'connector_configuration/catalog_sync/catalog_visibility';
  154. const XML_PATH_CONNECTOR_SYNC_CATALOG_TYPE = 'connector_configuration/catalog_sync/catalog_type';
  155. //Abandoned Cart
  156. const XML_PATH_CONNECTOR_EMAIL_CAPTURE = 'connector_configuration/abandoned_carts/email_capture';
  157. const XML_PATH_CONNECTOR_ABANDONED_CART_LIMIT = 'connector_configuration/abandoned_carts/cart_limit';
  158. const XML_PATH_CONNECTOR_EMAIL_CAPTURE_NEWSLETTER =
  159. 'connector_configuration/abandoned_carts/easy_capture_newsletter';
  160. const XML_PATH_CONNECTOR_CONTENT_LINK_ENABLED = 'connector_configuration/abandoned_carts/link_back_to_cart';
  161. const XML_PATH_CONNECTOR_CONTENT_LINK_TEXT = 'connector_configuration/abandoned_carts/link_text';
  162. const XML_PATH_CONNECTOR_CONTENT_CART_URL = 'connector_configuration/abandoned_carts/cart_url';
  163. const XML_PATH_CONNECTOR_CONTENT_LOGIN_URL = 'connector_configuration/abandoned_carts/login_url';
  164. const XML_PATH_CONNECTOR_CONTENT_ALLOW_NON_SUBSCRIBERS
  165. = 'connector_configuration/abandoned_carts/allow_non_subscribers';
  166. const XML_PATH_CONNECTOR_AC_AUTOMATION_EXPIRE_TIME = 'connector_configuration/abandoned_carts/expire_time';
  167. // Address Book Pref
  168. const XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_CAN_CHANGE_BOOKS =
  169. 'connector_configuration/customer_addressbook/can_change';
  170. const XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_BOOKS = 'connector_configuration/customer_addressbook/show_books';
  171. const XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_CAN_SHOW_FIELDS =
  172. 'connector_configuration/customer_addressbook/can_show_fields';
  173. const XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_FIELDS =
  174. 'connector_configuration/customer_addressbook/fields_to_show';
  175. const XML_PATH_CONNECTOR_SHOW_PREFERENCES =
  176. 'connector_configuration/customer_addressbook/show_preferences';
  177. //Dynamic Content
  178. const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_LINK_TEXT = 'connector_configuration/dynamic_content/link_text';
  179. /**
  180. * Automation studio.
  181. */
  182. const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER = 'connector_automation/visitor_automation/customer_automation';
  183. const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER =
  184. 'connector_automation/visitor_automation/subscriber_automation';
  185. const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER = 'connector_automation/visitor_automation/order_automation';
  186. const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER =
  187. 'connector_automation/visitor_automation/guest_order_automation';
  188. const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW = 'connector_automation/visitor_automation/review_automation';
  189. const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST = 'connector_automation/visitor_automation/wishlist_automation';
  190. const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER_STATUS = 'connector_automation/order_status_automation/program';
  191. const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_FIRST_ORDER =
  192. 'connector_automation/visitor_automation/first_order_automation';
  193. /**
  194. * ROI SECTION.
  195. */
  196. const XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED = 'connector_configuration/tracking/roi_enabled';
  197. const XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED = 'connector_configuration/tracking/page_enabled';
  198. /**
  199. * CONSENT SECTION.
  200. */
  201. const XML_PATH_DOTMAILER_CONSENT_SUBSCRIBER_ENABLED =
  202. 'connector_configuration/consent/dotmailer_consent_subscriber_enabled';
  203. const XML_PATH_DOTMAILER_CONSENT_SUBSCRIBER_TEXT =
  204. 'connector_configuration/consent/dotmailer_consent_subscriber_text';
  205. const XML_PATH_DOTMAILER_CONSENT_CUSTOMER_TEXT =
  206. 'connector_configuration/consent/dotmailer_consent_customer_text';
  207. /**
  208. * OAUTH.
  209. */
  210. const API_CONNECTOR_OAUTH_URL_AUTHORISE = 'OAuth2/authorise.aspx?';
  211. const API_CONNECTOR_OAUTH_URL_TOKEN = 'OAuth2/Tokens.ashx';
  212. const API_CONNECTOR_OAUTH_URL_LOG_USER = '?oauthtoken=';
  213. const CONNECTOR_FEED_LAST_CHECK_TIME = 'connector_feed_last_check_time';
  214. /**
  215. * Reviews SECTION.
  216. */
  217. const XML_PATH_REVIEWS_ENABLED = 'connector_automation/review_settings/enabled';
  218. //PRODUCT REVIEW REMINDER.
  219. const XML_PATH_AUTOMATION_REVIEW_STATUS = 'connector_automation_studio/review_settings/status';
  220. const XML_PATH_AUTOMATION_REVIEW_DELAY = 'connector_automation_studio/review_settings/delay';
  221. const XML_PATH_AUTOMATION_REVIEW_CAMPAIGN = 'connector_automation_studio/review_settings/campaign';
  222. const XML_PATH_AUTOMATION_REVIEW_ANCHOR = 'connector_automation_studio/review_settings/anchor';
  223. const XML_PATH_REVIEWS_FEEFO_LOGON = 'connector_automation/feefo_feedback_engine/logon';
  224. const XML_PATH_REVIEWS_FEEFO_REVIEWS = 'connector_automation/feefo_feedback_engine/reviews_per_product';
  225. const XML_PATH_REVIEWS_FEEFO_TEMPLATE = 'connector_automation/feefo_feedback_engine/template';
  226. /**
  227. * Developer SECTION.
  228. */
  229. const XML_PATH_CONNECTOR_CLIENT_ID = 'connector_developer_settings/oauth/client_id';
  230. const XML_PATH_CONNECTOR_SYNC_LIMIT = 'connector_developer_settings/import_settings/batch_size';
  231. const XML_PATH_CONNECTOR_CUSTOM_DOMAIN = 'connector_developer_settings/oauth/custom_domain';
  232. const XML_PATH_CONNECTOR_SETUP_DATAFIELDS = 'connector_developer_settings/sync_settings/setup_data_fields';
  233. const XML_PATH_CONNECTOR_CLIENT_SECRET_ID = 'connector_developer_settings/oauth/client_key';
  234. const XML_PATH_CONNECTOR_CUSTOM_AUTHORIZATION = 'connector_developer_settings/oauth/custom_authorization';
  235. const XML_PATH_CONNECTOR_ADVANCED_DEBUG_ENABLED = 'connector_developer_settings/debug/debug_enabled';
  236. const XML_PATH_CONNECTOR_DEBUG_API_REQUEST_LIMIT = 'connector_developer_settings/debug/api_log_time';
  237. const XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT =
  238. 'connector_developer_settings/import_settings/transactional_data';
  239. const XML_PATH_CONNECTOR_IP_RESTRICTION_ADDRESSES = 'connector_developer_settings/ip_restriction/ip_addresses';
  240. const XML_PATH_CONNECTOR_ENABLE_SUBSCRIBER_SALES_DATA =
  241. 'connector_developer_settings/import_settings/subscriber_sales_data_enabled';
  242. /**
  243. * API endpoint.
  244. */
  245. const PATH_FOR_API_ENDPOINT = 'connector/api/endpoint';
  246. /**
  247. * Trial Account.
  248. */
  249. const API_CONNECTOR_TRIAL_FORM_URL = 'https://magentosignup.dotmailer.com/';
  250. /**
  251. * @var \Magento\Framework\Stdlib\StringUtils
  252. */
  253. private $stringUtils;
  254. /**
  255. * @var \Magento\Store\Model\StoreManagerInterface
  256. */
  257. private $storeManager;
  258. /**
  259. * Config constructor.
  260. * @param \Magento\Framework\App\Helper\Context $context
  261. * @param \Magento\Framework\Stdlib\StringUtils $stringUtils
  262. * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  263. */
  264. public function __construct(
  265. \Magento\Framework\App\Helper\Context $context,
  266. \Magento\Framework\Stdlib\StringUtils $stringUtils,
  267. \Magento\Store\Model\StoreManagerInterface $storeManager
  268. ) {
  269. $this->stringUtils = $stringUtils;
  270. $this->storeManager = $storeManager;
  271. parent::__construct($context);
  272. }
  273. /**
  274. * Authorization link for OAUTH.
  275. *
  276. * @param int $website
  277. *
  278. * @return string
  279. */
  280. public function getAuthorizeLink($website = 0)
  281. {
  282. //base url, check for custom oauth domain
  283. if ($this->isAuthorizeCustomDomain($website)) {
  284. $baseUrl = $this->getWebsiteConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN)
  285. . self::API_CONNECTOR_OAUTH_URL_AUTHORISE;
  286. } else {
  287. $baseUrl = $this->getRegionAuthorize($website) . self::API_CONNECTOR_OAUTH_URL_AUTHORISE;
  288. }
  289. return $baseUrl;
  290. }
  291. /**
  292. * Is authorization link for custom domain set.
  293. *
  294. * @param int $website
  295. *
  296. * @return bool
  297. */
  298. private function isAuthorizeCustomDomain($website = 0)
  299. {
  300. $website = $this->storeManager->getWebsite($website);
  301. $customDomain = $website->getConfig(
  302. self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN
  303. );
  304. return (bool)$customDomain;
  305. }
  306. /**
  307. * Region aware authorize link.
  308. *
  309. * @param \Magento\Store\Api\Data\WebsiteInterface|int $website
  310. *
  311. * @return string|array
  312. */
  313. private function getRegionAuthorize($website)
  314. {
  315. $website = $this->storeManager->getWebsite($website);
  316. $apiEndpoint = $this->getWebsiteConfig(self::PATH_FOR_API_ENDPOINT, $website) . '/';
  317. //replace the api with the app prefix from the domain name
  318. $regionBaseUrl = str_replace('api', 'app', $apiEndpoint);
  319. return $regionBaseUrl;
  320. }
  321. /**
  322. * Callback authorization url.
  323. *
  324. * @return string
  325. */
  326. public function getCallbackUrl()
  327. {
  328. if ($callback = $this->scopeConfig->getValue(self::XML_PATH_CONNECTOR_CUSTOM_AUTHORIZATION)) {
  329. return $callback;
  330. }
  331. return $this->storeManager->getStore()->getBaseUrl(
  332. \Magento\Framework\UrlInterface::URL_TYPE_WEB,
  333. true
  334. );
  335. }
  336. /**
  337. * Token url for OAUTH.
  338. *
  339. * @param int $website
  340. *
  341. * @return string
  342. */
  343. public function getTokenUrl($website = 0)
  344. {
  345. if ($this->isAuthorizeCustomDomain($website)) {
  346. $website = $this->storeManager->getWebsite($website);
  347. $tokenUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN) .
  348. self::API_CONNECTOR_OAUTH_URL_TOKEN;
  349. } else {
  350. $tokenUrl = $this->getRegionAuthorize($website) . self::API_CONNECTOR_OAUTH_URL_TOKEN;
  351. }
  352. return $tokenUrl;
  353. }
  354. /**
  355. * Get login user url with for OAUTH.
  356. *
  357. * @param int $website
  358. *
  359. * @return string
  360. */
  361. public function getLogUserUrl($website = 0)
  362. {
  363. if ($this->isAuthorizeCustomDomain($website)) {
  364. $logUserUrl = $this->getWebsiteConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN)
  365. . self::API_CONNECTOR_OAUTH_URL_LOG_USER;
  366. } else {
  367. $logUserUrl = $this->getRegionAuthorize($website) . self::API_CONNECTOR_OAUTH_URL_LOG_USER;
  368. }
  369. return $logUserUrl;
  370. }
  371. /**
  372. * @param \Magento\Store\Api\Data\StoreInterface $store
  373. * @return string
  374. */
  375. public function getOptInType($store)
  376. {
  377. $needToConfirm = $store->getConfig(
  378. \Magento\Newsletter\Model\Subscriber::XML_PATH_CONFIRMATION_FLAG
  379. );
  380. $optInType = ($needToConfirm)? 'Double' : 'Single';
  381. return $optInType;
  382. }
  383. /**
  384. * @param string $path
  385. * @param int $website
  386. * @param string $scope
  387. * @return int|string|boolean|float
  388. */
  389. public function getWebsiteConfig($path, $website = 0, $scope = \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE)
  390. {
  391. return $this->scopeConfig->getValue(
  392. $path,
  393. $scope,
  394. $website
  395. );
  396. }
  397. /**
  398. * @param int $websiteId
  399. * @return string
  400. */
  401. public function getConsentCustomerText($websiteId)
  402. {
  403. return $this->limitLength(
  404. $this->getWebsiteConfig(self::XML_PATH_DOTMAILER_CONSENT_CUSTOMER_TEXT, $websiteId)
  405. );
  406. }
  407. /**
  408. * @param int $websiteId
  409. * @return string|boolean
  410. */
  411. public function isConsentSubscriberEnabled($websiteId)
  412. {
  413. return $this->getWebsiteConfig(self::XML_PATH_DOTMAILER_CONSENT_SUBSCRIBER_ENABLED, $websiteId);
  414. }
  415. /**
  416. * @param int $websiteId
  417. * @return string|boolean
  418. */
  419. public function getConsentSubscriberText($websiteId)
  420. {
  421. return $this->limitLength(
  422. $this->getWebsiteConfig(self::XML_PATH_DOTMAILER_CONSENT_SUBSCRIBER_TEXT, $websiteId)
  423. );
  424. }
  425. /**
  426. * @param string $value
  427. * @return string
  428. */
  429. private function limitLength($value)
  430. {
  431. if ($this->stringUtils->strlen($value) > \Dotdigitalgroup\Email\Model\Consent::CONSENT_TEXT_LIMIT) {
  432. $value = $this->stringUtils->substr($value, 0, \Dotdigitalgroup\Email\Model\Consent::CONSENT_TEXT_LIMIT);
  433. }
  434. return $value;
  435. }
  436. }