Commit 8f9a5c30 authored by Omar Chehab's avatar Omar Chehab

Remove use of proxy

parent 7240e806
......@@ -2,7 +2,12 @@
"name": "Toggl To Manager",
"version": "1.0.0",
"description": "Imports Toggl time entries as Billable Expenses into Manager",
"permissions": ["tabs", "declarativeContent", "storage"],
"permissions": [
"declarativeContent",
"storage",
"tabs",
"*://*/*"
],
"background": {
"scripts": ["background.js"],
"persistent": false
......
const proxy = 'https://toggl-to-manager.herokuapp.com/';
const togglUserAgent = 'user_agent=omar%40247studios.me'
const managerCustomerCollectionGuid = 'ec37c11e-2b67-49c6-8a58-6eccb7dd75ee';
......@@ -79,7 +78,7 @@ chrome.storage.sync.get([
managerUsernameField.value = data.managerUsername || managerUsername || ''
managerPasswordField.value = data.managerPassword || managerPassword || ''
if (togglApiKeyField.value && managerUrlField.value && managerUsernameField.value && managerPasswordField.value) {
if (togglApiKeyField.value && managerUrlField.value && managerUsernameField.value) {
credentialsSubmit.click();
}
});
......@@ -101,7 +100,7 @@ credentialsTab.addEventListener('submit', async function(event) {
abortController = new AbortController()
const signal = abortController.signal
const togglWorkspacesResponse = await fetch(`${proxy}https://www.toggl.com/api/v8/workspaces?${togglUserAgent}`, {
const togglWorkspacesResponse = await fetch(`https://www.toggl.com/api/v8/workspaces?${togglUserAgent}`, {
headers: {
Authorization: 'Basic ' + btoa(`${togglApiKey}:api_token`)
},
......@@ -120,7 +119,7 @@ credentialsTab.addEventListener('submit', async function(event) {
console.log('Toggl Workspaces: NOT OK');
}
const managerResponse = await fetch(`${proxy}${managerUrl}/api/index.json`, {
const managerResponse = await fetch(`${managerUrl}/api/index.json`, {
headers: {
Authorization: 'Basic ' + btoa(`${managerUsername}:${managerPassword}`),
},
......@@ -174,7 +173,7 @@ chooseNamespacesTab.addEventListener('submit', async function(event) {
abortController = new AbortController()
const signal = abortController.signal
const togglClientsResponse = await fetch(`${proxy}https://www.toggl.com/api/v8/workspaces/${selections.togglWorkspaceId}/clients?${togglUserAgent}`, {
const togglClientsResponse = await fetch(`https://www.toggl.com/api/v8/workspaces/${selections.togglWorkspaceId}/clients?${togglUserAgent}`, {
headers: {
Authorization: 'Basic ' + btoa(`${togglApiKey}:api_token`)
},
......@@ -193,7 +192,7 @@ chooseNamespacesTab.addEventListener('submit', async function(event) {
console.log('Toggl Clients: NOT OK');
}
const managerCustomersResponse = await fetch(`${proxy}${managerUrl}/api/${selections.managerBusinessId}/${managerCustomerCollectionGuid}/index.json`, {
const managerCustomersResponse = await fetch(`${managerUrl}/api/${selections.managerBusinessId}/${managerCustomerCollectionGuid}/index.json`, {
headers: {
Authorization: 'Basic ' + btoa(`${managerUsername}:${managerPassword}`)
},
......@@ -204,7 +203,7 @@ chooseNamespacesTab.addEventListener('submit', async function(event) {
const managerCustomerIds = await managerCustomersResponse.json();
const managerCustomerResponses = await (Promise.all(
managerCustomerIds.map(customerId =>
fetch(`${proxy}${managerUrl}/api/${selections.managerBusinessId}/${customerId}.json`, {
fetch(`${managerUrl}/api/${selections.managerBusinessId}/${customerId}.json`, {
headers: {
Authorization: 'Basic ' + btoa(`${managerUsername}:${managerPassword}`)
},
......@@ -256,7 +255,7 @@ importReportTab.addEventListener('submit', async function(event) {
abortController = new AbortController()
const signal = abortController.signal
const togglReportResponse = await fetch(`${proxy}https://www.toggl.com/reports/api/v2/summary?${togglUserAgent}&workspace_id=${selections.togglWorkspaceId}&grouping=projects&subgrouping=users&order_field=title&order_desc=off&rounding=Off&distinct_rates=Off&status=active&client_ids=${selections.togglClientId}&calculate=time&sortDirection=asc&sortBy=title&page=1&since=${selections.reportStartDate}&until=${selections.reportEndDate}&with_total_currencies=1&subgrouping_ids=true&date_format=YYYY-MM-DD`, {
const togglReportResponse = await fetch(`https://www.toggl.com/reports/api/v2/summary?${togglUserAgent}&workspace_id=${selections.togglWorkspaceId}&grouping=projects&subgrouping=users&order_field=title&order_desc=off&rounding=Off&distinct_rates=Off&status=active&client_ids=${selections.togglClientId}&calculate=time&sortDirection=asc&sortBy=title&page=1&since=${selections.reportStartDate}&until=${selections.reportEndDate}&with_total_currencies=1&subgrouping_ids=true&date_format=YYYY-MM-DD`, {
headers: {
Authorization: 'Basic ' + btoa(`${togglApiKey}:api_token`)
},
......@@ -339,7 +338,7 @@ generateTab.addEventListener('submit', async function(event) {
const signal = abortController.signal
const managerBillableTimeEntriesReponse = await Promise.all(managerBillableTimeEntries.map((billableTimeEntry) => (
fetch(`${proxy}${managerUrl}/api/${selections.managerBusinessId}/${managerBillableTimeEntryCollectionGuid}`, {
fetch(`${managerUrl}/api/${selections.managerBusinessId}/${managerBillableTimeEntryCollectionGuid}`, {
method: 'POST',
headers: {
Authorization: 'Basic ' + btoa(`${managerUsername}:${managerPassword}`),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment