rapleaf_api 0.1.0 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.md +3 -3
  2. data/lib/api/person.rb +58 -5
  3. metadata +1 -1
data/README.md CHANGED
@@ -46,6 +46,6 @@ Usage
46
46
  Authors
47
47
  -------
48
48
 
49
- * Adam Coffman :: coffman.adam@gmail.com
50
- * Brent Beer :: brentbeer@gmail.com
51
- * Mark Sands :: marksands07@gmail.com
49
+ * [Adam Coffman](http://github.com/thecoffman) :: coffman.adam@gmail.com
50
+ * [Brent Beer](http://github.com/brntbeer) :: brentbeer@gmail.com
51
+ * [Mark Sands](http://github.com/marksands) :: marksands07@gmail.com
data/lib/api/person.rb CHANGED
@@ -3,17 +3,70 @@ module RapleafApi
3
3
  class Person
4
4
 
5
5
  def initialize(xml)
6
- @xml = XmlSimple.xml_in(xml)
7
- end
8
-
9
- def xml
10
- @xml
6
+ @xml = XmlSimple.xml_in(xml, {'ForceArray' => false,
7
+ 'GroupTags' =>{'primary' => 'membership',
8
+ 'supplemental' => 'membership',
9
+ 'universities' => 'university',
10
+ 'occupations' =>'occupation'}})
11
11
  end
12
12
 
13
13
  def rapleaf_id
14
14
  @xml["id"]
15
15
  end
16
16
 
17
+ def basics
18
+ @xml["basics"]
19
+ end
20
+
21
+ def name
22
+ @xml["basics"]["name"]
23
+ end
24
+
25
+ def age
26
+ @xml["basics"]["age"]
27
+ end
28
+
29
+ def gender
30
+ @xml["basics"]["gender"]
31
+ end
32
+
33
+ def location
34
+ @xml["basics"]["location"]
35
+ end
36
+
37
+ def occupations
38
+ @xml["basics"]["occupations"]
39
+ end
40
+
41
+ def universities
42
+ @xml["basics"]["universities"]
43
+ end
44
+
45
+ def earliest_known_activity
46
+ @xml["basics"]["earliest_known_activity"]
47
+ end
48
+
49
+ def last_known_activity
50
+ @xml["basics"]["latest_known_activity"]
51
+ end
52
+
53
+ def num_friends
54
+ @xml["basics"]["num_friends"]
55
+ end
56
+
57
+ def memberships(selection = :all)
58
+ if selection == :primary || selection == :all
59
+ memberships = (@xml["memberships"]["primary"])
60
+ end
61
+ if selection == :supplemental || selection == :all
62
+ if memberships.nil?
63
+ memberships = (@xml["memberships"]["supplemental"])
64
+ else
65
+ memberships << (@xml["memberships"]["supplemental"])
66
+ end
67
+ end
68
+ memberships.compact
69
+ end
17
70
  end
18
71
 
19
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapleaf_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Coffman