Class: Cronjob::Requests

Inherits:
Object
  • Object
show all
Defined in:
lib/cronjob/requests/requests.rb

Direct Known Subclasses

Create, Delete, Edit, List, Ping, Show

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#responseObject

Returns the value of attribute response.



3
4
5
# File 'lib/cronjob/requests/requests.rb', line 3

def response
  @response
end

Instance Method Details

#clientObject



5
6
7
# File 'lib/cronjob/requests/requests.rb', line 5

def client
  Client.new.conn
end

#execute(method, endpoint, args) ⇒ Object



15
16
17
18
19
# File 'lib/cronjob/requests/requests.rb', line 15

def execute(method, endpoint, args)
  args[:auth_token] = Cronjob.configuration.token
  data = client.send(method, endpoint, args)
  parse(data.body)
end

#parse(data) ⇒ Object



9
10
11
12
13
# File 'lib/cronjob/requests/requests.rb', line 9

def parse(data)
  JSON.parse(data)
  rescue JSON::ParserError => e
    data
end