voximplant_api 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/voximplant_api/client.rb +25 -2
- 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: 05350c84c62797a2672f2fe02506d490b8b33c0a
|
4
|
+
data.tar.gz: 4202aa6409bbe2e17af8e5375377aca8e04a01bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19fce76882a8b00c2f3cf35e6aa3882ad9d436475f6fbd22716ff229237fa361ad7e262273b3b2ed60f14dce19c767ff3607a9e1e33a13f8e4c0b365985eff98
|
7
|
+
data.tar.gz: 57877275c3f39df9427d4423238a4e11ff6c7b7058db8d4fd5e353677fbd438195dd630288992e2dadbf96e0e7bb9e880f8abd164b6b56b483f7e569f6594efe
|
@@ -24,9 +24,18 @@ module VoximplantApi
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def method_missing(name, *args)
|
27
|
-
method_name = name.to_s.split('_').collect(&:capitalize).join
|
28
27
|
options = args.first || {}
|
29
|
-
|
28
|
+
name_words = name.to_s.split('_')
|
29
|
+
if name_words.first == "each"
|
30
|
+
return enum_for(name, *args) unless block_given?
|
31
|
+
method_name = name_words[1..-1].collect(&:capitalize).join
|
32
|
+
perform_request_each method_name, options do |x|
|
33
|
+
yield x
|
34
|
+
end
|
35
|
+
else
|
36
|
+
method_name = name_words.collect(&:capitalize).join
|
37
|
+
perform_request method_name, options
|
38
|
+
end
|
30
39
|
|
31
40
|
rescue VoximplantApi::Error => e
|
32
41
|
if e.code == NO_METHOD_ERROR_CODE
|
@@ -53,6 +62,20 @@ module VoximplantApi
|
|
53
62
|
self.class.perform_request(name, params)
|
54
63
|
end
|
55
64
|
|
65
|
+
def perform_request_each(name, params = {})
|
66
|
+
offset = params[:offset] || 0
|
67
|
+
per_page = [params[:count] || 100, 100].min
|
68
|
+
begin
|
69
|
+
result = perform_request(name, params.merge(offset: offset, count: per_page))
|
70
|
+
count = result["count"]
|
71
|
+
offset += count
|
72
|
+
total_count = result["total_count"]
|
73
|
+
result["result"].each do |obj|
|
74
|
+
yield obj
|
75
|
+
end
|
76
|
+
end while offset < total_count
|
77
|
+
end
|
78
|
+
|
56
79
|
def perform_request_as_parent(name, params = {})
|
57
80
|
params = parent_auth_params.merge params
|
58
81
|
self.class.perform_request(name, params)
|