ya_direct_api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8899285285c7c7c57d4db48e356be59156d19db
4
- data.tar.gz: d4acf7d9d861e617c4445959767665b8338067bb
3
+ metadata.gz: c80643945891d77d3a8a19b48161182883fc3145
4
+ data.tar.gz: 74881cb6676523b0687f15b17bf2f0b5a84726f3
5
5
  SHA512:
6
- metadata.gz: 0240854220989dfcfdadee5012ecf81c08ff86152bde6bb2efcadc482e60ab679ab4218eb547614e020785372581fcf4a16bde12392964fe1c6617e2ef235da8
7
- data.tar.gz: 38568ba48d67fab2a6f2cdeb9c859e4e27ef367d589679db4afc49ba3a4438b1321a1fe64adab78448d39bcfa1eaf8e81f81b3c7aa2e7d129f4aa20597af8d98
6
+ metadata.gz: 55eb83615dfcc37908bd05987fd331efc61d50ff3f3aa31fbe48bc2ab4720e173ac8fe3d7ad137a27c0562c4eb0311881defecc8ddc6e4921bf819f1aae0e87a
7
+ data.tar.gz: 00da71496f83cc5309b25d8a16a0081ca14d4b2b89525d749ab417371030891c51739158ee6b46f222b28d3871ff91cbc11afe0e3ad43a949f2b627cf8abb1c8
@@ -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
- @env = resolve_env
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
- staging: "https://soap.direct.yandex.ru/json-api/v4/",
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[env.to_sym]
11
+ def initialize(env, config, mode)
12
+ @url = URLS[mode]
14
13
  @config = config
15
14
  end
16
15
 
@@ -1,3 +1,3 @@
1
1
  module YaDirectApi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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://api-sandbox.direct.yandex.ru/json-api/v4/", @api.gateway.url
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ya_direct_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Savelyev