#!/usr/bin/env python3
"""Create a styled Google Doc version of the eToro SOW."""
import json, requests

with open('/root/.openclaw/workspace/google-auth/token.json') as f:
    d = json.load(f)

r = requests.post('https://oauth2.googleapis.com/token', data={
    'client_id': d['client_id'],
    'client_secret': d['client_secret'],
    'refresh_token': d['refresh_token'],
    'grant_type': 'refresh_token'
})
access_token = r.json()['access_token']
headers = {'Authorization': f'Bearer {access_token}', 'Content-Type': 'application/json'}

# 1. Create doc
r = requests.post('https://docs.googleapis.com/v1/documents', headers=headers,
    json={'title': 'Curious Endeavor × eToro — Statement of Work'})
doc = r.json()
doc_id = doc['documentId']
print(f"Doc created: https://docs.google.com/document/d/{doc_id}/edit")

# Helper to build requests
reqs = []
idx = 1  # current insert index

def insert_text(text, bold=False, italic=False, font_size=None, font_family=None, color=None, heading=None):
    global idx
    req = {'insertText': {'location': {'index': idx}, 'text': text + '\n'}}
    reqs.append(req)
    
    style = {}
    if bold: style['bold'] = True
    if italic: style['italic'] = True
    if font_size: style['fontSize'] = {'magnitude': font_size, 'unit': 'PT'}
    if font_family: style['weightedFontFamily'] = {'fontFamily': font_family}
    if color:
        r_val = int(color[1:3], 16) / 255
        g_val = int(color[3:5], 16) / 255
        b_val = int(color[5:7], 16) / 255
        style['foregroundColor'] = {'color': {'rgbColor': {'red': r_val, 'green': g_val, 'blue': b_val}}}
    
    if style:
        fields = ','.join(style.keys())
        reqs.append({
            'updateTextStyle': {
                'range': {'startIndex': idx, 'endIndex': idx + len(text)},
                'textStyle': style,
                'fields': fields
            }
        })
    
    if heading:
        reqs.append({
            'updateParagraphStyle': {
                'range': {'startIndex': idx, 'endIndex': idx + len(text) + 1},
                'paragraphStyle': {'namedStyleType': heading},
                'fields': 'namedStyleType'
            }
        })
    
    idx += len(text) + 1

def insert_line():
    global idx
    reqs.append({'insertText': {'location': {'index': idx}, 'text': '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'}})
    reqs.append({
        'updateTextStyle': {
            'range': {'startIndex': idx, 'endIndex': idx + 47},
            'textStyle': {'foregroundColor': {'color': {'rgbColor': {'red': 0.93, 'green': 0.93, 'blue': 0.93}}}},
            'fields': 'foregroundColor'
        }
    })
    idx += 48

