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 +4 -4
- data/lib/telphin_api/api.rb +11 -9
- data/lib/telphin_api/version.rb +1 -1
- 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: 69a4a2fd5800ff1c376f7f3cfae3c1122503769e
|
4
|
+
data.tar.gz: b5a42d1bf6295d237dc79eda46f5e0cdb2021e17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 650c818828bc06ad7acac0e6b9026aeb9f4ca1e754d1ce97bcfcbcfd5c95f82f213626dc81b937067e7e151ecc948c90ba1798f7a3c05ff9b8981b69fdcc4157
|
7
|
+
data.tar.gz: 73a918bb9f90c4c4d647aa783ff8783ada880e0e582d8cb3421e3a1b5e3627ec5473e8e15f8a84a9af2c28000413e3d788c30b87a1ebcc1e04ff95954e0f16eb
|
data/lib/telphin_api/api.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/telphin_api/version.rb
CHANGED