contacts_client 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/app/models/padma_contact.rb +26 -0
  2. metadata +2 -2
@@ -261,4 +261,30 @@ class PadmaContact < LogicalModel
261
261
  end
262
262
  end
263
263
 
264
+ ##
265
+ # Same parameters as search. Returns average age for scoped contacts
266
+ #
267
+ # Parameters:
268
+ # @param options [Hash].
269
+ # Valid options are:
270
+ # * all other options will be sent in :params to WebService
271
+ #
272
+ # Usage:
273
+ # -- Average age of students at 2014-3-31
274
+ # Person.average_age(account_name: 'martinez', status: 'student', local_status: 'student', )
275
+ def self.average_age(options = {})
276
+ options = self.merge_key(options)
277
+
278
+ response = Typhoeus.post(self.resource_uri+'/calculate/average_age', body: options)
279
+
280
+ if response.success?
281
+ log_ok(response)
282
+ resp = ActiveSupport::JSON.decode(response.body)
283
+ return resp['result'].to_f
284
+ else
285
+ log_failed(response)
286
+ return nil
287
+ end
288
+ end
289
+
264
290
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contacts_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-18 00:00:00.000000000 Z
12
+ date: 2014-03-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties