{"id":1238,"date":"2024-11-14T09:37:44","date_gmt":"2024-11-14T09:37:44","guid":{"rendered":"https:\/\/www.marsbetaffiliates.com\/?page_id=1238"},"modified":"2024-11-21T08:48:11","modified_gmt":"2024-11-21T08:48:11","slug":"become-an-affiliate","status":"publish","type":"page","link":"https:\/\/www.marsbetaffiliates.com\/en\/become-an-affiliate\/","title":{"rendered":"Become an Affiliate"},"content":{"rendered":"\n<p class=\"has-text-align-center\">Your application will be reviewed by admins. You will be informed via e-mail once the review process is completed.<\/p>\n\n\n\n\n\n\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Affiliate Application Form<\/title>\n    <style>\n        \/* Form Styling *\/\n        #dataForm {\n            font-family: Arial, sans-serif;\n            max-width: 600px;\n            margin: 0 auto;\n            padding: 20px;\n            background-color: #f9f9f9;\n            border: 1px solid #ddd;\n            border-radius: 8px;\n        }\n        #dataForm label {\n            font-size: 14px;\n            font-weight: bold;\n            margin-bottom: 8px;\n            display: block;\n        }\n        #dataForm input,\n        #dataForm select {\n            width: 90%;\n            padding: 10px;\n            margin: 5px 0 15px 0;\n            border: 1px solid #ccc;\n            border-radius: 4px;\n        }\n        #dataForm button {\n            background-color: #0073aa;\n            color: white;\n            padding: 12px 20px;\n            border: none;\n            border-radius: 4px;\n            cursor: pointer;\n        }\n        #dataForm button:hover {\n            background-color: #005c8a;\n        }\n    <\/style>\n\n\n\n    <form id=\"dataForm\">\n        <label for=\"affiliateName\">Affiliate Name:<\/label>\n        <input type=\"text\" id=\"affiliateName\" name=\"affiliateName\" required=\"\">\n\n        <label for=\"email\">Email:<\/label>\n        <input type=\"email\" id=\"email\" name=\"user[email]\" required=\"\">\n\n        <label for=\"password\">Password:<\/label>\n        <input type=\"password\" id=\"password\" name=\"user[password]\" required=\"\">\n\n        <label for=\"confirmPassword\">Confirm Password:<\/label>\n        <input type=\"password\" id=\"confirmPassword\" required=\"\">\n\n        <label for=\"country\">Country:<\/label>\n        <select id=\"country\" name=\"country\" required=\"\"><\/select>\n\n        <label for=\"language\">Language:<\/label>\n        <select id=\"language\" name=\"language\" required=\"\">\n            <option value=\"EN\">EN<\/option>\n            <option value=\"TR\">TR<\/option>\n            <option value=\"RU\">RU<\/option>\n        <\/select>\n\n        <label for=\"sourceUrl\">Source URL:<\/label>\n        <input type=\"text\" id=\"sourceUrl\" name=\"sourceUrl\">\n\n        <button type=\"submit\">Submit<\/button>\n    <\/form>\n\n    <script>\n        \/\/ Fetch the list of countries for the dropdown\n        fetch('https:\/\/restcountries.com\/v3.1\/all?fields=name,cca2')\n            .then(response => response.json())\n            .then(countries => {\n                \/\/ Sort countries alphabetically by name\n                countries.sort((a, b) => a.name.common.localeCompare(b.name.common));\n\n                \/\/ Populate the country dropdown\n                const countryDropdown = document.getElementById('country');\n                countries.forEach(country => {\n                    const option = document.createElement('option');\n                    option.value = country.cca2;  \/\/ ISO country code\n                    option.textContent = country.name.common;  \/\/ Country name\n                    countryDropdown.appendChild(option);\n                });\n            })\n            .catch(error => console.error('Error fetching countries:', error));\n\n        \/\/ Handle form submission\n        document.getElementById('dataForm').addEventListener('submit', function(e) {\n            e.preventDefault();  \/\/ Prevent the form from submitting the usual way\n\n            \/\/ Get form field values\n            const affiliateName = document.getElementById('affiliateName').value;\n            const email = document.getElementById('email').value;\n            const password = document.getElementById('password').value;\n            const confirmPassword = document.getElementById('confirmPassword').value;\n            const country = document.getElementById('country').value;\n            const language = document.getElementById('language').value;\n            const sourceUrl = document.getElementById('sourceUrl').value;\n\n            \/\/ Affiliate Name Validation (AWS Cognito-compatible: no spaces, special characters)\n            const affiliateNamePattern = \/^[a-zA-Z0-9_]+$\/;\n            if (!affiliateNamePattern.test(affiliateName)) {\n                alert('Affiliate Name can only contain letters, numbers, and underscores, with no spaces or special characters.');\n                return;  \/\/ Stop form submission if affiliate name is invalid\n            }\n\n            \/\/ Password validation\n            if (password !== confirmPassword) {\n                alert('Passwords do not match. Please try again.');\n                return;  \/\/ Stop form submission if passwords don't match\n            }\n\n            \/\/ Email validation (custom)\n            const emailPattern = \/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$\/;\n            if (!emailPattern.test(email)) {\n                alert('Please enter a valid email address.');\n                return;  \/\/ Stop form submission if email is invalid\n            }\n\n            \/\/ Prepare the form data\n            const formData = {\n                affiliateName: affiliateName,\n                user: {\n                    email: email,\n                    password: password\n                },\n                country: country,\n                language: language,\n                sourceUrl: sourceUrl\n            };\n\n            \/\/ Send the data via fetch\n            fetch('https:\/\/www.marsbet.com\/api\/affiliateapplicationmanagement\/v1\/applications', {\n                method: 'POST',\n                headers: {\n                    'Content-Type': 'application\/json'\n                },\n                body: JSON.stringify(formData)\n            })\n            .then(response => {\n                if (!response.ok) {\n                    \/\/ If the status code is 400 (or another non-200 response), throw an error\n                    return response.json().then(errorData => {\n                        throw new Error(errorData.message || 'Failed to submit the form.');\n                    });\n                }\n                return response.json();  \/\/ Parse the JSON response if the status code is 200\n            })\n            .then(data => {\n                console.log('API response:', data); \/\/ Log the entire response for troubleshooting\n                alert('Form submitted successfully! Your application is being processed.');\n            })\n            .catch(error => {\n                console.error('Error:', error);\n                alert('There was an error with the request: ' + error.message);  \/\/ Display the error message in the alert\n            });\n        });\n    <\/script>\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>Your application will be reviewed by admins. You will be informed via e-mail once the review process is completed. Affiliate Application Form Affiliate Name: Email: Password: Confirm Password: Country: Language: ENTRRU Source URL: Submit<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.marsbetaffiliates.com\/en\/wp-json\/wp\/v2\/pages\/1238"}],"collection":[{"href":"https:\/\/www.marsbetaffiliates.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.marsbetaffiliates.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.marsbetaffiliates.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marsbetaffiliates.com\/en\/wp-json\/wp\/v2\/comments?post=1238"}],"version-history":[{"count":17,"href":"https:\/\/www.marsbetaffiliates.com\/en\/wp-json\/wp\/v2\/pages\/1238\/revisions"}],"predecessor-version":[{"id":1258,"href":"https:\/\/www.marsbetaffiliates.com\/en\/wp-json\/wp\/v2\/pages\/1238\/revisions\/1258"}],"wp:attachment":[{"href":"https:\/\/www.marsbetaffiliates.com\/en\/wp-json\/wp\/v2\/media?parent=1238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}