sraas 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sraas.rb +25 -2
- data/lib/sraas/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: af79a1b3cdc77cf6ea26c5ce968562ca573867d2
|
4
|
+
data.tar.gz: 2d000227d9c4c79cb5076e6349021a6874536695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db4cb29c28282f4cc4ca12638867191d3e16b872ae0ceed73f48fcc0b67cf556980048e3f3cddd76f61879bf840dc3792ad167867ab0334e8ab4e74a30160349
|
7
|
+
data.tar.gz: 803a4c99a0c1a1237ccc30a9ca311b4bb733e7f7a03f6316fe8c134474c5cab0fbc5255c112dc5e035a1900f7d6096b9409ec34a104774d1213d85029132e100
|
data/lib/sraas.rb
CHANGED
@@ -51,9 +51,32 @@ module Sraas
|
|
51
51
|
end
|
52
52
|
|
53
53
|
# This returns template cards "index" json
|
54
|
+
# if limit is > 100, do paging here.
|
54
55
|
def template_cards(template_deck_id, offset: 0, limit: 100)
|
55
|
-
|
56
|
-
|
56
|
+
if limit <= 100
|
57
|
+
paging = { limit: limit, offset: offset }.to_query
|
58
|
+
JSON.parse(Sraas.api_resource(:get, "#{self.template_decks_endpoint}/#{template_deck_id}/template_cards", paging))
|
59
|
+
else
|
60
|
+
template_cards = []
|
61
|
+
q, r = limit.divmod(100)
|
62
|
+
|
63
|
+
# if remainder > 0, request for it first.
|
64
|
+
if r > 0
|
65
|
+
paging = { limit: r, offset: offset }.to_query
|
66
|
+
template_cards << JSON.parse(Sraas.api_resource(:get, "#{self.template_decks_endpoint}/#{template_deck_id}/template_cards", paging))
|
67
|
+
offset += r
|
68
|
+
end
|
69
|
+
q.times do
|
70
|
+
paging = { limit: 100, offset: offset }.to_query
|
71
|
+
result = JSON.parse(Sraas.api_resource(:get, "#{self.template_decks_endpoint}/#{template_deck_id}/template_cards", paging))
|
72
|
+
# If limit is bigger than number of template_cards, break once result is empty
|
73
|
+
# e.g. limit = 10000
|
74
|
+
break if result.empty?
|
75
|
+
template_cards << result
|
76
|
+
offset += result.count
|
77
|
+
end
|
78
|
+
template_cards.flatten
|
79
|
+
end
|
57
80
|
end
|
58
81
|
|
59
82
|
# This returns template card "full" json
|
data/lib/sraas/version.rb
CHANGED