mais_person_client 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -2
- data/lib/mais_person_client/person.rb +13 -0
- data/lib/mais_person_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b872fec73c13f1df1ab4cb1fec9cf729502eafb10b5924d0082347e1258b7eb
|
4
|
+
data.tar.gz: 9e13fe7906ba9c46ed96fea26434c290349f27b5f7caf4f5c9f8b6035223f12c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ab061800050aaa112c0205ce54cbec61f8bdb257a95bb753a0b392ef13c7293c4abe4ac4e03f925e55e3e2f5bf0a8197d63b97ded760e77ea16ac4650262eb2
|
7
|
+
data.tar.gz: 788c40c60b666ddcc582a7168f7aa85309b7004db61b253efdcf727f19b1281925665023f37951e73ec1a99bf1490cc812493a746f723b303b2a832cd92a6920
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -37,10 +37,15 @@ client = MaisPersonClient.configure(
|
|
37
37
|
base_url: Settings.mais_person.base_url,
|
38
38
|
user_agent: 'some-user-agent-string-to-send-in-requests' # defaults to 'stanford-library'
|
39
39
|
)
|
40
|
-
client.fetch_user('nataliex') # get a single user by sunet
|
41
|
-
|
40
|
+
result = client.fetch_user('nataliex') # get a single user by sunet, returns an XML doc as a string
|
41
|
+
|
42
|
+
person = MaisPersonClient::Person.new(result) # returns a class with the XML parsed
|
43
|
+
person.sunetid
|
44
|
+
=> 'donaldduck'
|
42
45
|
```
|
43
46
|
|
47
|
+
|
48
|
+
|
44
49
|
You can also invoke methods directly on the client class, which is useful in a Rails application environment where you might initialize the client in an
|
45
50
|
initializer and then invoke client methods in many other contexts where you want to be sure configuration has already occurred, e.g.:
|
46
51
|
|
@@ -77,6 +77,19 @@ class MaisPersonClient
|
|
77
77
|
names.find { |name| name.type == 'display' }
|
78
78
|
end
|
79
79
|
|
80
|
+
# Name component helpers
|
81
|
+
def first_name
|
82
|
+
registered_name&.first_name
|
83
|
+
end
|
84
|
+
|
85
|
+
def middle_name
|
86
|
+
registered_name&.middle
|
87
|
+
end
|
88
|
+
|
89
|
+
def last_name
|
90
|
+
registered_name&.last
|
91
|
+
end
|
92
|
+
|
80
93
|
# Titles (multiple possible)
|
81
94
|
def titles
|
82
95
|
xml.xpath('//title').map do |title_node|
|