Module: YandexApiDirect
- Defined in:
- lib/yandex-api-direct.rb,
lib/yandex-api-direct/yandex_object.rb,
lib/yandex-api-direct/yandex_objects/client.rb,
lib/yandex-api-direct/yandex_objects/generic.rb,
lib/yandex-api-direct/yandex_objects/campaign.rb,
lib/yandex-api-direct/yandex_objects/campaign_param.rb,
lib/yandex-api-direct/yandex_objects/campaign_stats.rb
Defined Under Namespace
Modules: YandexObject Classes: Campaign, CampaignParams, CampaignStats, Client, Generic, YandexAuthorizationError, YandexConnectionError, YandexError, YandexMethodError
Constant Summary collapse
- URLS =
{ production: "https://soap.direct.yandex.ru/json-api/v4/", #production url sandbox: "https://api-sandbox.direct.yandex.ru/json-api/v4/" #sandbox url }
Class Method Summary collapse
-
.config ⇒ Object
Get config for requset params build.
-
.config=(conf) ⇒ Object
Set config values.
-
.default_config ⇒ Object
default config for Yandex API * locale (language of api response) * * “uk” - Ukraine * * “ru” - Russian * * “en” - English.
-
.env ⇒ Object
Return current environment Uses RACK_ENV and RAILS_ENV - if not set any default is used “development”.
-
.url(environment = nil) ⇒ Object
Get URL for all requests to Yandex api * without parameter - Choose url by ENV * with parameter * * “test” - choose sandbox * * other - choose production.
Class Method Details
.config ⇒ Object
Get config for requset params build
57 58 59 |
# File 'lib/yandex-api-direct.rb', line 57 def self.config @config end |
.config=(conf) ⇒ Object
Set config values
52 53 54 |
# File 'lib/yandex-api-direct.rb', line 52 def self.config= conf @config = default_config.merge!(conf) end |
.default_config ⇒ Object
default config for Yandex API
-
locale (language of api response)
-
“uk” - Ukraine
-
-
“ru” - Russian
-
-
“en” - English
-
40 41 42 43 44 45 46 47 |
# File 'lib/yandex-api-direct.rb', line 40 def self.default_config { locale: "uk", application_id: "", login: "", access_token: "", } end |
.env ⇒ Object
Return current environment Uses RACK_ENV and RAILS_ENV - if not set any default is used “development”
16 17 18 |
# File 'lib/yandex-api-direct.rb', line 16 def self.env ["test"].include?(ENV['RACK_ENV'] || ENV['RAILS_ENV'] || "development") ? :sandbox : :production end |
.url(environment = nil) ⇒ Object
Get URL for all requests to Yandex api
-
without parameter - Choose url by ENV
-
with parameter
-
“test” - choose sandbox
-
-
other - choose production
-
25 26 27 28 29 30 31 32 33 |
# File 'lib/yandex-api-direct.rb', line 25 def self.url environment = nil if environment @url = URLS[environment.to_sym] elsif @url @url else @url = URLS[env] end end |