Module: Validation

Included in:
EventApi, EventTypeApi, MessageApi, ServiceApi, SubscriptionApi, UserApi
Defined in:
lib/tacklebox/apis/error.rb

Instance Method Summary collapse

Instance Method Details

#is_valid_data(data) ⇒ Object



20
21
22
# File 'lib/tacklebox/apis/error.rb', line 20

def is_valid_data(data)
  !!data
end

#is_valid_event_data(data) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/tacklebox/apis/error.rb', line 41

def is_valid_event_data(data)
  if data['eventType']
    data['event_type'] = data['eventType']
  end
  
  if data['idempotencyKey']
    data['idempotency_key'] = data['idempotencyKey']
  end
  
  (
    data['event_type'] &&
    data['event_type'].class == String &&
    data['idempotency_key'] &&
    data['idempotency_key'].class == String &&
    data['payload']
  )
end

#is_valid_id(id) ⇒ Object



16
17
18
# File 'lib/tacklebox/apis/error.rb', line 16

def is_valid_id(id)
  id && id.class == String
end

#is_valid_name(data) ⇒ Object



24
25
26
# File 'lib/tacklebox/apis/error.rb', line 24

def is_valid_name(data)
  data['name'] && data['name'].class == String
end

#is_valid_subscription_data(data) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tacklebox/apis/error.rb', line 28

def is_valid_subscription_data(data)
  if data['eventTypes']
    data['event_types'] = data['eventTypes']
  end
  
  (
    data['url'] &&
    data['url'].class == String &&
    data['event_types'] &&
    data['event_types'].length > 0
  )
end