sraas 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13c3f2a248c8e890955c00662fe6232b8618716f
4
- data.tar.gz: 865bd0d1715509c1cfc22ff56b8a92668d0695fd
3
+ metadata.gz: 01764c6541459c2412b6590b3b38d8d00c3eed18
4
+ data.tar.gz: 50d65e6c3f4c8744e3ec4b368c1349a81f7faeba
5
5
  SHA512:
6
- metadata.gz: b289012fa754d1c720cfdf75faaaef2ceb976da0f351f65e8079347041ddcfc401c703dab0e2fd8f283da99318fb39de12fd3ce2559e0b0a098c76d7a58e66a9
7
- data.tar.gz: 611b044719707a248b3e295bfbbc0c08c03fe71d22071f24c57d2c5e078560128d804e639a3a0b64ea7a8e8d2cb9642284a0df6a44c86c1679bb33d99251621f
6
+ metadata.gz: 30369331637831b470ef195f07688f32e876a2a01d6c073f963f148134eb820dce95a57a1cb6320e7e672882fb6f1d26d94f576af8394986cea64fe0a1a63db7
7
+ data.tar.gz: 86c61bdcdf956befd36ab27ca4639a8b019528baf3b1215e5a32aec8e40d478a1605e65051bee002a79998d46883802152da062327cacd41f38d61694a0e924c
@@ -58,7 +58,8 @@ module Sraas
58
58
 
59
59
  # This returns template cards "index" json
60
60
  # if limit is > 100, do paging here.
61
- def template_cards(template_deck_id, offset: 0, limit: 100)
61
+ def template_cards(template_deck_id=self.default_template_deck_id, offset: 0, limit: 100)
62
+ puts template_deck_id
62
63
  template_cards = []
63
64
  remainder = limit
64
65
  while remainder > 0 do
@@ -78,6 +79,21 @@ module Sraas
78
79
  JSON.parse(Sraas.api_resource(:get, "#{self.template_cards_endpoint}/#{template_card_id}"))
79
80
  end
80
81
 
82
+ # This gets the deck id from Sraas for the default deck (which is specified by name)
83
+ def default_template_deck_id
84
+ return @default_template_deck_id if @default_template_deck_id
85
+ template_deck = self.template_decks({name_start: configuration.default_deck_name}).last
86
+ @default_template_deck_id = template_deck['id'] if template_deck
87
+ end
88
+
89
+ # TODO: accept not only title and kind. sraas needs to use ransack for it.
90
+ # This search template_card with title and kind.
91
+ def search_template_card(template_deck_id=self.default_template_deck_id, title, kind)
92
+ url = "#{Sraas.template_decks_endpoint}/#{template_deck_id}/template_cards/search"
93
+ params = {title: title, kind: kind}
94
+ JSON.parse(Sraas.api_resource(:get, url, params))
95
+ end
96
+
81
97
  # This returns template card's children's "index" json
82
98
  def template_card_children(template_card_id)
83
99
  JSON.parse(Sraas.api_resource(:get, "#{self.template_cards_endpoint}/#{template_card_id}/children"))
@@ -129,9 +129,7 @@ module Sraas
129
129
  # This search template_card with title and kind.
130
130
  def search_template_card(title, kind)
131
131
  template_deck_id = template_deck['id']
132
- url = "#{Sraas.template_decks_endpoint}/#{template_deck_id}/template_cards/search"
133
- params = {title: title, kind: kind}
134
- JSON.parse(Sraas.api_resource(:get, url, params))
132
+ Sraas.search_template_card(template_deck_id, title, kind)
135
133
  end
136
134
 
137
135
  # return all template_decks without name and fingerprint
@@ -1,3 +1,3 @@
1
1
  module Sraas
2
- VERSION = '0.3.6'
2
+ VERSION = '0.3.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sraas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel