Module: Tuiter::StatusMethods

Included in:
Client
Defined in:
lib/tuiter/methods/status.rb

Instance Method Summary collapse

Instance Method Details

#statuses_mentions(options = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/tuiter/methods/status.rb', line 35

def statuses_mentions(options = {})
  query = "/statuses/mentions.json"
  if options[:since]
    params = "?since=#{options[:since]}"
  elsif options[:since_id]
    params = "?since_id=#{options[:since_id]}"
  else
    params = ""
  end
  if options[:page]
    if params == ""
        params = "?page=#{options[:page]}"
    else
        params = params + "&" + "page=#{options[:page]}"
    end
  end
  if res = @request_handler.get(query+params).body
    data = JSON.parse(res)
    return data.map { |d| Tuiter::Status.new(d) }
  else
    return nil
  end
end

#statuses_show(id) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/tuiter/methods/status.rb', line 14

def statuses_show(id)
  if res = @request_handler.get("/statuses/show/#{id}.json").body
    return Tuiter::Status.new(JSON.parse(res))
  else
    return nil
  end
end

#statuses_update(status, in_reply_to_status_id = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tuiter/methods/status.rb', line 22

def statuses_update(status, in_reply_to_status_id = nil)
  log("update() sending: #{status}")
  res = @request_handler.post('/statuses/update.json', {'status' => status, 'in_reply_to_status_id' => in_reply_to_status_id })
  case res
  when Net::HTTPSuccess, Net::HTTPRedirection
    log("update() success: OK")
    return res # OK
  else
    log("update() error: #{res.to_s}")
    res.error!
  end
end