Module: UniOne::Client::Webhook

Included in:
UniOne::Client
Defined in:
lib/unione/client/webhook.rb

Instance Method Summary collapse

Instance Method Details

#delete_webhook(url) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/unione/client/webhook.rb', line 49

def delete_webhook(url)
  params = { url: url }
  post 'webhook/delete.json', params
  validate_response({'type' => 'object', 'required' => ['status'], 'properties' => {
     'status' => {'type' => 'string'}
   }})
end

#get_webhook(url) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/unione/client/webhook.rb', line 14

def get_webhook(url)
  params = { url: url }
  post 'webhook/get.json', params
  get_webhook_schema = remove_fields_from_schema(webhook_schema, ['delivery_info', 'single_event'])
  validate_response({'type' => 'object', 'required' => ['status', 'object'], 'properties' => {
     'status' => {'type' => 'string'},
     'object' => get_webhook_schema
   }})
end

#list_webhooks(limit, offset) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/unione/client/webhook.rb', line 24

def list_webhooks(limit, offset)
  params = { limit: limit, offset: offset }
  post 'webhook/list.json', params
  validate_response({
    'type' => 'object', 'required' => ['status', 'objects'], 'properties' => {
      'status' => {'type' => 'string'},
      'objects' =>
      {'items' =>
       {'type' => 'object', 'required' => ['id', 'url', 'status', 'updated_at', 'events', 'event_format', 'delivery_info', 'single_event', 'max_parallel'], 'properties' => [
        'id' => {'type' => 'integer'},
        'url' => {'type' => 'string'},
        'status' => {'type' => 'string'},
        'updated_at' => {'type' => 'string'},
        'events' =>
        {'type' => 'object', 'required' => ['email_status', 'spam_block'], 'properties' => [
         'email_status' => {'items' => {'type' => 'string'}},
         'spam_block' => {'items' => {'type' => 'string'}}]},
        'event_format' => {'type' => 'string'},
        'delivery_info' => {'type' => 'integer'},
        'single_event' => {'type' => 'integer'},
        'max_parallel' => {'type' => 'integer'}
        ]}}}
  })
end

#set_webhook(webhook) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/unione/client/webhook.rb', line 6

def set_webhook(webhook)
  post 'webhook/set.json', webhook
  validate_response({'type' => 'object', 'required' => ['status', 'object'], 'properties' => {
     'status' => {'type' => 'string'},
     'object' => webhook_schema
   }})
end