class PortaText::Command::Api::Summary

The summary endpoint. github.com/PortaText/docs/wiki/REST-API#api_summary

Author

Marcelo Gornstein (marcelog@portatext.com)

Copyright

Copyright © 2015 PortaText

License

Apache-2.0

Public Instance Methods

by_day() click to toggle source
# File lib/portatext/command/api/summary.rb, line 23
def by_day
  set :granularity, 'date'
end
by_month() click to toggle source
# File lib/portatext/command/api/summary.rb, line 27
def by_month
  set :granularity, 'month'
end
by_week() click to toggle source
# File lib/portatext/command/api/summary.rb, line 31
def by_week
  set :granularity, 'week'
end
endpoint(_method) click to toggle source

rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize

# File lib/portatext/command/api/summary.rb, line 37
def endpoint(_method)
  qs = {}
  unless @args[:date_from].nil?
    qs[:date_from] = @args[:date_from]
    @args.delete :date_from
  end
  unless @args[:date_to].nil?
    qs[:date_to] = @args[:date_to]
    @args.delete :date_to
  end
  unless @args[:granularity].nil?
    qs[:granularity] = @args[:granularity]
    @args.delete :granularity
  end
  unless qs.empty?
    qs = URI.encode_www_form qs
    return "summary?#{qs}"
  end

  'summary'
end
from(date) click to toggle source
# File lib/portatext/command/api/summary.rb, line 15
def from(date)
  set :date_from, date
end
save_to(file) click to toggle source
# File lib/portatext/command/api/summary.rb, line 19
def save_to(file)
  set :accept_file, file
end
to(date) click to toggle source
# File lib/portatext/command/api/summary.rb, line 11
def to(date)
  set :date_to, date
end