class Coolsms::Finder

Public Class Methods

new(conditions_hash = {}) click to toggle source
# File lib/coolsms/finder.rb, line 3
def initialize(conditions_hash = {})
  @attributes = conditions_hash.with_indifferent_access
end

Public Instance Methods

__dupp()
Alias for: dup
api() click to toggle source
# File lib/coolsms/finder.rb, line 11
def api
  @api = Coolsms::RestApi::Sent.new
  @api.count = attributes[:per]
  @api.page = attributes[:page]
  @api.rcpt = attributes[:recipient_number]
  @api.start = attributes[:accepted_from]
  @api.end = attributes[:accepted_to]
  @api.status = attributes[:status]
  @api.resultcode = attributes[:result_code]
  @api.notin_resultcode = attributes[:not_in_result_code]
  @api.mid = attributes[:message_id]
  @api.gid = attributes[:group_id]
  @api
end
data() click to toggle source
# File lib/coolsms/finder.rb, line 36
def data; self[:data] end
dup() click to toggle source
# File lib/coolsms/finder.rb, line 50
def dup
  duplicated = __dupp
  duplicated.instance_variable_set(:@response, nil)
  duplicated.instance_variable_set(:@retrieved, nil)
  duplicated
end
Also aliased as: __dupp
has_next?() click to toggle source
# File lib/coolsms/finder.rb, line 41
def has_next?
  (((page - 1) * list_count) + data.size) < total_count
end
has_prev?() click to toggle source
# File lib/coolsms/finder.rb, line 45
def has_prev?
  page > 1
end
list_count() click to toggle source
# File lib/coolsms/finder.rb, line 37
def list_count; self[:list_count] end
next_page() click to toggle source
# File lib/coolsms/finder.rb, line 57
def next_page
  finder = self.dup
  finder.page = page + 1
  finder
end
page() click to toggle source
# File lib/coolsms/finder.rb, line 39
def page; self[:page] end
page=(num) click to toggle source
# File lib/coolsms/finder.rb, line 7
def page=(num)
  attributes[:page] = num
end
retrieve() click to toggle source
Calls superclass method Coolsms::Base#retrieve
# File lib/coolsms/finder.rb, line 26
def retrieve
  @response = api.call
  attributes.update(@response.body.with_indifferent_access)
  attributes[:data].map! do |msg_hash|
    msg_hash[:id] = msg_hash.delete(:message_id)
    Coolsms::Message.new(msg_hash)
  end
  super
end
total_count() click to toggle source
# File lib/coolsms/finder.rb, line 38
def total_count; self[:total_count] end