Module: Weasyl::Messages

Defined in:
lib/weasyl/messages.rb

Overview

Helper module to fetch information about messages.

Author:

  • Maxine Michalski

Since:

  • 0.1.0

Defined Under Namespace

Classes: Summary

Class Method Summary collapse

Class Method Details

.submissions(count = 100, backtime = 0, nexttime = Time.now.to_i) ⇒ Weasyl::SubmissionList

Fetch a list of submissions for the currently logged in user returned are returned submissions. While the non-block version only returns 100 submissions at all.

Parameters:

  • count (Integer) (defaults to: 100)

    max amount of submissions returned (100)

  • backtime (Integer) (defaults to: 0)

    UNIX EPOCH, only submissions after this time are

  • nexttime (Integer) (defaults to: Time.now.to_i)

    UNIX EPOCH, only submissions before this time

Returns:

  • (Weasyl::SubmissionList)

Author:

  • Maxine Michalski

Since:

  • 0.1.0



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/weasyl/messages.rb', line 46

def self.submissions(count = 100, backtime = 0, nexttime = Time.now.to_i)
  params = { count: count, backtime: backtime, nexttime: nexttime }
  subs = nil
  loop do
    subs = fetch_subs(params)
    break if subs[:nexttime].nil? || !block_given?
    subs[:submissions].each { |s| yield s }
    params[:nexttime] = subs[:nexttime]
  end
  subs
end

.summaryWeasyl::Messages::Summary

Fetch a summary of new message counts

Returns:

Author:

  • Maxine Michalski

Since:

  • 0.1.0



29
30
31
32
# File 'lib/weasyl/messages.rb', line 29

def self.summary
  Weasyl::Messages::Summary.new(Weasyl::API.instance
    .fetch('messages/summary'))
end