Class: FeishuNotifier::Config
- Inherits:
-
Data
- Object
- Data
- FeishuNotifier::Config
- Defined in:
- lib/feishu_notifier/config.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
"https://open.feishu.cn".freeze
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#app_secret ⇒ Object
readonly
Returns the value of attribute app_secret.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Class Method Summary collapse
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id
2 3 4 |
# File 'lib/feishu_notifier/config.rb', line 2 def app_id @app_id end |
#app_secret ⇒ Object (readonly)
Returns the value of attribute app_secret
2 3 4 |
# File 'lib/feishu_notifier/config.rb', line 2 def app_secret @app_secret end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url
2 3 4 |
# File 'lib/feishu_notifier/config.rb', line 2 def base_url @base_url end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id
2 3 4 |
# File 'lib/feishu_notifier/config.rb', line 2 def user_id @user_id end |
Class Method Details
.fetch_required(env, key) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/feishu_notifier/config.rb', line 14 def self.fetch_required(env, key) value = env[key].to_s.strip raise ArgumentError, "Missing required environment variable: #{key}" if value.empty? value end |
.from_env(env = ENV) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/feishu_notifier/config.rb', line 5 def self.from_env(env = ENV) new( app_id: fetch_required(env, "FEISHU_APP_ID"), app_secret: fetch_required(env, "FEISHU_APP_SECRET"), user_id: fetch_required(env, "FEISHU_USER_ID"), base_url: env.fetch("FEISHU_BASE_URL", DEFAULT_BASE_URL) ) end |