# Build the document content
insert_text('CURIOUS ENDEAVOR × eTORO', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('Statement of Work', bold=True, font_size=28, font_family='Inter')
insert_text('Brand Transformation & AI-Powered Production Systems', italic=True, font_size=14, font_family='Inter', color='#666666')
insert_text('')

# Project details
insert_text('Date: February 2026  |  Client: eToro  |  Duration: 12-16 weeks', font_size=10, font_family='JetBrains Mono', color='#999999')
insert_line()
insert_text('')

# Intro
insert_text('This Statement of Work ("SOW") made effective as of February 2026, is entered into by and between Curious Endeavor LLC, ("Curious Endeavor") and eToro ("Company"). Unless otherwise specified, capitalized terms used in this SOW shall have the meanings defined in the Agreement.', font_size=11, font_family='Inter')
insert_text('')

# Timeline Overview
insert_text('TIMELINE & INVESTMENT OVERVIEW', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('Project Timeline', bold=True, font_size=18, font_family='Inter')
insert_text('Total duration: ~5 weeks for Phases 1-2, with Phases 3-4 ongoing from Week 6. All dates assume client feedback within 2 business days per MSA Section 4. Delays in client response extend phase duration day-for-day.', font_size=11, font_family='Inter')
insert_text('')

insert_text('Phase 1 — Discovery + Tech Setup  |  ~2 weeks (Weeks 1–2)  |  €50,000 combined', bold=True, font_size=11, font_family='Inter')
insert_text('Competitive research, brand audit, strategy foundation, Discord/AI infrastructure', font_size=11, font_family='Inter', color='#666666')
insert_text('')
insert_text('Phase 2 — Rebrand + Brand System  |  ~2.5 weeks (Weeks 3–5)', bold=True, font_size=11, font_family='Inter')
insert_text('Brand book, design system, UI component foundations', font_size=11, font_family='Inter', color='#666666')
insert_text('')
insert_text('Phases 3–4 — Implementation + Scale  |  Week 6+  |  €20,000/month', bold=True, font_size=11, font_family='Inter')
insert_text('Brand deployment, AI studios, campaign systems', font_size=11, font_family='Inter', color='#666666')
insert_text('')
insert_text('Note: All timelines assume client feedback within 2 business days per MSA Section 4. Delays in client response will extend phase duration day-for-day.', italic=True, font_size=10, font_family='Inter', color='#999999')
insert_line()
insert_text('')

# Phase 1
insert_text('PHASE 1 · ~2 WEEKS', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('Onboarding, Discovery & Tech Implementation', bold=True, font_size=18, font_family='Inter')
insert_text('In the onboarding phase, we immerse ourselves in eToro\'s world: understanding your brand history, market position, internal culture, and competitive landscape.', font_size=11, font_family='Inter')
insert_text('')

# Phase 1 table as text
items_p1 = [
    ('C-Suite / leadership interviews', '2 days', 'Stakeholder insights document'),
    ('Brand perception audit (internal + external)', '1 day', 'Brand perception report'),
    ('Competitive deep-dive (visual, messaging, product)', '1 day', 'Exhaustive competitive research document'),
    ('Discord server setup with role-based access', '2 days', 'Dedicated Discord workspace'),
    ('AI workflow implementation', '2 days', 'AI-augmented production team + workflow documentation'),
    ('Competitive research document', '2 days', 'Industry + competition landscape deck'),
    ('Technology and platform audit', 'optional', 'Platform audit report'),
    ('Brand positioning, narrative, pitch, mission', '~5 days', 'Brand narrative + mission statement, elevator pitch, positioning gap analysis'),
    ('Team onboarding and training', 'optional', 'Training materials + onboarding sessions'),
]

insert_text('Process  →  Time  →  Deliverables', bold=True, font_size=10, font_family='JetBrains Mono', color='#999999')
for proc, time, deliv in items_p1:
    color = '#999999' if time == 'optional' else '#1a1a1a'
    insert_text(f'• {proc}  —  {time}', font_size=11, font_family='Inter', color=color)
    insert_text(f'  → {deliv}', font_size=10, font_family='Inter', color='#666666')

insert_text('')
insert_text('Phase 1 Total: ~15 days (~3 working weeks)', bold=True, font_size=11, font_family='Inter', color='#cc0000')
insert_line()
insert_text('')

# Phase 2
insert_text('PHASE 2 · ~2.5 WEEKS', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('Rebrand: Design Direction & Brand System', bold=True, font_size=18, font_family='Inter')
insert_text('This phase defines eToro\'s elevated brand identity: how it looks, feels, and sounds across all touchpoints. We explore multiple design directions, refine through structured critique, and deliver a complete brand system.', font_size=11, font_family='Inter')
insert_text('')

insert_text('Clarifications:', bold=True, font_size=11, font_family='Inter')
insert_text('"Brand Design Lock" — the formal sign-off milestone where eToro approves the final creative direction.', font_size=11, font_family='Inter', color='#666666')
insert_text('"UI component foundations" — core visual building blocks (buttons, cards, form elements, navigation patterns) as design specifications.', font_size=11, font_family='Inter', color='#666666')
insert_text('"1 final design direction" — we present 2–3 options, eToro selects one to develop fully.', font_size=11, font_family='Inter', color='#666666')
insert_text('')

items_p2 = [
    ('2–3 inspiration directions + moodboards', '2 days', 'Moodboards + reference collection per direction'),
    ('Stakeholder alignment sessions', '1 day', 'Alignment on chosen direction'),
    ('Brand Design Lock — 1 final design direction', '3 days', 'Creative direction and rationale document'),
    ('Logo system development', '3 days', 'Logo system + concept overview, usage and clear space rules'),
    ('Color palette + typography system', '1 day', 'Primary, secondary, extended palette + type system'),
    ('Tone of voice + photo language', '1 day', 'Tone of voice guidelines, photo language and treatment guide'),
    ('Brand architecture + UI component foundations', '1 day', 'Brand architecture map, UI component foundations'),
]

insert_text('Process  →  Time  →  Deliverables', bold=True, font_size=10, font_family='JetBrains Mono', color='#999999')
for proc, time, deliv in items_p2:
    insert_text(f'• {proc}  —  {time}', font_size=11, font_family='Inter')
    insert_text(f'  → {deliv}', font_size=10, font_family='Inter', color='#666666')

insert_text('')
insert_text('Phase 2 Total: ~12 days (~2.5 working weeks)', bold=True, font_size=11, font_family='Inter', color='#cc0000')
insert_text('Iteration rounds (3 rounds included) — additional, timeline depends on client feedback turnaround.', italic=True, font_size=10, font_family='Inter', color='#999999')
insert_line()
insert_text('')

# Brand Book Scope
insert_text('BRAND BOOK SCOPE', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('The Brand Book is a digital, interactive document hosted on a dedicated webpage on Curious Endeavor\'s platform. Single source of truth for eToro\'s new brand identity.', font_size=11, font_family='Inter')
insert_text('')

bb_items = [
    ('Brand Strategy', 'Creative direction and rationale, brand narrative, mission statement, elevator pitch, positioning'),
    ('Logo System', 'Logo concept overview, usage rules, clear space, minimum sizes, do\'s and don\'ts, file formats'),
    ('Color Palette', 'Primary, secondary, extended palette with hex/RGB/CMYK values, usage guidelines, accessibility contrast ratios'),
    ('Typography', 'Type system with hierarchy, font families, weights, sizes, spacing, usage rules for headings/body/UI'),
    ('Tone of Voice', 'Voice principles, writing guidelines, do\'s and don\'ts, example copy for different contexts'),
    ('Photo & Image Language', 'Photography style, treatment guide, image composition rules, illustration guidelines'),
    ('Visual Language & Iconography', 'Icon system, visual language guidelines, graphic elements, illustration style'),
    ('Brand Architecture', 'Sub-brand relationships, product naming conventions, brand hierarchy'),
    ('UI Component Foundations', 'Core visual building blocks as design specifications for engineering teams'),
]

for section, contents in bb_items:
    insert_text(f'• {section}', bold=True, font_size=11, font_family='Inter')
    insert_text(f'  {contents}', font_size=10, font_family='Inter', color='#666666')

insert_text('')
insert_text('Format: Digital brand book hosted on a dedicated webpage. Designed for real-time reference — not a static PDF. Includes interactive examples, downloadable assets, and copy-paste specifications.', italic=True, font_size=10, font_family='Inter', color='#999999')
insert_line()
insert_text('')

# Phase 3
insert_text('PHASE 3 (OPTIONAL) · ~3-4 WEEKS', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('Implementation', bold=True, font_size=18, font_family='Inter')
insert_text('Implementation bridges the gap between brand system and market presence. Establishes three specialized AI + human content production studios.', font_size=11, font_family='Inter')
insert_text('')
insert_text('• Website/landing page brand application', font_size=11, font_family='Inter')
insert_text('• Campaign asset creation', font_size=11, font_family='Inter')
insert_text('• Studio 1: Human photography  |  Studio 2: Screen/product imagery  |  Studio 3: Motion design', font_size=11, font_family='Inter')
insert_line()
insert_text('')

# Phase 4
insert_text('PHASE 4 (OPTIONAL) · ~3-5 WEEKS', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('Scale: Campaign Machine & Automation', bold=True, font_size=18, font_family='Inter')
insert_text('Transforms eToro\'s brand operations into a creative machine. Campaign generation, landing page systems, multi-variant creative, full funnel automation.', font_size=11, font_family='Inter')
insert_line()
insert_text('')

# Investment
insert_text('YOUR INVESTMENT & PAYMENT TERMS', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('')
insert_text('Brand Transformation (Phases 1-2):  €50,000', bold=True, font_size=16, font_family='Inter')
insert_text('Complete rebrand including discovery, strategy, brand book, and design system.', font_size=11, font_family='Inter', color='#666666')
insert_text('')
insert_text('Implementation Support (Phases 3-4) · Optional:  €20,000 / month', bold=True, font_size=16, font_family='Inter')
insert_text('Accompanying the internal team through implementation and scale phases.', font_size=11, font_family='Inter', color='#666666')
insert_text('')
insert_text('Payment Terms: Invoices are due within 15 days of receipt. Milestone-based:', bold=True, font_size=11, font_family='Inter')
insert_text('• 50% upon signing (€25,000) — covers Phase 1 and initiation of Phase 2. Secures resource allocation and enables immediate project kickoff.', font_size=11, font_family='Inter')
insert_text('• 50% upon delivery of brand book (€25,000) — due upon completion and delivery of Phase 2, subject to eToro\'s written approval per MSA Section 1.3.', font_size=11, font_family='Inter')
insert_line()
insert_text('')

# Expenses
insert_text('EXPENSES & OPERATIONAL COSTS', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('All operational expenses incurred during the project shall be borne entirely by eToro: API calls, software licenses, typography/font licensing, image rights, domain costs, hosting, and other third-party fees. Itemized reporting provided upon request.', font_size=11, font_family='Inter')
insert_line()
insert_text('')

# IP Section
insert_text('IP & SYSTEM OWNERSHIP', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('Intellectual Property & System Ownership', bold=True, font_size=18, font_family='Inter')
insert_text('The production system operates on a licensed model: eToro interacts through the brand interface layer (brand inputs → brand outputs), while the underlying engine remains Curious Endeavor\'s intellectual property.', font_size=11, font_family='Inter')
insert_text('')

insert_text('eToro Owns Outright:', bold=True, font_size=12, font_family='Inter')
insert_text('• All brand assets, design system, and visual output produced', font_size=11, font_family='Inter')
insert_text('• Visual language, iconography, and all design deliverables', font_size=11, font_family='Inter')
insert_text('• Brand book and all brand documentation', font_size=11, font_family='Inter')
insert_text('• All content and creative output generated through the system', font_size=11, font_family='Inter')
insert_text('• Full right to use, modify, and extend all output for any purpose', font_size=11, font_family='Inter')
insert_text('')

insert_text('Curious Endeavor Retains Ownership:', bold=True, font_size=12, font_family='Inter')
insert_text('• AI agent architecture, configurations, and prompt engineering', font_size=11, font_family='Inter')
insert_text('• All system configuration files, setup, and technical infrastructure', font_size=11, font_family='Inter')
insert_text('• Custom prompts, prompt templates, and prompt logic', font_size=11, font_family='Inter')
insert_text('• Production workflow logic and automation systems', font_size=11, font_family='Inter')
insert_text('• Core methodology, frameworks, and strategic approach', font_size=11, font_family='Inter')
insert_text('• Proprietary tools, templates, and base systems', font_size=11, font_family='Inter')
insert_text('• Discord server structure, roles, channels, and bot configurations', font_size=11, font_family='Inter')
insert_text('• Training methods and operational playbooks', font_size=11, font_family='Inter')
insert_text('')

insert_text('Perpetual Operating License', bold=True, font_size=14, font_family='Inter')
insert_text('eToro receives a perpetual, non-exclusive, non-transferable license to operate the production system for eToro brand purposes.', font_size=11, font_family='Inter')
insert_text('')

insert_text('eToro May:', bold=True, font_size=11, font_family='Inter', color='#28a745')
insert_text('• Operate the production system day-to-day for eToro brand work', font_size=11, font_family='Inter')
insert_text('• Modify their brand book and design system at will — the system adapts accordingly', font_size=11, font_family='Inter')
insert_text('• Update brand guidelines (colors, fonts, tone, imagery) and design tokens', font_size=11, font_family='Inter')
insert_text('• Prompt the system to create brand assets, campaigns, and content', font_size=11, font_family='Inter')
insert_text('• Evolve the brand over time — all brand-level changes fully within eToro\'s control', font_size=11, font_family='Inter')
insert_text('• Use the system for the eToro brand as defined in this SOW', font_size=11, font_family='Inter')
insert_text('')

insert_text('eToro May Not:', bold=True, font_size=11, font_family='Inter', color='#cc0000')
insert_text('• Access, extract, or inspect the underlying agent architecture, prompts, or workflow logic', font_size=11, font_family='Inter')
insert_text('• Duplicate, replicate, or adapt the system for other brands or purposes beyond this SOW', font_size=11, font_family='Inter')
insert_text('• Share, sublicense, or allow third parties to study, copy, or reverse-engineer the system', font_size=11, font_family='Inter')
insert_text('• Hire third parties to modify the agent layer, workflow logic, or system architecture', font_size=11, font_family='Inter')
insert_text('• Reverse-engineer the methodology to build a competing or derivative system', font_size=11, font_family='Inter')
insert_text('')

insert_text('System-Level Modifications: Any modifications to agent architecture, workflow logic, or system capabilities require engagement with Curious Endeavor. CE holds exclusive implementation rights for the system layer throughout the engagement and for 12 months following completion.', font_size=11, font_family='Inter')
insert_text('')
insert_text('Scope: The license is scoped to brand output operations for eToro. The system is delivered as a working production environment — not as transferable source code or documentation of its inner workings.', font_size=11, font_family='Inter')
insert_text('')
insert_text('Note on Fonts: Existing eToro typography will be maintained. Font licensing remains eToro\'s responsibility per MSA Section 4.', italic=True, font_size=10, font_family='Inter', color='#999999')
insert_line()
insert_text('')

# PR Rights
insert_text('PR RIGHTS & DOCUMENTATION', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('')
insert_text('Curious Endeavor May Freely Share:', bold=True, font_size=11, font_family='Inter', color='#28a745')
insert_text('• Our process, methodology, and tools (e.g. "how we use AI agents in a rebrand")', font_size=11, font_family='Inter')
insert_text('• Behind-the-scenes workflow on social media, blogs, and content channels', font_size=11, font_family='Inter')
insert_text('• Screenshots of our own tools, dashboards, and internal systems', font_size=11, font_family='Inter')
insert_text('• General descriptions (e.g. "working with a major fintech on brand transformation")', font_size=11, font_family='Inter')
insert_text('• Visual work samples (design directions, moodboards) excluding logo and unreleased final assets', font_size=11, font_family='Inter')
insert_text('• Non-confidential, post-launch work samples in our portfolio and website', font_size=11, font_family='Inter')
insert_text('• Speaking at conferences, podcasts, or events using our own process materials', font_size=11, font_family='Inter')
insert_text('')
insert_text('Requires eToro Prior Written Approval:', bold=True, font_size=11, font_family='Inter', color='#cc0000')
insert_text('• Use of eToro\'s name or logo in press releases or marketing campaigns', font_size=11, font_family='Inter')
insert_text('• Publishing unreleased or in-progress brand assets', font_size=11, font_family='Inter')
insert_text('• Sharing eToro\'s internal or confidential materials', font_size=11, font_family='Inter')
insert_text('• Formal case studies featuring eToro by name with detailed project specifics', font_size=11, font_family='Inter')
insert_text('• Media interviews or articles that reference eToro directly', font_size=11, font_family='Inter')
insert_text('')
insert_text('Approval shall not be unreasonably withheld. Both parties will coordinate public communications to align with eToro\'s PR timelines.', font_size=11, font_family='Inter')
insert_text('')
insert_text('Credit: Where eToro publicly references this brand transformation, eToro agrees to credit Curious Endeavor as the strategic partner, including crediting Dan Peguine and Assaf Dagan by name.', font_size=11, font_family='Inter')
insert_line()
insert_text('')

# Timeline Impact
insert_text('TIMELINE & APPROVAL IMPACT', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('All timelines assume client feedback within response windows defined in MSA Section 4. Any delays in client response extend delivery timelines day-for-day.', font_size=11, font_family='Inter')
insert_text('')
insert_text('Example: if a deliverable is submitted Day 1 and eToro provides feedback Day 10, the timeline shifts by 8 business days (10 minus the 2-day SLA).', italic=True, font_size=11, font_family='Inter', color='#666666')
insert_line()
insert_text('')

# SLAs
insert_text('SERVICE LEVEL AGREEMENTS', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('')
insert_text('Day-to-day requests:  CE 1 business day  |  eToro 2 business days', font_size=11, font_family='Inter')
insert_text('New/unanticipated requests:  CE 1 business day  |  eToro 4 business days', font_size=11, font_family='Inter')
insert_text('Design validation / approval:  eToro 10 business days', font_size=11, font_family='Inter')
insert_text('')
insert_text('Working days: Monday–Friday. Weekends and public holidays excluded.', italic=True, font_size=10, font_family='Inter', color='#999999')
insert_line()
insert_text('')

# Governance
insert_text('GOVERNANCE', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('• Project Contacts: Each party designates a primary contact for day-to-day decisions and approvals.', font_size=11, font_family='Inter')
insert_text('• Weekly Check-ins: 30-minute recurring sync between Project Contacts.', font_size=11, font_family='Inter')
insert_text('• Communication: Dedicated Discord workspace as primary collaboration channel.', font_size=11, font_family='Inter')
insert_text('• Escalation: Issues unresolved at contact level within 3 business days escalate to senior leadership.', font_size=11, font_family='Inter')
insert_line()
insert_text('')

# Liability
insert_text('LIABILITY', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('Governed by the Master Services Agreement, Sections 10 and 12. Neither party liable for indirect, incidental, or consequential damages. Total liability capped at amounts paid under this SOW.', font_size=11, font_family='Inter')
insert_text('')
insert_text('')

# Signatures
insert_text('SIGNATURES', bold=True, font_size=10, font_family='JetBrains Mono', color='#cc0000')
insert_text('')
insert_text('Curious Endeavor LLC', bold=True, font_size=14, font_family='Inter')
insert_text('Name: ____________________________    Title: ____________________________', font_size=11, font_family='Inter')
insert_text('Signature: ________________________    Date: _____________________________', font_size=11, font_family='Inter')
insert_text('')
insert_text('eToro', bold=True, font_size=14, font_family='Inter')
insert_text('Name: ____________________________    Title: ____________________________', font_size=11, font_family='Inter')
insert_text('Signature: ________________________    Date: _____________________________', font_size=11, font_family='Inter')
insert_text('')
insert_text('')
insert_text('Creativity is a curious and unexpected endeavor.', italic=True, font_size=10, font_family='Inter', color='#cc0000')

# 2. Apply all formatting
# Split into batches of 50 to avoid API limits
batch_size = 50
for i in range(0, len(reqs), batch_size):
    batch = reqs[i:i+batch_size]
    r = requests.post(f'https://docs.googleapis.com/v1/documents/{doc_id}:batchUpdate',
        headers=headers, json={'requests': batch})
    if r.status_code != 200:
        print(f'Batch {i} error: {r.text[:200]}')
        break

# 3. Set page margins
margin_reqs = [{
    'updateDocumentStyle': {
        'documentStyle': {
            'marginTop': {'magnitude': 72, 'unit': 'PT'},
            'marginBottom': {'magnitude': 72, 'unit': 'PT'},
            'marginLeft': {'magnitude': 72, 'unit': 'PT'},
            'marginRight': {'magnitude': 72, 'unit': 'PT'},
        },
        'fields': 'marginTop,marginBottom,marginLeft,marginRight'
    }
}]
r = requests.post(f'https://docs.googleapis.com/v1/documents/{doc_id}:batchUpdate',
    headers=headers, json={'requests': margin_reqs})

# 4. Share with Assaf
drive_headers = {'Authorization': f'Bearer {access_token}', 'Content-Type': 'application/json'}
for email in ['assafdagan@gmail.com', 'assaf@curiousendeavor.com']:
    r = requests.post(f'https://www.googleapis.com/drive/v3/files/{doc_id}/permissions',
        headers=drive_headers,
        json={'type': 'user', 'role': 'writer', 'emailAddress': email})

print(f"\nDone! Shared with Assaf.")
print(f"https://docs.google.com/document/d/{doc_id}/edit")
