yandex360 1.0.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +12 -0
- data/.github/workflows/ci.yml +51 -0
- data/.gitignore +2 -0
- data/.rspec +5 -0
- data/Gemfile +0 -9
- data/Gemfile.lock +40 -1
- data/README.md +71 -3
- data/lib/yandex360/resources/departments.rb +12 -10
- data/lib/yandex360/resources/groups.rb +12 -10
- data/lib/yandex360/resources/users.rb +2 -2
- data/lib/yandex360/version.rb +1 -1
- data/lib/yandex360.rb +2 -1
- data/spec/antispam_spec.rb +46 -0
- data/spec/client_spec.rb +24 -0
- data/spec/departments_spec.rb +131 -0
- data/spec/groups_spec.rb +133 -0
- data/spec/spec_helper.rb +59 -0
- data/spec/users_spec.rb +203 -0
- data/spec/vcr/anispam/create.yml +43 -0
- data/spec/vcr/anispam/delete.yml +41 -0
- data/spec/vcr/anispam/list.yml +41 -0
- data/spec/vcr/departments/add_alias.yml +43 -0
- data/spec/vcr/departments/create.yml +43 -0
- data/spec/vcr/departments/delete.yml +41 -0
- data/spec/vcr/departments/delete_alias.yml +41 -0
- data/spec/vcr/departments/delete_error.yml +37 -0
- data/spec/vcr/departments/info.yml +41 -0
- data/spec/vcr/departments/list.yml +41 -0
- data/spec/vcr/departments/update.yml +44 -0
- data/spec/vcr/groups/add_user.yml +43 -0
- data/spec/vcr/groups/create.yml +43 -0
- data/spec/vcr/groups/delete.yml +41 -0
- data/spec/vcr/groups/delete_user.yml +41 -0
- data/spec/vcr/groups/list.yml +48 -0
- data/spec/vcr/groups/params.yml +41 -0
- data/spec/vcr/groups/update.yml +43 -0
- data/spec/vcr/groups/users.yml +41 -0
- data/spec/vcr/users/add.yml +43 -0
- data/spec/vcr/users/add_alias.yml +43 -0
- data/spec/vcr/users/delete_alias.yml +41 -0
- data/spec/vcr/users/get2FA.yml +41 -0
- data/spec/vcr/users/get2FA_error.yml +37 -0
- data/spec/vcr/users/has2FA.yml +41 -0
- data/spec/vcr/users/info.yml +41 -0
- data/spec/vcr/users/list.yml +41 -0
- data/spec/vcr/users/list_error.yml +37 -0
- data/spec/vcr/users/update.yml +44 -0
- data/yandex360.gemspec +10 -2
- metadata +146 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66eac1024d498386e562d1ba1813ccd7992ca5a655798c35c2ceb31b9b577e32
|
4
|
+
data.tar.gz: 100f12e93db7cd960ca3ef04a206dcb71de80db74fab1ffd4c0db2ed73d71532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f73c6450cf570a6414dec1b1f87317565df27d46352ffa8f04d03a664940efd605148cda51a1e2cd8d1d8f791ad1edca712d2b1da6a44595842ff3cc3f4637f
|
7
|
+
data.tar.gz: 4ca5dd21ddeeb96dbf342e18b91f16f51a0ee0a084fd09550f030c65be7eb5dbefcafe057b7f90dbea382b0655d4d78c95715afc9b4656fde26175450baf9711
|
@@ -0,0 +1,51 @@
|
|
1
|
+
name: Ruby specs
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
name: tests
|
6
|
+
strategy:
|
7
|
+
fail-fast: false
|
8
|
+
matrix:
|
9
|
+
os: [ubuntu-latest, macos-latest]
|
10
|
+
ruby: ['2.6', '2.7', '3.0', '3.1', head, truffleruby, truffleruby-head]
|
11
|
+
runs-on: ${{ matrix.os }}
|
12
|
+
continue-on-error: true
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v3
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
18
|
+
bundler-cache: true
|
19
|
+
|
20
|
+
- name: Get the newest rubygems version to rid ourselves of warnings
|
21
|
+
run: gem update --system --no-document
|
22
|
+
|
23
|
+
- name: Install bundler
|
24
|
+
run: gem i bundler --no-document
|
25
|
+
|
26
|
+
- name: Install dependencies
|
27
|
+
run: |
|
28
|
+
bundle config set --local without benchmark
|
29
|
+
bundle install --jobs=3
|
30
|
+
- name: RSpec testing
|
31
|
+
run: |
|
32
|
+
JRUBY_OPTS="--dev --debug" bundle exec rspec --color --format documentation
|
33
|
+
- name: Coveralls Parallel
|
34
|
+
uses: coverallsapp/github-action@1.1.3
|
35
|
+
with:
|
36
|
+
github-token: ${{ secrets.github_token }}
|
37
|
+
flag-name: run-${{ matrix.ruby-version }}
|
38
|
+
path-to-lcov: ./coverage/lcov/yandex360.lcov
|
39
|
+
parallel: true
|
40
|
+
|
41
|
+
coverage:
|
42
|
+
name: Coverage
|
43
|
+
needs: test
|
44
|
+
runs-on: ubuntu-latest
|
45
|
+
steps:
|
46
|
+
- name: Coveralls Finished
|
47
|
+
uses: coverallsapp/github-action@1.1.3
|
48
|
+
with:
|
49
|
+
github-token: ${{ secrets.github_token }}
|
50
|
+
path-to-lcov: ${{ github.workspace }}/coverage/lcov.info
|
51
|
+
parallel-finished: true
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
yandex360 (1.
|
4
|
+
yandex360 (1.1.1)
|
5
5
|
addressable (~> 2.3, >= 2.3.7)
|
6
6
|
faraday (~> 1.7)
|
7
7
|
|
@@ -10,6 +10,10 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
addressable (2.8.1)
|
12
12
|
public_suffix (>= 2.0.2, < 6.0)
|
13
|
+
crack (0.4.5)
|
14
|
+
rexml
|
15
|
+
diff-lcs (1.5.0)
|
16
|
+
docile (1.4.0)
|
13
17
|
faraday (1.10.2)
|
14
18
|
faraday-em_http (~> 1.0)
|
15
19
|
faraday-em_synchrony (~> 1.0)
|
@@ -33,14 +37,49 @@ GEM
|
|
33
37
|
faraday-patron (1.0.0)
|
34
38
|
faraday-rack (1.0.0)
|
35
39
|
faraday-retry (1.0.3)
|
40
|
+
hashdiff (1.0.1)
|
36
41
|
multipart-post (2.2.3)
|
37
42
|
public_suffix (5.0.0)
|
43
|
+
rake (12.3.3)
|
44
|
+
rexml (3.2.5)
|
45
|
+
rspec (3.11.0)
|
46
|
+
rspec-core (~> 3.11.0)
|
47
|
+
rspec-expectations (~> 3.11.0)
|
48
|
+
rspec-mocks (~> 3.11.0)
|
49
|
+
rspec-core (3.11.0)
|
50
|
+
rspec-support (~> 3.11.0)
|
51
|
+
rspec-expectations (3.11.1)
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
+
rspec-support (~> 3.11.0)
|
54
|
+
rspec-mocks (3.11.1)
|
55
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
56
|
+
rspec-support (~> 3.11.0)
|
57
|
+
rspec-support (3.11.1)
|
38
58
|
ruby2_keywords (0.0.5)
|
59
|
+
simplecov (0.21.2)
|
60
|
+
docile (~> 1.1)
|
61
|
+
simplecov-html (~> 0.11)
|
62
|
+
simplecov_json_formatter (~> 0.1)
|
63
|
+
simplecov-html (0.12.3)
|
64
|
+
simplecov-lcov (0.7.0)
|
65
|
+
simplecov_json_formatter (0.1.4)
|
66
|
+
vcr (6.1.0)
|
67
|
+
webmock (3.18.1)
|
68
|
+
addressable (>= 2.8.0)
|
69
|
+
crack (>= 0.3.2)
|
70
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
39
71
|
|
40
72
|
PLATFORMS
|
41
73
|
x86_64-darwin-17
|
42
74
|
|
43
75
|
DEPENDENCIES
|
76
|
+
bundler
|
77
|
+
rake (~> 12.3.3)
|
78
|
+
rspec (~> 3.0)
|
79
|
+
simplecov (~> 0.9)
|
80
|
+
simplecov-lcov (~> 0.7.0)
|
81
|
+
vcr (~> 6.1)
|
82
|
+
webmock (~> 3.18, >= 3.18.1)
|
44
83
|
yandex360!
|
45
84
|
|
46
85
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,7 +1,75 @@
|
|
1
|
-
#
|
1
|
+
# Yandex 360 - Ruby API client ([gem](https://rubygems.org/gems/yandex360))
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/yandex360.svg)](https://badge.fury.io/rb/yandex360)
|
4
|
+
![Gem](https://img.shields.io/gem/dt/yandex360)
|
5
|
+
![GitHub](https://img.shields.io/github/license/ruby-api-client/yandex360)
|
6
|
+
[![Ruby specs](https://github.com/ruby-api-client/yandex360/actions/workflows/ci.yml/badge.svg)](https://github.com/ruby-api-client/yandex360/actions/workflows/ci.yml)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/github/ruby-api-client/yandex360/badge.svg?branch=main)](https://coveralls.io/github/ruby-api-client/yandex360?branch=main)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
### Gemfile
|
12
|
+
|
13
|
+
```gemfile
|
14
|
+
gem 'yandex360', '~> 1.1'
|
15
|
+
```
|
16
|
+
|
17
|
+
### Install
|
18
|
+
|
19
|
+
```sh
|
20
|
+
gem install yandex360
|
21
|
+
```
|
22
|
+
|
23
|
+
## Getting started
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require "yandex360"
|
27
|
+
|
28
|
+
yandex360 = Yandex360::Client.new(token: "paste your access_token here")
|
29
|
+
|
30
|
+
users = yandex360.users.list(org_id: 1234567)
|
31
|
+
```
|
32
|
+
|
33
|
+
## Available methods
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
# Antispam
|
37
|
+
antispam.list(org_id:)
|
38
|
+
antispam.create(org_id, *strings)
|
39
|
+
antispam.delete(org_id:)
|
40
|
+
|
41
|
+
# Users
|
42
|
+
users.add(org_id:, dep_id:, **user_params)
|
43
|
+
users.add_alias(org_id:, user_id:, user_alias:)
|
44
|
+
users.update(org_id:, user_id:, **user_params)
|
45
|
+
users.info(org_id:, user_id:)
|
46
|
+
users.list(org_id:, page: 1, per_page: 10)
|
47
|
+
users.get2FA(org_id:, user_id:)
|
48
|
+
users.has2FA?(org_id:, user_id:)
|
49
|
+
users.delete_alias(org_id:, user_id:, user_alias:)
|
50
|
+
|
51
|
+
# Departments
|
52
|
+
departments.add_alias(org_id:, dep_id:, name:)
|
53
|
+
departments.update(org_id:, dep_id:, parent_id:, **params)
|
54
|
+
departments.info(org_id:, dep_id:)
|
55
|
+
departments.list(org_id:, page: 1, per_page: 10, parent_id: 0, order_by: "id")
|
56
|
+
departments.create(org_id:, name:, parent_id:, **params)
|
57
|
+
departments.delete_alias(org_id:, dep_id:, name:)
|
58
|
+
departments.delete(org_id:, dep_id:)
|
59
|
+
|
60
|
+
# Groups
|
61
|
+
groups.add_user(org_id:, group_id:, user_id:, type: "user")
|
62
|
+
groups.update(org_id:, group_id:, **user_params)
|
63
|
+
groups.params(org_id:, group_id:)
|
64
|
+
groups.list(org_id:, page: 1, per_page: 10)
|
65
|
+
groups.users(org_id:, group_id:)
|
66
|
+
groups.create(org_id:, name:, **group_params)
|
67
|
+
groups.delete(org_id:, group_id:)
|
68
|
+
groups.delete_user(org_id:, group_id:, type:, user_id:)
|
69
|
+
```
|
2
70
|
|
3
71
|
## TODO
|
4
72
|
|
5
|
-
-
|
73
|
+
- examples
|
6
74
|
- documentation
|
7
|
-
- tests
|
75
|
+
- ~~tests~~
|
@@ -7,8 +7,12 @@ module Yandex360
|
|
7
7
|
DepartmentAlias.new post("directory/v1/org/#{org_id}/departments/#{dep_id}/aliases", body: dep_alias).body
|
8
8
|
end
|
9
9
|
|
10
|
-
def update(org_id:, dep_id:, **params)
|
11
|
-
department = {
|
10
|
+
def update(org_id:, dep_id:, parent_id:, **params)
|
11
|
+
department = {
|
12
|
+
orgId: org_id,
|
13
|
+
departmentId: dep_id,
|
14
|
+
parentId: parent_id
|
15
|
+
}
|
12
16
|
params.each {|param, value| department[param] = value }
|
13
17
|
Department.new patch("directory/v1/org/#{org_id}/departments/#{dep_id}", body: department).body
|
14
18
|
end
|
@@ -18,14 +22,12 @@ module Yandex360
|
|
18
22
|
end
|
19
23
|
|
20
24
|
def list(org_id:, page: 1, per_page: 10, parent_id: 0, order_by: "id")
|
21
|
-
resp = get(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}.gsub(/\s+/, "").strip)
|
28
|
-
Collection.from_response(resp, key: "departments", type: GroupList)
|
25
|
+
resp = get("directory/v1/org/#{org_id}/departments \
|
26
|
+
?page=#{page} \
|
27
|
+
&perPage=#{per_page} \
|
28
|
+
&parentId=#{parent_id} \
|
29
|
+
&orderBy=#{order_by}".gsub(/\s+/, "").strip)
|
30
|
+
Collection.from_response(resp, key: "departments", type: Department)
|
29
31
|
end
|
30
32
|
|
31
33
|
# parent_id:, name:, description: "", external_id: "", head_id: 0, label: ""
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module Yandex360
|
4
4
|
class GroupsResource < Resource
|
5
|
-
def add_user(org_id:, group_id:,
|
5
|
+
def add_user(org_id:, group_id:, user_id:, type: "user")
|
6
6
|
user = {
|
7
|
-
id:
|
7
|
+
id: user_id,
|
8
8
|
type: type
|
9
9
|
}
|
10
10
|
Group.new post("directory/v1/org/#{org_id}/groups/#{group_id}/members", body: user).body
|
@@ -22,26 +22,28 @@ module Yandex360
|
|
22
22
|
|
23
23
|
def list(org_id:, page: 1, per_page: 10)
|
24
24
|
resp = get("directory/v1/org/#{org_id}/groups?page=#{page}&perPage=#{per_page}")
|
25
|
-
Collection.from_response(resp, key: "groups", type:
|
25
|
+
Collection.from_response(resp, key: "groups", type: Group)
|
26
26
|
end
|
27
27
|
|
28
28
|
def users(org_id:, group_id:)
|
29
|
-
|
30
|
-
|
29
|
+
resp = get("directory/v1/org/#{org_id}/groups/#{group_id}/members")
|
30
|
+
Collection.from_response(resp, key: "users", type: User)
|
31
31
|
end
|
32
32
|
|
33
|
-
def create(org_id:, **group_params)
|
34
|
-
group = {
|
33
|
+
def create(org_id:, name:, **group_params)
|
34
|
+
group = {
|
35
|
+
name: name
|
36
|
+
}
|
35
37
|
group_params.each {|param, value| group[param] = value }
|
36
38
|
Group.new post("directory/v1/org/#{org_id}/groups", body: group).body
|
37
39
|
end
|
38
40
|
|
39
41
|
def delete(org_id:, group_id:)
|
40
|
-
delete_request("directory/v1/org/#{org_id}/groups/#{group_id}")
|
42
|
+
Group.new delete_request("directory/v1/org/#{org_id}/groups/#{group_id}").body
|
41
43
|
end
|
42
44
|
|
43
|
-
def delete_user(org_id:, group_id:, type:,
|
44
|
-
Object.new delete_request("directory/v1/org/#{org_id}/groups/#{group_id}/members/#{type}/#{
|
45
|
+
def delete_user(org_id:, group_id:, type:, user_id:)
|
46
|
+
Object.new delete_request("directory/v1/org/#{org_id}/groups/#{group_id}/members/#{type}/#{user_id}").body
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -29,7 +29,7 @@ module Yandex360
|
|
29
29
|
|
30
30
|
def list(org_id:, page: 1, per_page: 10)
|
31
31
|
resp = get("directory/v1/org/#{org_id}/users?page=#{page}&perPage=#{per_page}")
|
32
|
-
Collection.from_response(resp, key: "users", type:
|
32
|
+
Collection.from_response(resp, key: "users", type: User)
|
33
33
|
end
|
34
34
|
|
35
35
|
# rubocop:disable Naming/MethodName
|
@@ -44,7 +44,7 @@ module Yandex360
|
|
44
44
|
# rubocop:enable Naming/MethodName
|
45
45
|
|
46
46
|
def delete_alias(org_id:, user_id:, user_alias:)
|
47
|
-
Alias.new delete_request("directory/v1/org/#{org_id}/users/#{user_id}/aliases/#{user_alias}")
|
47
|
+
Alias.new delete_request("directory/v1/org/#{org_id}/users/#{user_id}/aliases/#{user_alias}").body
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/lib/yandex360/version.rb
CHANGED
data/lib/yandex360.rb
CHANGED
@@ -15,6 +15,7 @@ module Yandex360
|
|
15
15
|
autoload :AllowList, "yandex360/objects/types"
|
16
16
|
|
17
17
|
autoload :DepartmentsResource, "yandex360/resources/departments"
|
18
|
+
autoload :Department, "yandex360/objects/types"
|
18
19
|
autoload :Departments, "yandex360/objects/types"
|
19
20
|
autoload :DepartmentList, "yandex360/objects/types"
|
20
21
|
autoload :DepartmentAlias, "yandex360/objects/types"
|
@@ -26,5 +27,5 @@ module Yandex360
|
|
26
27
|
autoload :GroupList, "yandex360/objects/types"
|
27
28
|
|
28
29
|
autoload :UsersResource, "yandex360/resources/users"
|
29
|
-
autoload :
|
30
|
+
autoload :User, "yandex360/objects/types"
|
30
31
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "yandex360"
|
5
|
+
|
6
|
+
RSpec.describe "#anispam.create" do
|
7
|
+
let(:org_id) { "1234567" }
|
8
|
+
|
9
|
+
context "when create" do
|
10
|
+
subject(:resp) do
|
11
|
+
VCR.use_cassette("anispam/create") do
|
12
|
+
@yandex360.antispam.create(org_id, "127.0.0.1", "172.0.1.10")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it { expect(resp).to be_an Yandex360::AllowList }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.describe "#anispam.list" do
|
21
|
+
let(:org_id) { "1234567" }
|
22
|
+
|
23
|
+
context "when list" do
|
24
|
+
subject(:resp) do
|
25
|
+
VCR.use_cassette("anispam/list") do
|
26
|
+
@yandex360.antispam.list(org_id: org_id)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it { expect(resp).to be_an Yandex360::AllowList }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec.describe "#anispam.delete" do
|
35
|
+
let(:org_id) { "1234567" }
|
36
|
+
|
37
|
+
context "when delete" do
|
38
|
+
subject(:resp) do
|
39
|
+
VCR.use_cassette("anispam/delete") do
|
40
|
+
@yandex360.antispam.delete(org_id: org_id)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it { expect(resp.status).to eq 200 }
|
45
|
+
end
|
46
|
+
end
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "yandex360"
|
5
|
+
|
6
|
+
RSpec.describe Yandex360::Client do
|
7
|
+
describe "#client", :vcr do
|
8
|
+
context "with valid token" do
|
9
|
+
it do
|
10
|
+
allow(described_class).to receive(:new)
|
11
|
+
.with(token: ACCESS_TOKEN)
|
12
|
+
.and_return(Yandex360::Client)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "without token" do
|
17
|
+
it { expect { described_class.new }.to raise_error(ArgumentError) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
RSpec.describe "#VERSION" do
|
23
|
+
it { expect(Yandex360::VERSION).to eq "1.1.0" }
|
24
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "yandex360"
|
5
|
+
|
6
|
+
RSpec.describe "#departments.list" do
|
7
|
+
let(:org_id) { "1234567" }
|
8
|
+
|
9
|
+
context "with params" do
|
10
|
+
subject(:resp) do
|
11
|
+
VCR.use_cassette("departments/list") do
|
12
|
+
@yandex360.departments.list(org_id: org_id)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it { expect(resp).to be_a Yandex360::Collection }
|
17
|
+
it { expect(resp.data.first).to be_an Yandex360::Department }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
RSpec.describe "#departments.create" do
|
22
|
+
let(:org_id) { "1234567" }
|
23
|
+
|
24
|
+
context "with params" do
|
25
|
+
subject(:resp) do
|
26
|
+
VCR.use_cassette("departments/create") do
|
27
|
+
@yandex360.departments.create(org_id: org_id, name: "Support", parent_id: 1)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it { expect(resp).to be_an Yandex360::Department }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec.describe "#departments.update" do
|
36
|
+
let(:org_id) { "1234567" }
|
37
|
+
let(:dep_id) { "13" }
|
38
|
+
let(:parent_id) { "1" }
|
39
|
+
|
40
|
+
context "with params" do
|
41
|
+
subject(:resp) do
|
42
|
+
VCR.use_cassette("departments/update") do
|
43
|
+
@yandex360.departments.update(
|
44
|
+
org_id: org_id,
|
45
|
+
dep_id: dep_id,
|
46
|
+
parent_id: parent_id,
|
47
|
+
description: "Yandex360",
|
48
|
+
name: "Support Team",
|
49
|
+
label: "support-team"
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it { expect(resp).to be_an Yandex360::Department }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
RSpec.describe "#departments.info" do
|
59
|
+
let(:org_id) { "1234567" }
|
60
|
+
let(:dep_id) { "13" }
|
61
|
+
|
62
|
+
context "with params" do
|
63
|
+
subject(:resp) do
|
64
|
+
VCR.use_cassette("departments/info") do
|
65
|
+
@yandex360.departments.info(dep_id: dep_id, org_id: org_id)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it { expect(resp).to be_an(Yandex360::Department) }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
RSpec.describe "#departments.add_alias" do
|
74
|
+
let(:org_id) { "1234567" }
|
75
|
+
let(:dep_id) { "13" }
|
76
|
+
let(:name) { "support-team" }
|
77
|
+
|
78
|
+
context "with params" do
|
79
|
+
subject(:resp) do
|
80
|
+
VCR.use_cassette("departments/add_alias") do
|
81
|
+
@yandex360.departments.add_alias(org_id: org_id, dep_id: dep_id, name: name)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it { expect(resp).to be_an Yandex360::DepartmentAlias }
|
86
|
+
it { expect(resp.aliases.first).to eq name }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
RSpec.describe "#departments.delete_alias" do
|
91
|
+
let(:org_id) { "1234567" }
|
92
|
+
let(:dep_id) { "13" }
|
93
|
+
let(:name) { "support-team" }
|
94
|
+
|
95
|
+
context "with params" do
|
96
|
+
subject(:resp) do
|
97
|
+
VCR.use_cassette("departments/delete_alias") do
|
98
|
+
@yandex360.departments.delete_alias(org_id: org_id, dep_id: dep_id, name: name)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it { expect(resp).to be_an Yandex360::Object }
|
103
|
+
it { expect(resp.removed).to be true }
|
104
|
+
it { expect(resp.alias).to eq name }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
RSpec.describe "#departments.delete" do
|
109
|
+
let(:org_id) { "1234567" }
|
110
|
+
let(:dep_id) { "13" }
|
111
|
+
|
112
|
+
context "with params" do
|
113
|
+
subject(:resp) do
|
114
|
+
VCR.use_cassette("departments/delete") do
|
115
|
+
@yandex360.departments.delete(org_id: org_id, dep_id: dep_id)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it { expect(resp).to be_an(Yandex360::Object) }
|
120
|
+
end
|
121
|
+
|
122
|
+
context "with error" do
|
123
|
+
subject(:resp) do
|
124
|
+
VCR.use_cassette("departments/delete_error") do
|
125
|
+
@yandex360.departments.delete(org_id: org_id, dep_id: dep_id)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
it { expect { resp }.to raise_error(Yandex360::Error, /No results/) }
|
130
|
+
end
|
131
|
+
end
|