Class: RIPE::HTTPRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/ripe/http_request.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, object_type) ⇒ HTTPRequest

Returns a new instance of HTTPRequest.



9
10
11
12
# File 'lib/ripe/http_request.rb', line 9

def initialize(client, object_type)
  @client = client
  @object_type = object_type
end

Instance Method Details

#create(password, object_hash) ⇒ Object



19
20
21
22
# File 'lib/ripe/http_request.rb', line 19

def create(password, object_hash)
  json = request(Net::HTTP::Post, '', :query => {:password => password}, :json => object_hash.to_json)
  json.dig('objects', 'object').first
end

#delete(password, key, reason = nil) ⇒ Object



29
30
31
# File 'lib/ripe/http_request.rb', line 29

def delete(password, key, reason = nil)
  request(Net::HTTP::Delete, "/#{key}", :query => {:password => password, :reason => reason})
end

#lookup(key) ⇒ Object



14
15
16
17
# File 'lib/ripe/http_request.rb', line 14

def lookup(key)
  json = request(Net::HTTP::Get, "/#{key}")
  json.dig('objects', 'object').first
end

#update(password, key, object_hash) ⇒ Object



24
25
26
27
# File 'lib/ripe/http_request.rb', line 24

def update(password, key, object_hash)
  json = request(Net::HTTP::Put, "/#{key}", :query => {:password => password}, :json => object_hash.to_json)
  json.dig('objects', 'object').first
end