telphin_api 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d65cf182b7b9c5ce0a85016c7b4aa77b644edb29
4
- data.tar.gz: f084ceca56e1f731c5b77b3dc7c2503f8ab9d577
3
+ metadata.gz: 69a4a2fd5800ff1c376f7f3cfae3c1122503769e
4
+ data.tar.gz: b5a42d1bf6295d237dc79eda46f5e0cdb2021e17
5
5
  SHA512:
6
- metadata.gz: eac68125abde03b673fce6cf65347683ca6b180a6c7ff1121e1c2007f5e8099fd5e2c023d6753071505f850ff2ba0fe50b438037c06e8dcf83e4c779c018facd
7
- data.tar.gz: 6d9701340e351dc2f9c918a6425838d9f5cf1872dc1eeea50607b497178d7c2223a79b1fe3c77491e1ee3e4ee4e2b8b53d8097681980df5d3fc56fb16283ecdb
6
+ metadata.gz: 650c818828bc06ad7acac0e6b9026aeb9f4ca1e754d1ce97bcfcbcfd5c95f82f213626dc81b937067e7e151ecc948c90ba1798f7a3c05ff9b8981b69fdcc4157
7
+ data.tar.gz: 73a918bb9f90c4c4d647aa783ff8783ada880e0e582d8cb3421e3a1b5e3627ec5473e8e15f8a84a9af2c28000413e3d788c30b87a1ebcc1e04ff95954e0f16eb
@@ -18,18 +18,15 @@ module TelphinApi
18
18
 
19
19
  user_id = args.delete(:user_id)
20
20
  extension_number = args.delete(:extension_number)
21
+
21
22
  id = args.delete(:id)
23
+ url = [namespace, user_id, extension_number, action].join('/')
24
+ url = url + '/' + id unless id.nil?
22
25
 
23
26
  flat_arguments = Utils.flatten_arguments(args)
24
- url = [TelphinApi.site, namespace, user_id, extension_number, action].join('/')
25
- url = url + '/' + id unless id.nil?
26
- connection = connection(url: url, token: token)
27
+ flat_arguments = flat_arguments.to_json.to_s if http_method == :post
27
28
 
28
- if flat_arguments.empty?
29
- connection.send(http_method).body
30
- else
31
- connection.send(http_method, flat_arguments).body
32
- end
29
+ connection(url: TelphinApi.site, token: token, method: http_method).send(http_method, url, flat_arguments).body
33
30
  end
34
31
 
35
32
  # Faraday connection.
@@ -40,9 +37,14 @@ module TelphinApi
40
37
  def connection(options = {})
41
38
  url = options.delete(:url)
42
39
  token = options.delete(:token)
43
- url = url + '?accessRequestToken=' + token
40
+ method = options.delete(:method)
44
41
 
45
42
  Faraday.new(url, TelphinApi.faraday_options) do |builder|
43
+ builder.headers['Authorization'] = "Bearer #{token}"
44
+ if method == :post
45
+ builder.headers['Content-Type'] = 'application/json'
46
+ end
47
+
46
48
  builder.request :multipart
47
49
  builder.request :url_encoded
48
50
  builder.request :retry, TelphinApi.max_retries
@@ -1,4 +1,4 @@
1
1
  module TelphinApi
2
2
  # Library version.
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telphin_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyutyunnikov Konstantin