Module: CenitClient::Client

Defined in:
lib/cenit_client/client.rb

Defined Under Namespace

Classes: PushApiError

Class Method Summary collapse

Class Method Details

.destroy(resource, id, options = self.configuration) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cenit_client/client.rb', line 26

def self.destroy(resource,id, options=self.configuration)

  res = HTTParty.delete(
      options[:push_url] + "/#{resource}/#{id}",
      {
          headers: {
              'Content-Type'       => 'application/json',
              'X-Hub-Store'        => options[:connection_id],
              'X-Hub-Access-Token' => options[:connection_token],
              'X-Hub-Timestamp'    => Time.now.utc.to_i.to_s
          }
      }
  )
  validate(res)
  res
end

.index(resource, options = self.configuration) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/cenit_client/client.rb', line 60

def self.index(resource, options=self.configuration)

  res = HTTParty.get(
      options[:push_url] + "/#{resource}",
      {
          headers: {
              'Content-Type'       => 'application/json',
              'X-Hub-Store'        => options[:connection_id],
              'X-Hub-Access-Token' => options[:connection_token],
              'X-Hub-Timestamp'    => Time.now.utc.to_i.to_s
          }
      }
  )
  validate(res)
  res.body
end

.push(json_payload, options = self.configuration) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cenit_client/client.rb', line 8

def self.push(json_payload, options=self.configuration)

  res = HTTParty.post(
    options[:push_url],
      {
        body: json_payload,
        headers: {
         'Content-Type'       => 'application/json',
         'X-Hub-Store'        => options[:connection_id],
         'X-Hub-Access-Token' => options[:connection_token],
         'X-Hub-Timestamp'    => Time.now.utc.to_i.to_s
        }
      }
  )
  validate(res)
  res
end

.show(resource, id, options = self.configuration) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cenit_client/client.rb', line 43

def self.show(resource,id, options=self.configuration)

  res = HTTParty.get(
      options[:push_url] + "/#{resource}/#{id}",
      {
          headers: {
              'Content-Type'       => 'application/json',
              'X-Hub-Store'        => options[:connection_id],
              'X-Hub-Access-Token' => options[:connection_token],
              'X-Hub-Timestamp'    => Time.now.utc.to_i.to_s
          }
      }
  )
  validate(res)
  res.body
end