<commit_before>package readmillhighlights

import (
  "fmt"
  "strconv"
  "time"
  "encoding/json"
  "bytes"
  "net/http"
)

type HighlightRequest struct {
  Highlight Highlight `json:"highlight"`
}

type HighlightLocators struct {
  Position float32 `json:"position"`
  Mid string `json:"mid"`
}

type Highlight struct {
  Content string `json:"content"`
  Position float32 `json:"position"`
  Highlighted_at time.Time `json:"highlighted_at"`
  Locators HighlightLocators `json:"locators"`
}

func (h *Highlight) prepare() {
  h.Locators = HighlightLocators{h.Position, h.Content}
  h.Highlighted_at = h.Highlighted_at.UTC()
}

func PostHighlight(highlight Highlight, readingId int, accessToken string) bool {
  uri := "https://api.readmill.com/v2/readings/" + strconv.Itoa(readingId) + "/highlights.json?access_token=" + accessToken
  fmt.Println(uri)

  highlight.prepare()
  fmt.Println(highlight)

  data, _ := json.Marshal(HighlightRequest{highlight})

  str := string(data)
  fmt.Println(str)

  reader := bytes.NewReader(data)
  //defer reader.Close()

  response, _ := http.Post(uri, "application/json", reader)
  return (response.StatusCode == 201)
}

<commit_msg>Remove debugging output<commit_after>package readmillhighlights

import (
  "strconv"
  "time"
  "encoding/json"
  "bytes"
  "net/http"
)

type HighlightRequest struct {
  Highlight Highlight `json:"highlight"`
}

type HighlightLocators struct {
  Position float32 `json:"position"`
  Mid string `json:"mid"`
}

type Highlight struct {
  Content string `json:"content"`
  Position float32 `json:"position"`
  Highlighted_at time.Time `json:"highlighted_at"`
  Locators HighlightLocators `json:"locators"`
}

func (h *Highlight) prepare() {
  h.Locators = HighlightLocators{h.Position, h.Content}
  h.Highlighted_at = h.Highlighted_at.UTC()
}

func PostHighlight(highlight Highlight, readingId int, accessToken string) bool {
  uri := "https://api.readmill.com/v2/readings/" + strconv.Itoa(readingId) + "/highlights.json?access_token=" + accessToken

  highlight.prepare()
  data, _ := json.Marshal(HighlightRequest{highlight})

  reader := bytes.NewReader(data)

  response, _ := http.Post(uri, "application/json", reader)
  return (response.StatusCode == 201)
}


{'fraction_non_alphanumeric': 0.13494191242180517, 'fraction_numerical': 0.0071492403932082215, 'mean_word_length': 4.9866310160427805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5933874', 'n_tokens_mistral': 773, 'n_tokens_neox': 729, 'n_words': 154}