rsm-roguchi commited on
Commit
3d769ea
·
1 Parent(s): fa7a61e
Files changed (3) hide show
  1. app.py +0 -4
  2. server/ebay_time_away.py +0 -61
  3. ui/ebay_time_away.py +0 -14
app.py CHANGED
@@ -11,7 +11,6 @@ from ui import (
11
  price_matching,
12
  inventory,
13
  listing_checks,
14
- ebay_time_away
15
  )
16
 
17
  from server import (
@@ -22,7 +21,6 @@ from server import (
22
  price_matching as price_matching_srv,
23
  inventory as inventory_srv,
24
  listing_checks as listing_checks_srv,
25
- ebay_time_away as ebay_time_away_srv
26
  )
27
 
28
 
@@ -35,7 +33,6 @@ ui = ui.page_fluid(
35
  price_matching.ui,
36
  inventory.ui,
37
  listing_checks.ui,
38
- ebay_time_away.ui,
39
  title="SEO Blog Writer",
40
  header=ui.tags.head(
41
  ui.tags.link(rel='stylesheet', type='text/css', href='style.css')
@@ -51,6 +48,5 @@ def server(input, output, session):
51
  price_matching_srv.server(input, output, session)
52
  inventory_srv.server(input, output, session)
53
  listing_checks_srv.server(input, output, session)
54
- ebay_time_away_srv.server(input, output, session)
55
 
56
  app = App(ui, server)
 
11
  price_matching,
12
  inventory,
13
  listing_checks,
 
14
  )
15
 
16
  from server import (
 
21
  price_matching as price_matching_srv,
22
  inventory as inventory_srv,
23
  listing_checks as listing_checks_srv,
 
24
  )
25
 
26
 
 
33
  price_matching.ui,
34
  inventory.ui,
35
  listing_checks.ui,
 
36
  title="SEO Blog Writer",
37
  header=ui.tags.head(
38
  ui.tags.link(rel='stylesheet', type='text/css', href='style.css')
 
48
  price_matching_srv.server(input, output, session)
49
  inventory_srv.server(input, output, session)
50
  listing_checks_srv.server(input, output, session)
 
51
 
52
  app = App(ui, server)
server/ebay_time_away.py DELETED
@@ -1,61 +0,0 @@
1
- from shiny import reactive, render
2
- from datetime import datetime, timedelta, date
3
- import requests
4
- import os
5
-
6
- def get_next_sunday():
7
- today = datetime.utcnow().date()
8
- days_until_sunday = (6 - today.weekday()) % 7
9
- return today + timedelta(days=days_until_sunday)
10
-
11
- def activate_time_away(access_token: str, end_date: date):
12
- url = "https://api.ebay.com/sell/account/v1/time_away"
13
- headers = {
14
- "Authorization": f"Bearer {access_token}",
15
- "Content-Type": "application/json"
16
- }
17
-
18
- now = datetime.utcnow()
19
- end_datetime = datetime.combine(end_date, datetime.max.time())
20
-
21
- payload = {
22
- "startDate": now.strftime("%Y-%m-%dT%H:%M:%SZ"),
23
- "endDate": end_datetime.strftime("%Y-%m-%dT%H:%M:%SZ"),
24
- "timeAwayMode": "CUSTOM_MESSAGE",
25
- "message": "Thanks for your message! We will get back to you soon! (Our business hours are M–F 9am–5pm)",
26
- "autoDeclineRequests": False,
27
- "hideFixedPriceStoreItems": False
28
- }
29
-
30
- resp = requests.put(url, headers=headers, json=payload)
31
- return resp.status_code, resp.text
32
-
33
- # Get your access token from environment
34
- ACCESS_TOKEN = os.getenv("EBAY_USER_TOKEN")
35
-
36
- def server(input, output, session):
37
- # Reactive status value (clean fix)
38
- status = reactive.Value("Click button to activate time away.")
39
-
40
- @output
41
- @render.text
42
- def timeaway_status():
43
- return status()
44
-
45
- @reactive.effect
46
- @reactive.event(input.activate_timeaway)
47
- def _():
48
- use_custom = input.use_custom_date()
49
- selected_date = input.custom_end_date()
50
-
51
- if use_custom and selected_date:
52
- end_date = selected_date
53
- else:
54
- end_date = get_next_sunday()
55
-
56
- code, msg = activate_time_away(ACCESS_TOKEN, end_date)
57
-
58
- if code in [200, 204]:
59
- status.set(f"✅ Time Away activated until {end_date.isoformat()}")
60
- else:
61
- status.set(f"❌ Failed: {msg}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/ebay_time_away.py DELETED
@@ -1,14 +0,0 @@
1
- from shiny import ui
2
- from datetime import date
3
-
4
- ui = ui.nav_panel(
5
- "eBay Time Away",
6
-
7
- ui.input_checkbox("use_custom_date", "Use custom end date", value=False),
8
-
9
- ui.input_date("custom_end_date", "Select end date (UTC)", value=date.today()),
10
-
11
- ui.input_action_button("activate_timeaway", "Activate Time Away", class_="btn-primary"),
12
-
13
- ui.output_text("timeaway_status")
14
- )