تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
ويتم إكمال عملية الإعداد باستخدام فئة Config. يمكنك الوصول إلى هذا الصف بعدة طرق
مثل كتابة ملف تهيئة، أو تحديد القيم عند الإنشاء، أو
تحميل القيم من متغيرات البيئة.
عندئذٍ، ستبدو المكتبة في الموقع المحدد
متغيّر بيئة واحد (GOOGLE_ADS_CONFIGURATION_FILE_PATH) إذا كان هذا المتغير
لم يتم ضبطه، فستبحث المكتبة في دليل HOME عن الملف.
حقول التسجيل: راجِع دليل التسجيل للحصول على التفاصيل الكاملة.
log_level: الحد الأدنى للرسائل على مستوى السجلّ التي تريد تسجيلها. على سبيل المثال:
سيؤدي تحديد 'DEBUG' إلى ضمان عرض جميع رسائل السجل وتحديد
سيستبعد 'INFO' رسائل "تصحيح الأخطاء" ولكنه يعرض جميع الرسائل الأخرى.
log_target: المكان الذي تريد تسجيل الدخول إليه، مثل STDERR
logger: تحديد المسجّل الخاص بك سيؤدي تحديد ذلك إلى إلغاء الإجراءَين
"log_level" وlog_target"
متغيرات البيئة
يمكنك ضبط مكتبة البرامج باستخدام متغيّرات البيئة. لا يتم تضمينها
محملة بشكل افتراضي، وتتطلب اتصالاً إضافيًا بعد إنشاء مثيل
من أجل التحميل. اطّلِع على القائمة الكاملة لمتغيّرات البيئة.
مدعوم من الكل
اللغات.
لتحميل متغيّرات البيئة في Config، يمكنك استدعاء load_environment_config على النحو التالي:
في كل مرة يتم فيها استدعاء ذلك، تصبح الحالة الحالية لمتغيرات البيئة
استبدال أي عنصر متوفّر حاليًا في Config مع هذا
فيمكنك على سبيل المثال الحصول على تهيئة افتراضية ولكن مع إلغاء إعدادات
باستخدام متغيرات البيئة، أو يمكنك تكوينها بالكامل باستخدام
والمتغيرات البيئية.
بالإضافة إلى متغيرات البيئة التي تدعمها جميع المكتبات، تستخدم واجهة برمجة تطبيقات Ruby
مكتبة على متغيرين إضافيين:
GOOGLE_ADS_RUBY_LOG_LEVEL: كما ذكرت "log_level" أعلاه
تاريخ التعديل الأخير: 2025-08-21 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-21 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eGoogle Ads API configuration is handled by a \u003ccode\u003eConfig\u003c/code\u003e class, modifiable via configuration files, dynamic settings, or environment variables.\u003c/p\u003e\n"],["\u003cp\u003eYou can provide a \u003ccode\u003egoogle_ads_config.rb\u003c/code\u003e file path directly, set it using the \u003ccode\u003eGOOGLE_ADS_CONFIGURATION_FILE_PATH\u003c/code\u003e environment variable, or the library defaults to your home directory.\u003c/p\u003e\n"],["\u003cp\u003eDynamic configuration allows setting or updating values using blocks when instantiating or after creating the \u003ccode\u003eGoogle::Ads::GoogleAds::GoogleAdsClient\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eEnvironment variables offer another configuration approach, loaded by calling \u003ccode\u003eload_environment_config\u003c/code\u003e on the client instance, overriding existing settings.\u003c/p\u003e\n"],["\u003cp\u003eSupported configuration fields include OAuth credentials, developer token, login customer ID, logging preferences, and a proxy setting specific to the Ruby library.\u003c/p\u003e\n"]]],[],null,["# Configuration is done using a `Config` class. You can access this class in multiple\nways, such as writing a configuration file, specifying values on creation, or\nloading values from environment variables.\n\nConfiguration file\n------------------\n\nYou can specify a\n[`google_ads_config.rb`](https://github.com/googleads/google-ads-ruby/blob/HEAD/google_ads_config.rb)\nfile to use when instantiating the client.\n\nIf you use no arguments when instantiating: \n\n client = Google::Ads::GoogleAds::GoogleAdsClient.new\n\nthen the library will look in the location specified in the\n`GOOGLE_ADS_CONFIGURATION_FILE_PATH` environment variable. If that variable is\nnot set, then the library will look in your `HOME` directory for the file.\n\nAlternatively, you can specify a path: \n\n client = Google::Ads::GoogleAds::GoogleAdsClient.new(\"path/to/file.rb\")\n\nin which case the client will look for the file at that filepath.\n\nThe easiest way to generate this file is to copy the `google_ads_config.rb` from\nthe GitHub repository and modify it to include your refresh token, client ID,\nand client secret.\n\nDynamic configuration\n---------------------\n\nYou can set up the configuration dynamically when instantiating the library,\nor even afterwards: \n\n client = Google::Ads::GoogleAds::GoogleAdsClient.new do |config|\n config.client_id = 'INSERT_CLIENT_ID_HERE'\n # ... more configuration\n end\n\nYou can even modify the configuration after instantiation: \n\n client.configure do |config|\n config.login_customer_id = 'INSERT_LOGIN_CUSTOMER_ID_HERE'\n # ... more configuration\n end\n\nConfiguration fields\n--------------------\n\nThe `Config` object supports the following fields.\n\nGeneral fields:\n\n- `refresh_token`: Your OAuth refresh token.\n- `client_id`: Your OAuth client ID.\n- `client_secret`: Your OAuth client secret.\n- `developer_token`: Your developer token for accessing the API.\n- `login_customer_id`: See the [login-customer-id documentation](/google-ads/api/docs/concepts/call-structure#cid).\n\nLogging fields. See the [logging guide](/google-ads/api/docs/client-libs/ruby/logging) for complete details.\n\n- `log_level`: The minimum log level messages you want logged. For example, specifying `'DEBUG'` will ensure you see all log messages, and specifying `'INFO'` will exclude DEBUG messages but show all other messages.\n- `log_target`: Where you want to log to, such as `STDERR`.\n- `logger`: Specify your own custom logger. Specifying this will override both `log_level` and `log_target`.\n\nEnvironment variables\n---------------------\n\nYou can configure the client library using environment variables. They are not\nloaded by default, and require an additional call after instantiating the\nclient in order to load. See the complete list of [environment variables\nsupported by all\nlanguages](/google-ads/api/docs/client-libs#configuration).\n\nTo load the environment variables into your `Config`, call `load_environment_config`: \n\n client = Google::Ads::GoogleAds::GoogleAdsClient.new\n client.load_environment_config\n\nEach time this is called, the current state of the environment variables will\noverwrite anything that is already present in the `Config`. With this\nmechanism, you can for example have a default config but override specific\nvalues using environment variables, or you can entirely configure with\nenvironment variables.\n\nIn addition to the environment variables supported by all libraries, the Ruby\nlibrary has two additional variables:\n\n- `GOOGLE_ADS_RUBY_LOG_LEVEL`: As `log_level` above.\n- `GOOGLE_ADS_RUBY_HTTP_PROXY`: Specify an HTTP proxy."]]