Class: Datawow::Connector

Inherits:
Object
  • Object
show all
Defined in:
lib/datawow/connector.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(path, type, token: '', version_api: 'v1') ⇒ Connector

Returns a new instance of Connector.



13
14
15
16
17
18
19
# File 'lib/datawow/connector.rb', line 13

def initialize(path, type, token: '', version_api: 'v1')
  @version_api = version_api
  @type = type
  @path = path
  @token = token
  @method = :GET
end

Instance Method Details

#delete(data = {}, query_str = true) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/datawow/connector.rb', line 46

def delete(data = {}, query_str = true)
  @method = :DELETE
  response = send_request(data, query_str)
  body = JSON.parse response.body

  Response.new(body['data'], response.code, body['meta']['message'], body['meta'], body['meta']['total_count'])
end

#get(data = {}, query_str = true) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/datawow/connector.rb', line 30

def get(data = {}, query_str = true)
  @method = :GET
  response = send_request(data, query_str)
  body = JSON.parse response.body

  Response.new(body['data'], response.code, body['meta']['message'], body['meta'], body['meta']['total_count'])
end

#post(data = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/datawow/connector.rb', line 21

def post(data = {})
  @method = :POST
  response = send_request(data)

  body = JSON.parse response.body

  Response.new(body['data'], response.code, body['meta']['message'], body['meta'], 1)
end

#put(data = {}) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/datawow/connector.rb', line 38

def put(data = {})
  @method = :PUT
  response = send_request(data)
  body = JSON.parse response.body

  Response.new(body['data'], response.code, body['meta']['message'], body['meta'], 1)
end