Class: Mock::Twilio::Schemas::BrandsRegistrationsA2p

Inherits:
Object
  • Object
show all
Defined in:
lib/mock/twilio/schemas/brands_registrations_a2p.rb

Constant Summary collapse

@@scheduler =
Rufus::Scheduler.new

Class Method Summary collapse

Class Method Details

.brand_sid(body) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/mock/twilio/schemas/brands_registrations_a2p.rb', line 34

def brand_sid(body)
  prefix = "BN"
  sid = prefix + SecureRandom.hex(16)
  @@scheduler.in '2s' do
    response = Mock::Twilio::Webhooks::Brands.trigger(sid, "unverified")
    response = if response.status == 200
                 Mock::Twilio::Webhooks::Brands.trigger(sid, "verified")
               end
  end
  body["sid"] = sid
end

.for(body, request) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mock/twilio/schemas/brands_registrations_a2p.rb', line 10

def for(body, request)
  body["date_updated"] = Time.current.rfc2822 if body["date_updated"]
  body["date_created"] = Time.current.rfc2822 if body["date_created"]

  brand_sid(body) if body["sid"]
  body["account_sid"] = ::Twilio.  if body["account_sid"]
  body["customer_profile_bundle_sid"] = request.data["CustomerProfileBundleSid"] if body["customer_profile_bundle_sid"]
  body["a2p_profile_bundle_sid"] = request.data["A2PProfileBundleSid"] if body["a2p_profile_bundle_sid"]
  body["brand_type"] = request.data["BrandType"] if body["brand_type"]
  body["account_sid"] = ::Twilio.  if body["account_sid"]

  body["status"] = "PENDING" if body["status"]
  body["brand_score"] = 100 if body["brand_score"]
  body["identity_status"] = "SELF_DECLARED" if body["identity_status"]
  body["tcr_id"] = "BXXXXXX" if body["tcr_id"]
  body["tax_exempt_status"] = "501c3" if body["tax_exempt_status"]

  body["errors"] = nil if body["errors"]
  body["failure_reason"] = nil if body["failure_reason"]
  body["links"] = { "brand_vettings": "http://example.com", "brand_registration_otps": "http://example.com" } if body["links"]

  body
end