Module: Developerreply

Extended by:
Developerreply
Included in:
Developerreply
Defined in:
lib/developerreply.rb,
lib/developerreply/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Instance Method Summary collapse

Instance Method Details

#create(options = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/developerreply.rb', line 40

def create(options={})
  hostname  = options[:hostname]
  url       = options[:url]
  payload   = { 
    hostname: hostname, 
    url: url,
    api_user: Developerreply.username, 
    api_key: Developerreply.password
  }

  resp = Developerreply.request.post do |req|
    req.path    = "/api/parse.set.json"
    req.body    = payload
  end

  if resp.body["error"]
    error_message = resp.body["error"]["message"] 
    raise "Unable to create hostname and url: #{error_message}"
  else
    return true
  end
end

#passwordObject



27
28
29
30
# File 'lib/developerreply.rb', line 27

def password
  return @password if @password 
  "password_required"       
end

#password=(password) ⇒ Object



20
21
22
23
24
25
# File 'lib/developerreply.rb', line 20

def password=(password)    
  @password = password     
  setup_request!
    
  @password
end

#requestObject



36
37
38
# File 'lib/developerreply.rb', line 36

def request
  @request
end

#request=(request) ⇒ Object



32
33
34
# File 'lib/developerreply.rb', line 32

def request=(request)
  @request = request
end

#usernameObject



15
16
17
18
# File 'lib/developerreply.rb', line 15

def username
  return @username if @username 
  "username_required"       
end

#username=(username) ⇒ Object



8
9
10
11
12
13
# File 'lib/developerreply.rb', line 8

def username=(username)    
  @username = username     
  setup_request!
    
  @username
end