Module: TheCastleClient
- Defined in:
- lib/the_castle_client.rb,
lib/the_castle_client/version.rb
Constant Summary collapse
- VERSION =
"0.0.5"
Class Attribute Summary collapse
-
.host ⇒ Object
Returns the value of attribute host.
-
.key ⇒ Object
Returns the value of attribute key.
-
.port ⇒ Object
Returns the value of attribute port.
-
.scheme ⇒ Object
Returns the value of attribute scheme.
-
.secret ⇒ Object
Returns the value of attribute secret.
-
.version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .account_aggregates(id) ⇒ Object
-
.account_data(id, opts = {}) ⇒ Object
these are just niceties around the query method; deprecate?.
- .piece_aggregates(id) ⇒ Object
- .piece_data(id, opts = {}) ⇒ Object
- .popular_pieces(popular_on = Date.today, limit = 25) ⇒ Object
- .query(id, model = 'account', data_type = '', options = {}) ⇒ Object
Class Attribute Details
.host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/the_castle_client.rb', line 8 def host @host end |
.key ⇒ Object
Returns the value of attribute key.
8 9 10 |
# File 'lib/the_castle_client.rb', line 8 def key @key end |
.port ⇒ Object
Returns the value of attribute port.
8 9 10 |
# File 'lib/the_castle_client.rb', line 8 def port @port end |
.scheme ⇒ Object
Returns the value of attribute scheme.
8 9 10 |
# File 'lib/the_castle_client.rb', line 8 def scheme @scheme end |
.secret ⇒ Object
Returns the value of attribute secret.
8 9 10 |
# File 'lib/the_castle_client.rb', line 8 def secret @secret end |
.version ⇒ Object
Returns the value of attribute version.
8 9 10 |
# File 'lib/the_castle_client.rb', line 8 def version @version end |
Class Method Details
.account_aggregates(id) ⇒ Object
26 |
# File 'lib/the_castle_client.rb', line 26 def account_aggregates(id); query(id, 'account', 'aggregates'); end |
.account_data(id, opts = {}) ⇒ Object
these are just niceties around the query method; deprecate?
25 |
# File 'lib/the_castle_client.rb', line 25 def account_data(id, opts={}); query(id, 'account', '', opts); end |
.piece_aggregates(id) ⇒ Object
28 |
# File 'lib/the_castle_client.rb', line 28 def piece_aggregates(id); query(id, 'piece', 'aggregates'); end |
.piece_data(id, opts = {}) ⇒ Object
27 |
# File 'lib/the_castle_client.rb', line 27 def piece_data(id, opts={}); query(id, 'piece', '', opts); end |
.popular_pieces(popular_on = Date.today, limit = 25) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/the_castle_client.rb', line 16 def popular_pieces(popular_on=Date.today, limit=25) popular_on = Date.parse(popular_on) if popular_on.is_a?(String) popular_on_s = popular_on.to_s = {'popular_on'=>popular_on_s, 'limit'=>limit} url = "/api/#{version}/pieces/popular#{to_query()}" get(url, {'Accept'=>'application/json', 'Content-Type'=>'application/json'}) end |
.query(id, model = 'account', data_type = '', options = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/the_castle_client.rb', line 10 def query(id, model='account', data_type='', ={}) raise "Invalid data type #{data_type}" unless ['aggregates', 'referrers', 'embedders', ''].include?(data_type) url = "/api/#{version}/#{model}s/#{id}/#{data_type}#{to_query()}" get(url, {'Accept'=>'application/json', 'Content-Type'=>'application/json'}) end |