lib/restful_model_collection.rb in inbox-0.13.0 vs lib/restful_model_collection.rb in inbox-0.14.0
- old
+ new
@@ -25,10 +25,17 @@
offset += results.length
finished = results.length < chunk_size
end
end
+ def count
+ RestClient.get(url, params: @filters.merge(view: 'count')) { |response,request,result|
+ json = Inbox.interpret_response(result, response)
+ return json['count']
+ }
+ end
+
def first
get_model_collection.first
end
def all
@@ -69,11 +76,11 @@
get_model(id)
end
def build(args)
for key in args.keys
- args[key.to_s] = args[key]
+ args[key.to_s] = args[key]
end
model = @model_class.new(@_api, @namespace_id)
model.inflate(args)
model
end
@@ -127,7 +134,16 @@
models = inflate_collection(items)
}
models
end
+ end
+
+ # a ManagementModelCollection is similar to a RestfulModelCollection except
+ # it's used by models under the /a/<app_id> namespace (mostly account status
+ # and billing methods).
+ class ManagementModelCollection < RestfulModelCollection
+ def url
+ @_api.url_for_management
+ end
end
end