Class: CloudWaba::Utils

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/cloud_waba/utils.rb

Class Method Summary collapse

Class Method Details

.import_config(app_id:, app_secret:, phone_number_id:, business_account_id:, access_token:, api_version:) ⇒ Object



19
20
21
22
23
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/cloud_waba/utils.rb', line 19

def self.import_config(app_id:, app_secret:, phone_number_id:, business_account_id:, access_token:, api_version:)
  Dotenv.load

  base_url = ENV.fetch("WA_BASE_URL", "https://graph.facebook.com")
  app_id = app_id || ENV.fetch("M4D_APP_ID", "")
  app_secret = app_secret || ENV.fetch("M4D_APP_SECRET", "")
  phone_number_id = phone_number_id || ENV.fetch("WA_PHONE_NUMBER_ID", "")
   =  || ENV.fetch("WA_BUSINESS_ACCOUNT_ID", "")
  access_token = access_token || ENV.fetch("CLOUD_API_ACCESS_TOKEN", "")
  api_version = api_version || ENV.fetch("CLOUD_API_VERSION", "v16.0")

  validate_config!(
    app_id: app_id,
    app_secret: app_secret,
    phone_number_id: phone_number_id,
    business_account_id: ,
    access_token: access_token
  )

  ::CloudWaba::Models::Config.new(
    base_url: base_url,
    app_id: app_id,
    app_secret: app_secret,
    phone_number_id: phone_number_id,
    business_account_id: ,
    api_version: api_version,
    access_token: access_token
  )
end