your_membership 1.0.0
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 +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +261 -0
- data/Rakefile +2 -0
- data/lib/httparty/patch.rb +33 -0
- data/lib/your_membership/base.rb +197 -0
- data/lib/your_membership/commerce.rb +25 -0
- data/lib/your_membership/config.rb +41 -0
- data/lib/your_membership/convert.rb +24 -0
- data/lib/your_membership/error.rb +21 -0
- data/lib/your_membership/events.rb +60 -0
- data/lib/your_membership/feeds.rb +37 -0
- data/lib/your_membership/member.rb +397 -0
- data/lib/your_membership/members.rb +124 -0
- data/lib/your_membership/people.rb +38 -0
- data/lib/your_membership/profile.rb +85 -0
- data/lib/your_membership/sa.rb +6 -0
- data/lib/your_membership/sa_auth.rb +34 -0
- data/lib/your_membership/sa_certifications.rb +22 -0
- data/lib/your_membership/sa_commerce.rb +22 -0
- data/lib/your_membership/sa_events.rb +66 -0
- data/lib/your_membership/sa_export.rb +195 -0
- data/lib/your_membership/sa_groups.rb +30 -0
- data/lib/your_membership/sa_member.rb +49 -0
- data/lib/your_membership/sa_members.rb +179 -0
- data/lib/your_membership/sa_nonmembers.rb +41 -0
- data/lib/your_membership/sa_people.rb +92 -0
- data/lib/your_membership/session.rb +147 -0
- data/lib/your_membership/version.rb +3 -0
- data/lib/your_membership.rb +37 -0
- data/spec/lib/profile_spec.rb +197 -0
- data/spec/spec_helper.rb +78 -0
- data/your_membership.gemspec +30 -0
- metadata +155 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
module YourMembership
|
2
|
+
# YourMembership Events Namespace
|
3
|
+
class Events < YourMembership::Base
|
4
|
+
# Returns a list of Community Events based on the supplied search term.
|
5
|
+
#
|
6
|
+
# @see https://api.yourmembership.com/reference/2_00/Events_All_Search.htm
|
7
|
+
#
|
8
|
+
# @param [YourMembership::Session] session
|
9
|
+
# @param [Hash] options
|
10
|
+
# @option options [String] :SearchText Text to be searched.
|
11
|
+
# @option options [Integer] :PageSize The maximum number of records in the returned result set.
|
12
|
+
# @option options [Integer] :StartRecord The record number at which to start the returned result set.
|
13
|
+
# @return [Array] Returns an Array of Hashes representing events based on a search result.
|
14
|
+
def self.all_search(session, options = {})
|
15
|
+
# Options include :SearchText(String), :PageSize(Integer), :StartRecord(Integer)
|
16
|
+
|
17
|
+
response = post('/', :body => build_XML_request('Events.All.Search', session, options))
|
18
|
+
|
19
|
+
response_valid? response
|
20
|
+
response_to_array_of_hashes response['YourMembership_Response']['Events.All.Search'], ['Results', 'Item']
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns a list of all Attendees for the specified event including both Registrations and RSVPs. If the Event
|
24
|
+
# Registration contains a related Custom Form, the form data will be included in the <DataSet> element as it is
|
25
|
+
# stored in our database. Records for authenticated members also include the <ID> element to cross reference the
|
26
|
+
# Member's data.
|
27
|
+
#
|
28
|
+
# @see https://api.yourmembership.com/reference/2_00/Events_Event_Attendees_Get.htm
|
29
|
+
#
|
30
|
+
# @param [YourMembership::Session] session
|
31
|
+
# @param [Integer] event_id An Event ID for which to return event details.
|
32
|
+
# @return [Array] Returns an Array of Hashes representing the attendees to a specific event.
|
33
|
+
def self.event_attendees_get(session, event_id)
|
34
|
+
options = {}
|
35
|
+
options[:EventID] = event_id
|
36
|
+
|
37
|
+
response = post('/', :body => build_XML_request('Events.Event.Attendees.Get', session, options))
|
38
|
+
|
39
|
+
response_valid? response
|
40
|
+
response_to_array_of_hashes response['YourMembership_Response']['Events.Event.Attendees.Get'], ['Attendees', 'Attendee']
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns details about the provided Event ID.
|
44
|
+
#
|
45
|
+
# @see https://api.yourmembership.com/reference/2_00/Events_Event_Get.htm
|
46
|
+
#
|
47
|
+
# @param [YourMembership::Session] session
|
48
|
+
# @param [Integer] event_id An Event ID for which to return event details.
|
49
|
+
# @return [Hash] Returns a Hash of details about a particular event.
|
50
|
+
def self.event_get(session, event_id)
|
51
|
+
options = {}
|
52
|
+
options[:EventID] = event_id
|
53
|
+
|
54
|
+
response = post('/', :body => build_XML_request('Events.Event.Get', session, options))
|
55
|
+
|
56
|
+
response_valid? response
|
57
|
+
response['YourMembership_Response']['Events.Event.Get'].to_h
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module YourMembership
|
2
|
+
# YourMembership Feeds Namespace
|
3
|
+
class Feeds < YourMembership::Base
|
4
|
+
# Returns a list of RSS 2.0 community feeds.
|
5
|
+
#
|
6
|
+
# @see https://api.yourmembership.com/reference/2_00/Feeds_Get.htm
|
7
|
+
#
|
8
|
+
# @param [YourMembership::Session] session
|
9
|
+
# @return [Array] Returns an Array of Hashes representing all of your community's feeds.
|
10
|
+
def self.get(session)
|
11
|
+
response = post('/', :body => build_XML_request('Feeds.Get', session))
|
12
|
+
|
13
|
+
response_valid? response
|
14
|
+
response_to_array_of_hashes response['YourMembership_Response']['Feeds.Get'], ['Feed']
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns a RSS 2.0 community feed
|
18
|
+
#
|
19
|
+
# @see https://api.yourmembership.com/reference/2_00/Feeds_Feed_Get.htm
|
20
|
+
#
|
21
|
+
# @param [YourMembership::Session] session
|
22
|
+
# @param [String] feed_id ID of the Feed to be returned.
|
23
|
+
# @param [Hash] options
|
24
|
+
# @option options [Integer] :PageSize The maximum number of records in the returned result set.
|
25
|
+
# @option options [Integer] :StartRecord The record number at which to start the returned result set.
|
26
|
+
# @return [Nokogiri::XML] Returns a Nokogiri XML document that represents an rss feed
|
27
|
+
def self.feed_get(session, feed_id, options = {})
|
28
|
+
options[:FeedID] = feed_id
|
29
|
+
|
30
|
+
response = post('/', :body => build_XML_request('Feeds.Feed.Get', session, options))
|
31
|
+
|
32
|
+
response_valid? response
|
33
|
+
xml_body = Nokogiri::XML response.body
|
34
|
+
xml_body.at_xpath '//rss'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,397 @@
|
|
1
|
+
module YourMembership
|
2
|
+
# The member object provides a convenient abstraction that encapsulates the member methods and caches some basic
|
3
|
+
# details about the member.
|
4
|
+
#
|
5
|
+
# @attr_reader [String] id The API ID of the member.
|
6
|
+
# @attr_reader [String] website_id The WebsiteID of the member which is used to construct urls for member navigation.
|
7
|
+
# @attr_reader [String] full_name The COMPUTED full_name of the member. This is implemented through the full_name
|
8
|
+
# method so as to allow this method to be easily overridden if a different format is desired.
|
9
|
+
# @attr [String] first_name The First Name of the member.
|
10
|
+
# @attr [String] last_name The Last Name of the member.
|
11
|
+
# @attr [String] email The email address associated with the member.
|
12
|
+
# @attr [YourMembership::Session] session The Session object bound to this member through authentication.
|
13
|
+
# @attr [YourMembership::Profile] profile A session object bound to this member object. This must be set manually.
|
14
|
+
class Member < YourMembership::Base
|
15
|
+
attr_reader :id, :website_id
|
16
|
+
attr_accessor :first_name, :last_name, :email, :session, :profile
|
17
|
+
|
18
|
+
# Member Initializer - Use Member.create_from_session or Member.create_by_authentication to instantiate
|
19
|
+
# objects of this type.
|
20
|
+
#
|
21
|
+
# @note There is not yet a compelling reason to call Member.new() directly, however it can be done.
|
22
|
+
#
|
23
|
+
# @param [String] id The API ID of the member.
|
24
|
+
# @param [String] website_id The WebsiteID of the member which is used to construct urls for member navigation.
|
25
|
+
# @param [String] first_name The First Name of the member.
|
26
|
+
# @param [String] last_name The Last Name of the member.
|
27
|
+
# @param [String] email The email address associated with the member.
|
28
|
+
# @param [YourMembership::Session, Nil] session The Session object bound to this member through authentication.
|
29
|
+
def initialize(id, website_id, first_name, last_name, email, session = nil)
|
30
|
+
@id = id
|
31
|
+
@website_id = website_id
|
32
|
+
@first_name = first_name
|
33
|
+
@last_name = last_name
|
34
|
+
@email = email
|
35
|
+
@session = session
|
36
|
+
@profile = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
# Format name parts in to a full name string.
|
40
|
+
# If you wish different behavior (perhaps 'last_name, first_name') this method should be overridden.
|
41
|
+
#
|
42
|
+
# @return [string] Returns a formatted name.
|
43
|
+
def full_name
|
44
|
+
@first_name + ' ' + @last_name
|
45
|
+
end
|
46
|
+
|
47
|
+
# Allow an instance to call all class methods (unless they are specifically restricted) and pass the session and
|
48
|
+
# arguments of the current object.
|
49
|
+
def method_missing(name, *args)
|
50
|
+
if [:create_by_authentication, :create_from_session].include? name
|
51
|
+
raise NoMethodError.new("Cannot call method #{name} on class #{self.class} because it is specifically denied.", 'Method Protected')
|
52
|
+
else
|
53
|
+
self.class.send(name, @session, *args)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Creates a new Member object through username and password authentication.
|
58
|
+
# @param [String] username The username in cleartext
|
59
|
+
# @param [String] password The password in cleartext
|
60
|
+
# @return [YourMembership::Member] Returns a new Member object with associated authenticated Session object
|
61
|
+
def self.create_by_authentication(username, password)
|
62
|
+
session = YourMembership::Session.new username, password
|
63
|
+
create_from_session(session)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Creates a new Member object from a previously authenticated Session object.
|
67
|
+
# @param [YourMembership::Session] session A previously authenticated Session.
|
68
|
+
# @return [YourMembership::Member] Returns a new Member object
|
69
|
+
def self.create_from_session(session)
|
70
|
+
profile = profile_getMini session
|
71
|
+
new(
|
72
|
+
profile['ID'],
|
73
|
+
profile['WebsiteID'],
|
74
|
+
profile['FirstName'],
|
75
|
+
profile['LastName'],
|
76
|
+
profile['EmailAddr'],
|
77
|
+
session
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Returns a list of Certifications for the specified user.
|
82
|
+
#
|
83
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Certifications_Get.htm
|
84
|
+
#
|
85
|
+
# @param [YourMembership::Session] session
|
86
|
+
# @param [Hash] options
|
87
|
+
# @option options [Boolean] :IsArchived Include archived certification records in the returned result. Default: True
|
88
|
+
#
|
89
|
+
# @return [Array] An Array of Hashes representing the Certifications of the authenticated user.
|
90
|
+
def self.certifications_get(session, options = {})
|
91
|
+
response = post('/', :body => build_XML_request('Member.Certifications.Get', session, options))
|
92
|
+
|
93
|
+
response_valid? response
|
94
|
+
response_to_array_of_hashes response['YourMembership_Response']['Member.Certifications.Get'], ['Certification']
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns a list of Certification Journal Entries for the signed in user that may be optionally filterd by date,
|
98
|
+
# expiration, and paging.
|
99
|
+
#
|
100
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Certifications_Journal_Get.htm
|
101
|
+
#
|
102
|
+
# @param [YourMembership::Session] session
|
103
|
+
# @param [Hash] options
|
104
|
+
# @option options [Boolean] :ShowExpired Include expired journal entries in the returned result.
|
105
|
+
# @option options [DateTime] :StartDate Only include Journal Entries that are newer that the supplied date.
|
106
|
+
# @option options [Integer] :EntryID Filter the returned results by sequential EntryID. Only those Certification
|
107
|
+
# Journals which have an EntryID greater than the supplied integer will be returned.
|
108
|
+
# @option options [String] :CertificationID Filter the Journal Entries returned by the specified Certification ID.
|
109
|
+
# @option options [Integer] :PageSize The number of items that are returned per call of this method.
|
110
|
+
# Default is 200 entries.
|
111
|
+
# @option options [Integer] :PageNumber PageNumber can be used to retrieve multiple result sets.
|
112
|
+
# Page 1 is returned by default.
|
113
|
+
#
|
114
|
+
# @return [Array] An Array of Hashes representing the Certification Journal Entries of the authenticated user.
|
115
|
+
def self.certifications_journal_get(session, options = {})
|
116
|
+
response = post('/', :body => build_XML_request('Member.Certifications.Journal.Get', session, options))
|
117
|
+
|
118
|
+
response_valid? response
|
119
|
+
response_to_array_of_hashes response['YourMembership_Response']['Member.Certifications.Journal.Get'], ['Entry']
|
120
|
+
end
|
121
|
+
|
122
|
+
# Returns a list of order IDs for the authenticated user that may be optionally filtered by timestamp and status.
|
123
|
+
#
|
124
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Commerce_Store_GetOrderIDs.htm
|
125
|
+
#
|
126
|
+
# @param [YourMembership::Session] session
|
127
|
+
# @param [Hash] options
|
128
|
+
# @option options [DateTime] :Timestamp Filter the returned results by date/time. Only those orders which were
|
129
|
+
# placed after the supplied date/time will be returned.
|
130
|
+
# @option options [Symbol, Integer] :Status Filter the returned results by Status.
|
131
|
+
# (-1 = :Cancelled; 0 = :open; 1 = :processed; 2 = :shipped or :closed)
|
132
|
+
#
|
133
|
+
# @return [Array] A list of Invoice Id Strings for the authenticated user.
|
134
|
+
def self.commerce_store_getOrderIDs(session, options = {}) # rubocop:disable Style/MethodName
|
135
|
+
if options[:Status]
|
136
|
+
options[:Status] = YourMembership::Commerce.convert_order_status(options[:Status])
|
137
|
+
end
|
138
|
+
|
139
|
+
response = post('/', :body => build_XML_request('Member.Commerce.Store.GetOrderIDs', session, options))
|
140
|
+
|
141
|
+
response_valid? response
|
142
|
+
response_to_array response['YourMembership_Response']['Member.Commerce.Store.GetOrderIDs']['Orders'], ['Order'], 'InvoiceID'
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns the order details, including line items and products ordered, of a store order placed by the authenticated
|
146
|
+
# member.
|
147
|
+
#
|
148
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Commerce_Store_Order_Get.htm
|
149
|
+
#
|
150
|
+
# @param [YourMembership::Session] session
|
151
|
+
# @param [String] invoiceID The Invoice ID of the store order to be returned.
|
152
|
+
# @return [Hash] Returns a Hash representing a users order referenced by the invoiceID
|
153
|
+
#
|
154
|
+
# @note This method depends on the HTTParty Monkey Patch that HTML Decodes response bodies before parsing.
|
155
|
+
# YourMembership returns invalid XML when embedding <![CDATA] elements.
|
156
|
+
def self.commerce_store_order_get(session, invoiceID)
|
157
|
+
options = {}
|
158
|
+
options[:InvoiceID] = invoiceID
|
159
|
+
|
160
|
+
response = post('/', :body => build_XML_request('Member.Commerce.Store.Order.Get', session, options))
|
161
|
+
|
162
|
+
response_valid? response
|
163
|
+
response_to_array_of_hashes response['YourMembership_Response']['Member.Commerce.Store.Order.Get'], ['Order']
|
164
|
+
end
|
165
|
+
|
166
|
+
# Approves or declines a connection request.
|
167
|
+
#
|
168
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Connection_Approve.htm
|
169
|
+
#
|
170
|
+
# @param [YourMembership::Session] session
|
171
|
+
# @param [String] id ID or Profile ID of the member to approve/decline.
|
172
|
+
# @param [Boolean] approve 0 or 1 to decline or approve a connection 0 = Decline, 1 = Approve
|
173
|
+
def self.connection_approve(session, id, approve)
|
174
|
+
options = {}
|
175
|
+
options[:ID] = id
|
176
|
+
options[:Approve] = approve
|
177
|
+
response = post('/', :body => build_XML_request('Member.Connection.Approve', session, options))
|
178
|
+
response_valid? response
|
179
|
+
end
|
180
|
+
|
181
|
+
# Creates An XML Body for submission with a file to the authenticated member's media gallery.
|
182
|
+
# Valid files must be an RGB image in GIF, JPEG or PNG format.
|
183
|
+
# API requests must be submitted as multipart/form-data with the XML API request submitted in the named field value
|
184
|
+
# XMLMessage. This function returns a string that can be embedded as this field value.
|
185
|
+
#
|
186
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_MediaGallery_Upload.htm
|
187
|
+
#
|
188
|
+
# @param [YourMembership::Session] session
|
189
|
+
# @param [Hash] options
|
190
|
+
# @option options [Integer] :AlbumID AlbumID of the media gallery item to submit to.
|
191
|
+
# @option options [String] :Caption Caption to be associated with the media gallery item. (Limited to 150 Chars.)
|
192
|
+
# @option options [String] :AllowComments Setting for allowing comments. Available values are:
|
193
|
+
# :all = Comments are allowed
|
194
|
+
# :connections = Comments limited to a member's connections
|
195
|
+
# :none = Comments not allowed
|
196
|
+
# @option options [Boolean] :IsPublic Setting for allowing anonymous visitors to view uploaded photos for public
|
197
|
+
# member types. True makes the image visible to everyone, False makes the image only available to Members.
|
198
|
+
# @return [String] This string should be submitted as the XMLMessage field in a multipart/form-data post to
|
199
|
+
# https://api.yourmembership.com/
|
200
|
+
def self.mediaGallery_upload(session, options = {}) # rubocop:disable Style/MethodName
|
201
|
+
build_XML_request('Member.MediaGallery.Upload', session, options)
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns a list of messages from the authenticated member's Inbox. Returns a maximum of 100 records per request.
|
205
|
+
#
|
206
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Messages_GetInbox.htm
|
207
|
+
#
|
208
|
+
# @param [YourMembership::Session] session
|
209
|
+
# @param [Hash] options
|
210
|
+
# @option options [Integer] :PageSize The maximum number of records in the returned result set.
|
211
|
+
# @option options [Integer] :StartRecord The record number at which to start the returned result set.
|
212
|
+
# @return [Array] Returns an Array of Hashes representing a member's inbox messages
|
213
|
+
#
|
214
|
+
# @note BUG WORKAROUND: The API documentation indicates that GetInbox should return an <GetInbox> XML structure, but
|
215
|
+
# instead it returns <Get.Inbox>
|
216
|
+
def self.messages_getInbox(session, options = {}) # rubocop:disable Style/MethodName
|
217
|
+
response = post('/', :body => build_XML_request('Member.Messages.GetInbox', session, options))
|
218
|
+
|
219
|
+
response_valid? response
|
220
|
+
response_to_array_of_hashes response['YourMembership_Response']['Members.Messages.Get.Inbox'], ['Message']
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns a list of messages from the authenticated member's Sent folder, Returns a maximum of 100 records per
|
224
|
+
# request.
|
225
|
+
#
|
226
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Messages_GetSent.htm
|
227
|
+
#
|
228
|
+
# @param [YourMembership::Session] session
|
229
|
+
# @param [Hash] options
|
230
|
+
# @option options [Integer] :PageSize The maximum number of records in the returned result set.
|
231
|
+
# @option options [Integer] :StartRecord The record number at which to start the returned result set.
|
232
|
+
# @return [Array] Returns an Array of Hashes representing a member's sent messages
|
233
|
+
#
|
234
|
+
# @note BUG WORKAROUND: The API documentation indicates that GetInbox should return an <GetSent> XML structure, but
|
235
|
+
# instead it returns <Get.Sent>
|
236
|
+
def self.messages_getSent(session, options = {}) # rubocop:disable Style/MethodName
|
237
|
+
response = post('/', :body => build_XML_request('Member.Messages.GetSent', session, options))
|
238
|
+
|
239
|
+
response_valid? response
|
240
|
+
response_to_array_of_hashes response['YourMembership_Response']['Members.Messages.Get.Sent'], ['Message']
|
241
|
+
end
|
242
|
+
|
243
|
+
# Returns an individual message by MessageID and marks it as read.
|
244
|
+
#
|
245
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Messages_Message_Read.htm
|
246
|
+
#
|
247
|
+
# @param [YourMembership::Session] session
|
248
|
+
# @param [Integer] message_id The ID of the Message to be returned.
|
249
|
+
# @return [Hash] Returns a has of all of the message's fields.
|
250
|
+
def self.messages_message_read(session, message_id)
|
251
|
+
options = {}
|
252
|
+
options[:MessageID] = message_id
|
253
|
+
response = post('/', :body => build_XML_request('Member.Messages.Message.Read', session, options))
|
254
|
+
|
255
|
+
response_valid? response
|
256
|
+
# Note that the response key is not the same as the request key, this could just be a typo in the API
|
257
|
+
response['YourMembership_Response']['Members.Messages.Message.Read']['Message']
|
258
|
+
end
|
259
|
+
|
260
|
+
# Message a member.
|
261
|
+
#
|
262
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Messages_Message_Send.htm
|
263
|
+
#
|
264
|
+
# @param [YourMembership::Session] session
|
265
|
+
# @param [String] member_id ID or ProfileID of the member to send a message.
|
266
|
+
# @param [String] subject Subject line of the message.
|
267
|
+
# @param [String] body Body of the message.
|
268
|
+
# @return [Boolean] True if successful
|
269
|
+
def self.messages_message_send(session, member_id, subject, body)
|
270
|
+
options = {}
|
271
|
+
options[:ID] = member_id
|
272
|
+
options[:Subject] = subject
|
273
|
+
options[:Body] = body
|
274
|
+
response = post('/', :body => build_XML_request('Member.Messages.Message.Send', session, options))
|
275
|
+
response_valid? response
|
276
|
+
end
|
277
|
+
|
278
|
+
# Upon validating Username or Email Address given, sends an email to matching members with a link needed to reset
|
279
|
+
# their password. This method does not require authentication.
|
280
|
+
#
|
281
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Password_InitializeReset.htm
|
282
|
+
#
|
283
|
+
# @param [YourMembership::Session] session
|
284
|
+
# @param [Hash] options
|
285
|
+
# @option options [String] :Username Username of the member
|
286
|
+
# @option options [String] :EmailAddress Email Address of the member
|
287
|
+
# @return [Boolean] Returns True if successful
|
288
|
+
def self.password_initializeReset(session, options = {}) # rubocop:disable Style/MethodName
|
289
|
+
response = post('/', :body => build_XML_request('Member.Password.InitializeReset', session, options))
|
290
|
+
response_valid? response
|
291
|
+
end
|
292
|
+
|
293
|
+
# After validating ResetToken or CurrentPassword given, this method updates the associated member's password to the
|
294
|
+
# new value. This method requires Authentication only when passing in CurrentPassword parameter.
|
295
|
+
#
|
296
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Password_Update.htm
|
297
|
+
#
|
298
|
+
# @param [YourMembership::Session] session
|
299
|
+
# @param [String] new_password The new password to use.
|
300
|
+
# @param [Hash] options
|
301
|
+
# @option options [String] :CurrentPassword Member's current password. The API request must be Authenticated when
|
302
|
+
# using this parameter. Used when members are signed in, but want to change their password.
|
303
|
+
# @option options [String] :ResetToken Reset Token from the Password Reset email.
|
304
|
+
# @return [Boolean] Returns True if successful
|
305
|
+
def self.password_update(session, new_password, options = {})
|
306
|
+
options[:NewPassword] = new_password
|
307
|
+
response = post('/', :body => build_XML_request('Member.Password.Update', session, options))
|
308
|
+
response_valid? response
|
309
|
+
end
|
310
|
+
|
311
|
+
# Returns the authenticated member's profile data.
|
312
|
+
#
|
313
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Profile_Get.htm
|
314
|
+
#
|
315
|
+
# @param [YourMembership::Session] session
|
316
|
+
# @return [YourMembership::Profile] Returns a Profile object that represents the person's profile
|
317
|
+
def self.profile_get(session)
|
318
|
+
response = post('/', :body => build_XML_request('Member.Profile.Get', session))
|
319
|
+
|
320
|
+
response_valid? response
|
321
|
+
YourMembership::Profile.new response['YourMembership_Response']['Member.Profile.Get']
|
322
|
+
end
|
323
|
+
|
324
|
+
# Returns a subset of the authenticated member's profile data along with statistics and permissions for the purpose
|
325
|
+
# of creating a profile snapshot and navigation control.
|
326
|
+
#
|
327
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Profile_Get.htm
|
328
|
+
#
|
329
|
+
# @param [YourMembership::Session] session
|
330
|
+
# @return [Hash] Returns a Hash of details and permissions for the authenticated user.
|
331
|
+
def self.profile_getMini(session) # rubocop:disable Style/MethodName
|
332
|
+
response = post('/', :body => build_XML_request('Member.Profile.GetMini', session))
|
333
|
+
|
334
|
+
response_valid? response
|
335
|
+
response['YourMembership_Response']['Member.Profile.GetMini']
|
336
|
+
end
|
337
|
+
|
338
|
+
# Post to a member's wall.
|
339
|
+
#
|
340
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_Wall_Post.htm
|
341
|
+
#
|
342
|
+
# @param [YourMembership::Session] session
|
343
|
+
# @param [String] post_text Text to post on the member's wall.
|
344
|
+
# @param [String] id ID or ProfileID of any member that is connected to the authenticated member whose wall to post
|
345
|
+
# on. Omit this argument to post on the authenticated member's own wall.
|
346
|
+
# @return [Boolean] True if successful
|
347
|
+
def self.wall_post(session, post_text, id = nil)
|
348
|
+
options = {}
|
349
|
+
options[:ID] = id if id
|
350
|
+
options[:PostText] = post_text
|
351
|
+
response = post('/', :body => build_XML_request('Member.Wall.Post', session, options))
|
352
|
+
response_valid? response
|
353
|
+
end
|
354
|
+
|
355
|
+
# Validates that the current session has been authenticated by returning the authenticated member's ID.
|
356
|
+
#
|
357
|
+
# @see https://api.yourmembership.com/reference/2_00/Member_IsAuthenticated.htm
|
358
|
+
#
|
359
|
+
# @param [YourMembership::Session] session
|
360
|
+
# @return [String] if provided session is authenticated returns the members's ID
|
361
|
+
# @return [Nil] if provided session is not authenticated
|
362
|
+
# returns nil.
|
363
|
+
def self.isAuthenticated(session) # rubocop:disable Style/MethodName
|
364
|
+
response = post('/', :body => build_XML_request('Member.IsAuthenticated', session))
|
365
|
+
|
366
|
+
# Fail on HTTP Errors
|
367
|
+
raise HTTParty::ResponseError.new(response), 'Connection to YourMembership API failed.' unless response.success?
|
368
|
+
|
369
|
+
error_code = response['YourMembership_Response']['ErrCode']
|
370
|
+
|
371
|
+
# Error Code 202 means that the session itself has expired, we don't
|
372
|
+
# want to throw an exception for that, just return that the session is
|
373
|
+
# not authenticated.
|
374
|
+
return nil if error_code == '202'
|
375
|
+
|
376
|
+
# Error Code 403 means that the method requires Authentication, if the
|
377
|
+
# call is not authenticated then the session cannot be authenticated.
|
378
|
+
return nil if error_code == '403'
|
379
|
+
|
380
|
+
# All Error Codes other than 403 inidicate an unrecoverable issue that
|
381
|
+
# we need to raise an exception for.
|
382
|
+
raise YourMembership::Error.new(
|
383
|
+
response['YourMembership_Response']['ErrCode'],
|
384
|
+
response['YourMembership_Response']['ErrDesc']
|
385
|
+
) if error_code != '0'
|
386
|
+
|
387
|
+
if response['YourMembership_Response']['Member.IsAuthenticated']
|
388
|
+
# If everything is ok retun the authenticated users ID
|
389
|
+
return response['YourMembership_Response']['Member.IsAuthenticated']['ID']
|
390
|
+
else
|
391
|
+
# If there is no ID in the data returned then the session is not
|
392
|
+
# authenticated.
|
393
|
+
nil
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
module YourMembership
|
2
|
+
# YourMembership Members Namespace
|
3
|
+
class Members < YourMembership::Base
|
4
|
+
# Returns a member's connection category list.
|
5
|
+
#
|
6
|
+
# @see https://api.yourmembership.com/reference/2_00/Members_Connections_Categories_Get.htm
|
7
|
+
#
|
8
|
+
# @param [YourMembership::Session] session
|
9
|
+
# @param [String] member_id or ProfileID of the member's connections to get.
|
10
|
+
# @return [Array] Returns an Array of Hashes representing a member's connection categories.
|
11
|
+
# @note If you attempt to retrieve a member's connection category list and they have not assigned any connections to
|
12
|
+
# categories an execption of type 406 from YourMembership.com 'Method could not uniquely identify a record on which
|
13
|
+
# to operate' will be raised.
|
14
|
+
def self.connections_categories_get(session, member_id)
|
15
|
+
options = {}
|
16
|
+
options[:ID] = member_id
|
17
|
+
response = post('/', :body => build_XML_request('Members.Connections.Categories.Get', session, options))
|
18
|
+
|
19
|
+
response_valid? response
|
20
|
+
response_to_array_of_hashes response['YourMembership_Response']['Members.Connections.Categories.Get'], ['Category']
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns a member's connection list, optionally filtered by category. Returns a maximum of 100 records per request.
|
24
|
+
#
|
25
|
+
# @see https://api.yourmembership.com/reference/2_00/Members_Connections_Get.htm
|
26
|
+
#
|
27
|
+
# @param [YourMembership::Session] session
|
28
|
+
# @param [String] member_id or ProfileID of the member's connections to get.
|
29
|
+
# @param [Hash] options
|
30
|
+
# @option options [Integer] :CategoryID Filter the returned results by connection category.
|
31
|
+
# @option options [Integer] :PageSize The maximum number of records in the returned result set.
|
32
|
+
# @option options [Integer] :StartRecord The record number at which to start the returned result set.
|
33
|
+
# @return [Array] Returns an Array of Hashes representing a member's connections.
|
34
|
+
def self.connections_get(session, member_id, options = {})
|
35
|
+
options = {}
|
36
|
+
options[:ID] = member_id
|
37
|
+
response = post('/', :body => build_XML_request('Members.Connections.Get', session, options))
|
38
|
+
|
39
|
+
response_valid? response
|
40
|
+
response_to_array_of_hashes response['YourMembership_Response']['Members.Connections.Get'], ['Connection']
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns a member's media gallery album list. The returned list will include <AlbumID>-1</AlbumID> which is a
|
44
|
+
# virtual album containing all of the member's media gallery items.
|
45
|
+
#
|
46
|
+
# @see https://api.yourmembership.com/reference/2_00/Members_MediaGallery_Albums_Get.htm
|
47
|
+
#
|
48
|
+
# @param [YourMembership::Session] session
|
49
|
+
# @param [String] member_id or ProfileID of the member whose media gallery albums to return.
|
50
|
+
# @return [Array] Returns an Array of Hashes representing a member's albums.
|
51
|
+
# @note BUG NOTED - This method seems to raise an exception on every call saying that Method Call Failed one or more
|
52
|
+
# elements is missing or invalid
|
53
|
+
# @todo Contact YourMembership.com dev team to see if we're doing this correctly.
|
54
|
+
def self.mediaGallery_albums_get(session, member_id) # rubocop:disable Style/MethodName
|
55
|
+
options = {}
|
56
|
+
options[:ID] = member_id
|
57
|
+
# puts build_XML_request('Members.MediaGallery.Albums.Get', session, options)
|
58
|
+
response = post('/', :body => build_XML_request('Members.MediaGallery.Albums.Get', session, options))
|
59
|
+
|
60
|
+
response_valid? response
|
61
|
+
response_to_array_of_hashes response['YourMembership_Response']['Members.MediaGallery.Albums.Get'], ['Album']
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns a member's media gallery item list, optionally filtered by album. Returns a maximum of 100 records per
|
65
|
+
# request.
|
66
|
+
#
|
67
|
+
# @see https://api.yourmembership.com/reference/2_00/Members_MediaGallery_Get.htm
|
68
|
+
#
|
69
|
+
# @param [YourMembership::Session] session
|
70
|
+
# @param [String] member_id or ProfileID of the member whose media gallery to retrieve.
|
71
|
+
# @param [Hash] options
|
72
|
+
# @option options [String] :AlbumID Filter the returned results by media gallery album.
|
73
|
+
# @option options [Integer] :PageSize The maximum number of records in the returned result set.
|
74
|
+
# @option options [Integer] :StartRecord The record number at which to start the returned result set.
|
75
|
+
# @return [Array] Returns an Array of Hashes representing a member's media items.
|
76
|
+
# @note If you attempt to retrieve a member's gallery item list and they have no media an exception will be thrown
|
77
|
+
# of type 406 from YourMembership.com 'Method could not uniquely identify a record on which to operate'
|
78
|
+
def self.mediaGallery_get(session, member_id, options = {}) # rubocop:disable Style/MethodName
|
79
|
+
options = {}
|
80
|
+
options[:ID] = member_id
|
81
|
+
response = post('/', :body => build_XML_request('Members.MediaGallery.Get', session, options))
|
82
|
+
|
83
|
+
response_valid? response
|
84
|
+
response_to_array_of_hashes response['YourMembership_Response']['Members.MediaGallery.Get'], ['Item']
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns a single media gallery item.
|
88
|
+
#
|
89
|
+
# @see https://api.yourmembership.com/reference/2_00/Members_MediaGallery_Item_Get.htm
|
90
|
+
#
|
91
|
+
# @param [YourMembership::Session] session
|
92
|
+
# @param [String] member_id or ProfileID of the member whose media gallery item to return.
|
93
|
+
# @param [Integer] item_id of the media gallery item to return.
|
94
|
+
# @return [Hash] Returns an Hash that represents a single media item.
|
95
|
+
def self.mediaGallery_item_get(session, member_id, item_id) # rubocop:disable Style/MethodName
|
96
|
+
options = {}
|
97
|
+
options[:ID] = member_id
|
98
|
+
options[:ItemID] = item_id
|
99
|
+
response = post('/', :body => build_XML_request('Members.MediaGallery.Item.Get', session, options))
|
100
|
+
|
101
|
+
response_valid? response
|
102
|
+
response['YourMembership_Response']['Members.MediaGallery.Item.Get']
|
103
|
+
end
|
104
|
+
|
105
|
+
# Returns a member's wall.
|
106
|
+
#
|
107
|
+
# @see https://api.yourmembership.com/reference/2_00/Members_Wall_Get.htm
|
108
|
+
#
|
109
|
+
# @param [YourMembership::Session] session
|
110
|
+
# @param [String] member_id ID or ProfileID of the member's wall to get.
|
111
|
+
# @param [Hash] options
|
112
|
+
# @option options [Integer] :PageSize The maximum number of records in the returned result set.
|
113
|
+
# @option options [Integer] :StartRecord The record number at which to start the returned result set.
|
114
|
+
# @return [Hash] Returns a Hash representing the requested user's wall.
|
115
|
+
def self.wall_get(session, member_id, options = {})
|
116
|
+
options = {}
|
117
|
+
options[:ID] = member_id
|
118
|
+
response = post('/', :body => build_XML_request('Members.Wall.Get', session, options))
|
119
|
+
|
120
|
+
response_valid? response
|
121
|
+
response['YourMembership_Response']['Members.Wall.Get']
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module YourMembership
|
2
|
+
# YourMembership People Namespace
|
3
|
+
class People < YourMembership::Base
|
4
|
+
# Returns paged results for a search request. Returns a maximum of 100 records per request.
|
5
|
+
#
|
6
|
+
# @see https://api.yourmembership.com/reference/2_00/People_All_Search.htm
|
7
|
+
#
|
8
|
+
# @param [YourMembership::Session] session
|
9
|
+
# @param [Hash] options
|
10
|
+
# @option options [String] :SearchText Text to be searched
|
11
|
+
# @option options [Integer] :PageSize The maximum number of records in the returned result set.
|
12
|
+
# @option options [Integer] :StartRecord The record number at which to start the returned result set.
|
13
|
+
# @return [Array] Returns an Array of Hashes representing search results
|
14
|
+
def self.all_search(session, options = {})
|
15
|
+
response = post('/', :body => build_XML_request('People.All.Search', session, options))
|
16
|
+
|
17
|
+
response_valid? response
|
18
|
+
response_to_array_of_hashes response['YourMembership_Response']['People.All.Search'], ['Results', 'Item']
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns a person's profile data.
|
22
|
+
#
|
23
|
+
# @see https://api.yourmembership.com/reference/2_00/People_Profile_Get.htm
|
24
|
+
#
|
25
|
+
# @param [YourMembership::Session] session
|
26
|
+
# @param [String] id ID or ProfileID of the person's whose profile data to return.
|
27
|
+
# @return [YourMembership::Profile] Returns a Profile object that represents the person's profile
|
28
|
+
def self.profile_get(session, id)
|
29
|
+
options = {}
|
30
|
+
options['ID'] = id
|
31
|
+
|
32
|
+
response = post('/', :body => build_XML_request('People.Profile.Get', session, options))
|
33
|
+
|
34
|
+
response_valid? response
|
35
|
+
YourMembership::Profile.new response['YourMembership_Response']['People.Profile.Get']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|