Class: Mock::Twilio::Decorators::CustomerProfilesV1::Evaluations

Inherits:
Object
  • Object
show all
Defined in:
lib/mock/twilio/decorators/customer_profiles_v1/evaluations.rb

Class Method Summary collapse

Class Method Details

.decorate(body, request) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/mock/twilio/decorators/customer_profiles_v1/evaluations.rb', line 9

def decorate(body, request)
  body["date_created"] = Time.current.rfc2822 if body["date_created"]
  parse_customer_profile_sid(body, request) if body["customer_profile_sid"]
  evaluation_sid(body, request) if body["sid"]
  body["account_sid"] = ::Twilio.
  body["policy_sid"] = request.data["PolicySid"] if body["policy_sid"]
  body["status"] = "compliant" if body["status"]

  body
end

.evaluation_sid(body, request) ⇒ Object



20
21
22
23
24
# File 'lib/mock/twilio/decorators/customer_profiles_v1/evaluations.rb', line 20

def evaluation_sid(body, request)
  prefix = "EL"
  sid = prefix + SecureRandom.hex(16)
  body["sid"] = sid
end

.parse_customer_profile_sid(body, request) ⇒ Object



26
27
28
29
30
# File 'lib/mock/twilio/decorators/customer_profiles_v1/evaluations.rb', line 26

def parse_customer_profile_sid(body, request)
  uri = URI(request.url)
  customer_profile_sid = uri.path.split('/')[3].split('.').first
  body["customer_profile_sid"] = customer_profile_sid
end