Class: Mock::Twilio::Decorators::Api2010::Addresses

Inherits:
Object
  • Object
show all
Defined in:
lib/mock/twilio/decorators/api_2010/addresses.rb

Class Method Summary collapse

Class Method Details

.address_sid(body, request) ⇒ Object



29
30
31
32
33
# File 'lib/mock/twilio/decorators/api_2010/addresses.rb', line 29

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

.decorate(body, request) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mock/twilio/decorators/api_2010/addresses.rb', line 9

def decorate(body, request)
  body["date_updated"] = Time.current.rfc2822 if body["date_updated"]
  body["date_created"] = Time.current.rfc2822 if body["date_created"]
  body["account_sid"] = ::Twilio. if body["account_sid"]

  address_sid(body, request) if body["sid"]
  body["iso_country"] = "US" if body["iso_country"]
  body["city"] = request.data["City"] if body["city"]
  body["region"] = request.data["Region"] if body["region"]
  body["street"] = request.data["Street"] if body["street"]
  body["postal_code"] = request.data["PostalCode"] if body["postal_code"]
  body["friendly_name"] = request.data["FriendlyName"] if body["friendly_name"]

  body["emergency_enabled"] = false if body["emergency_enabled"]
  body["validated"] = true if body["validated"]
  body["verified"] = true if body["verified"]

  body
end