ya_direct_api 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ya_direct_api.rb +2 -7
- data/lib/ya_direct_api/gateway.rb +3 -4
- data/lib/ya_direct_api/version.rb +1 -1
- data/test/lib/ya_direct_api/gateway_test.rb +7 -2
- data/test/lib/ya_direct_api_test.rb +0 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c80643945891d77d3a8a19b48161182883fc3145
|
4
|
+
data.tar.gz: 74881cb6676523b0687f15b17bf2f0b5a84726f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55eb83615dfcc37908bd05987fd331efc61d50ff3f3aa31fbe48bc2ab4720e173ac8fe3d7ad137a27c0562c4eb0311881defecc8ddc6e4921bf819f1aae0e87a
|
7
|
+
data.tar.gz: 00da71496f83cc5309b25d8a16a0081ca14d4b2b89525d749ab417371030891c51739158ee6b46f222b28d3871ff91cbc11afe0e3ad43a949f2b627cf8abb1c8
|
data/lib/ya_direct_api.rb
CHANGED
@@ -10,25 +10,20 @@ module Ya
|
|
10
10
|
class Api
|
11
11
|
attr_reader :config, :gateway, :env
|
12
12
|
|
13
|
-
def initialize(token, app_id, login, locale = 'en')
|
13
|
+
def initialize(token, app_id, login, locale = 'en', mode = :sandbox)
|
14
14
|
@config = {
|
15
15
|
token: token,
|
16
16
|
app_id: app_id,
|
17
17
|
login: login,
|
18
18
|
locale: locale
|
19
19
|
}
|
20
|
-
@
|
21
|
-
@gateway = Ya::Direct::Gateway.new(@env, @config)
|
20
|
+
@gateway = Ya::Direct::Gateway.new(@env, @config, mode)
|
22
21
|
end
|
23
22
|
|
24
23
|
def method_missing(method_name, args = {})
|
25
24
|
@gateway.get_data(method_name.to_s.camelize, args)
|
26
25
|
end
|
27
26
|
|
28
|
-
def resolve_env
|
29
|
-
ENV['RAILS_ENV'] || 'development'
|
30
|
-
end
|
31
|
-
|
32
27
|
end
|
33
28
|
end
|
34
29
|
end
|
@@ -5,12 +5,11 @@ module Ya
|
|
5
5
|
|
6
6
|
URLS = {
|
7
7
|
production: "https://soap.direct.yandex.ru/json-api/v4/",
|
8
|
-
|
9
|
-
development: "https://api-sandbox.direct.yandex.ru/json-api/v4/"
|
8
|
+
sandbox: "https://api-sandbox.direct.yandex.ru/json-api/v4/"
|
10
9
|
}
|
11
10
|
|
12
|
-
def initialize(env, config)
|
13
|
-
@url = URLS[
|
11
|
+
def initialize(env, config, mode)
|
12
|
+
@url = URLS[mode]
|
14
13
|
@config = config
|
15
14
|
end
|
16
15
|
|
@@ -3,11 +3,16 @@ require 'minitest/autorun'
|
|
3
3
|
|
4
4
|
class GatewayTest < YaDirect::TestCase
|
5
5
|
def setup
|
6
|
-
@api = Ya::Direct::Api.new('token', 'app_id', 'login', 'ru')
|
6
|
+
@api = Ya::Direct::Api.new('token', 'app_id', 'login', 'ru', :production)
|
7
|
+
@sandbox_api = Ya::Direct::Api.new('token', 'app_id', 'login', 'ru')
|
7
8
|
end
|
8
9
|
|
9
10
|
def test_gateway_url
|
10
|
-
assert_equal "https://
|
11
|
+
assert_equal "https://soap.direct.yandex.ru/json-api/v4/", @api.gateway.url
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_sandbox_gateway_url
|
15
|
+
assert_equal "https://api-sandbox.direct.yandex.ru/json-api/v4/", @sandbox_api.gateway.url
|
11
16
|
end
|
12
17
|
|
13
18
|
end
|
@@ -2,12 +2,4 @@ require "test_helper"
|
|
2
2
|
require 'minitest/autorun'
|
3
3
|
|
4
4
|
class YaDirectApiTest < YaDirect::TestCase
|
5
|
-
def setup
|
6
|
-
@api = Ya::Direct::Api.new('token', 'app_id', 'login', 'ru')
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_that_default_env_is_development
|
10
|
-
assert_equal "development", @api.env
|
11
|
-
end
|
12
|
-
|
13
5
|
end
|