class Itch::Purchases

Return purchase history and history by date

Public Class Methods

new(agent) click to toggle source
# File lib/itch/purchases.rb, line 15
def initialize(agent)
  @agent = agent
end

Public Instance Methods

history() click to toggle source
# File lib/itch/purchases.rb, line 27
def history
  fetch_csv Itch::URL::PURCHASES_CSV
end
history_by_month(month, year) click to toggle source
# File lib/itch/purchases.rb, line 19
def history_by_month(month, year)
  fetch_csv format(Itch::URL::MONTH_PURCHASES_CSV, month: month, year: year)
end
history_by_year(year) click to toggle source
# File lib/itch/purchases.rb, line 23
def history_by_year(year)
  fetch_csv format(Itch::URL::YEAR_PURCHASES_CSV, year: year)
end

Protected Instance Methods

fetch_csv(url) click to toggle source
# File lib/itch/purchases.rb, line 33
def fetch_csv(url)
  page = with_login do
    @agent.get(url)
  end

  validate_response(page, action: "fetching purchase CSV", content_type: "text/csv")

  CSV.new(page.content, headers: true)
end