Class: Posterrrrous

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/posterrrrous.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.emailObject

Returns the value of attribute email


10
11
12
# File 'lib/posterrrrous.rb', line 10

def email
  @email
end

.passwordObject

Returns the value of attribute password


10
11
12
# File 'lib/posterrrrous.rb', line 10

def password
  @password
end

Class Method Details

.method_missing(method_sym, *arguments, &block) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/posterrrrous.rb', line 13

def self.method_missing(method_sym, *arguments, &block)
  attributes = arguments.pop

  options = {
    :query => attributes,
    :basic_auth  =>  {
      :username => email,
      :password => password
    }
  }

  response = get "/#{method_sym}", options
  response = response["rsp"]

  status = response.delete('stat')
  if status != "ok"
    error = response['err']
    raise "Posterous Error #{error['code']}: #{error['msg']}"
  else
    response.values.first
  end
end