yclients-api 0.1.3 → 0.1.4
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/Gemfile.lock +1 -1
- data/lib/yclients/api.rb +1 -0
- data/lib/yclients/api/client.rb +1 -0
- data/lib/yclients/api/companies.rb +1 -0
- data/lib/yclients/api/exception.rb +1 -0
- data/lib/yclients/api/service_categories.rb +53 -0
- data/lib/yclients/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b0e3e2f5e6ae543e8d68b46dc44be299de9ff7efd1b95afda195da7b9064994
|
4
|
+
data.tar.gz: f5729fc2e6376e186b79622bbc53c69478fbf89f7200c83f81a450dd09d34d09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3012035d54aa17f2b8ae3a420c1cef98d35239d0750d06a99a5251a166a361bff18b70938de2049a9822853cbc2cd967148918150e69a2891eb3dfcf28cea68a
|
7
|
+
data.tar.gz: eb2d7c9ccf7d6a650b0fefebeb86e45ba46cc34e4a95a18bca72467f8395207e52ee4b20d0ae3d2d6c90bd0343d6fa5e1332d0f4553fb907b1ca65021132f74c
|
data/Gemfile.lock
CHANGED
data/lib/yclients/api.rb
CHANGED
data/lib/yclients/api/client.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
### Категории услуг
|
2
|
+
### https://yclients.docs.apiary.io/#reference/3
|
3
|
+
module Yclients::Api
|
4
|
+
module ServiceCategories
|
5
|
+
URL1 = 'https://api.yclients.com/api/v1/service_category'
|
6
|
+
URL2 = 'https://api.yclients.com/api/v1/service_categories'
|
7
|
+
|
8
|
+
# id (Number, 1234) ID категории услуг (для работы с конкретной категорией)
|
9
|
+
# staff_id (Number, 1234) ID сотрудника (для получения категорий, привязанных к сотруднику)
|
10
|
+
def service_categories(company_id, args={})
|
11
|
+
id = query_param(:id, args[:id], :numeric)[:id] if args.key?(:id)
|
12
|
+
uri = URI(id.nil? ? "#{URL2}/#{company_id}" : "#{URL2}/#{company_id}/#{id}")
|
13
|
+
params = {}
|
14
|
+
params.merge!(query_param(:staff_id, args[:staff_id], :numeric)) if args.key?(:staff_id)
|
15
|
+
uri.query = URI.encode_www_form(params)
|
16
|
+
|
17
|
+
req = Net::HTTP::Get.new(uri, headers({ auth: false }))
|
18
|
+
|
19
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
20
|
+
http.request(req)
|
21
|
+
end
|
22
|
+
|
23
|
+
json = JSON.parse(res.body)
|
24
|
+
if json.kind_of?(Array)
|
25
|
+
json
|
26
|
+
else
|
27
|
+
raise ServiceCategoriesAccessError, json.to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def service_category(company_id, id)
|
32
|
+
uri = URI("#{URL1}/#{company_id}/#{id}")
|
33
|
+
req = Net::HTTP::Get.new(uri, headers({ auth: false }))
|
34
|
+
|
35
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
36
|
+
http.request(req)
|
37
|
+
end
|
38
|
+
|
39
|
+
json = JSON.parse(res.body)
|
40
|
+
if json.kind_of?(Hash) && json.key?('id')
|
41
|
+
json
|
42
|
+
else
|
43
|
+
raise ServiceCategoriesAccessError, json.to_s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
=begin TODO
|
48
|
+
def new_service_category(company_id, args={}); end
|
49
|
+
def edit_service_category(company_id, id=nil, args={}); end
|
50
|
+
def delete_service_category(company_id, id=nil); end
|
51
|
+
=end
|
52
|
+
end
|
53
|
+
end
|
data/lib/yclients/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yclients-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maksim Akkuzin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- lib/yclients/api/client.rb
|
46
46
|
- lib/yclients/api/companies.rb
|
47
47
|
- lib/yclients/api/exception.rb
|
48
|
+
- lib/yclients/api/service_categories.rb
|
48
49
|
- lib/yclients/api/version.rb
|
49
50
|
- yclients-api.gemspec
|
50
51
|
homepage: https://github.com/makkuzin/yclients-api
|