your_membership 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,179 @@
|
|
1
|
+
module YourMembership
|
2
|
+
module Sa
|
3
|
+
# YourMembership System Administrator Members Namespace
|
4
|
+
class Members < YourMembership::Base
|
5
|
+
# Returns a list of member IDs that may be optionally filtered by timestamp, and/or group membership. This
|
6
|
+
# method is provided for data synchronization purposes and will return a maximum of 10,000 results. It would
|
7
|
+
# typically be used in conjunction with subsequent calls to Sa.People.Profile.Get for each <ID> returned.
|
8
|
+
#
|
9
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Members_All_GetIDs.htm
|
10
|
+
#
|
11
|
+
# @param [Hash] options
|
12
|
+
# @option options [DateTime] :Timestamp Only accounts created after the this time will be returned
|
13
|
+
# @option options [String] :WebsiteID Filter the returned results by sequential WebsiteID.
|
14
|
+
# @option options [Array] :Groups Filter the returned results by group membership. [key, value] will translate to
|
15
|
+
# <key>value</key>
|
16
|
+
#
|
17
|
+
# @return [Array] A list of API IDs for members in your community.
|
18
|
+
def self.all_getIDs(options = {}) # rubocop:disable Style/MethodName
|
19
|
+
response = post('/', :body => build_XML_request('Sa.Members.All.GetIDs', nil, options))
|
20
|
+
response_valid? response
|
21
|
+
response['YourMembership_Response']['Sa.Members.All.GetIDs']['Members']['ID']
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns a Hash of recent member activity on your YourMembership Site
|
25
|
+
# Returns member community activity information for the purpose of creating a navigation control.
|
26
|
+
#
|
27
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Members_All_RecentActivity.htm
|
28
|
+
#
|
29
|
+
# @return [Hash] A subset of data is returned for each of the following:
|
30
|
+
#
|
31
|
+
# * Newest member
|
32
|
+
# * Latest post
|
33
|
+
# * Latest comment on a post
|
34
|
+
# * Latest photo
|
35
|
+
def self.all_recentActivity # rubocop:disable Style/MethodName
|
36
|
+
response = post('/', :body => build_XML_request('Sa.Members.All.RecentActivity'))
|
37
|
+
response_valid? response
|
38
|
+
response['YourMembership_Response']['Sa.Members.All.RecentActivity'].to_h
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns a list of order IDs for a specified member that may be optionally filtered by timestamp and status.
|
42
|
+
# This method will return a maximum of 1,000 results.
|
43
|
+
#
|
44
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Members_Commerce_Store_GetOrderIDs.htm
|
45
|
+
#
|
46
|
+
# @param member_id [String] The id of the person for whom you want to retrieve data
|
47
|
+
# @param [Hash] options
|
48
|
+
# @option options [DateTime] :Timestamp Filter the returned results by date/time. Only those orders which were
|
49
|
+
# placed after the supplied date/time will be returned.
|
50
|
+
# @option options [Symbol, Integer] :Status Filter the returned results by Status.
|
51
|
+
# (-1 = :Cancelled; 0 = :open; 1 = :processed; 2 = :shipped or :closed)
|
52
|
+
#
|
53
|
+
# @return [Array] A list of Invoice Id Strings
|
54
|
+
def self.commerce_store_getOrderIDs(member_id, options = {}) # rubocop:disable Style/MethodName
|
55
|
+
options[:ID] = member_id
|
56
|
+
if options[:Status]
|
57
|
+
options[:Status] = YourMembership::Commerce.convert_order_status(options[:Status])
|
58
|
+
end
|
59
|
+
response = post('/', :body => build_XML_request('Sa.Members.Commerce.Store.GetOrderIDs', nil, options))
|
60
|
+
response_valid? response
|
61
|
+
response_to_array response['YourMembership_Response']['Sa.Members.Commerce.Store.GetOrderIDs']['Orders'], ['Order'], 'InvoiceID'
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns Event Registration details for the provided Event and Member ID. Includes all Event Registration details
|
65
|
+
# for Primary Registrant and Additional Registrants. If the Event Registration contains a related Custom Form, the
|
66
|
+
# form data will be included in the <DataSet> element as it is stored in our database.
|
67
|
+
#
|
68
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Members_Events_Event_Registration_Get.htm
|
69
|
+
#
|
70
|
+
# @param event_id [Integer] The ID number for the Event you wish to retrieve Event Registration from.
|
71
|
+
# @param member_id [Integer] Member's API ID
|
72
|
+
#
|
73
|
+
# @return [Array] Returns an Array of Hashes that represent registrations by a specific user for a specific event.
|
74
|
+
def self.events_event_registration_get(event_id, member_id) # rubocop:disable Style/MethodName
|
75
|
+
options = {}
|
76
|
+
options[:EventID] = event_id
|
77
|
+
options[:ID] = member_id
|
78
|
+
|
79
|
+
response = post('/', :body => build_XML_request('Sa.Members.Events.Event.Registration.Get', nil, options))
|
80
|
+
|
81
|
+
response_valid? response
|
82
|
+
response_to_array_of_hashes response['YourMembership_Response']['Sa.Members.Events.Event.Registration.Get'], ['Registrations', 'Registration']
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns a list of a member's referrals.
|
86
|
+
#
|
87
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Members_Referrals_Get.htm
|
88
|
+
#
|
89
|
+
# @param member_id [String] ID of the person whose referrals to return.
|
90
|
+
# @param [Hash] options
|
91
|
+
# @option options [DateTime] :Timestamp Filter the returned results by date/time. Only those referred members who
|
92
|
+
# registered after the supplied date/time will be returned.
|
93
|
+
#
|
94
|
+
# @return [Array] Returns an Array of Hashes that represent a Member's referrals
|
95
|
+
def self.referrals_get(member_id, options = {})
|
96
|
+
options[:ID] = member_id
|
97
|
+
|
98
|
+
response = post('/', :body => build_XML_request('Sa.Members.Referrals.Get', nil, options))
|
99
|
+
|
100
|
+
response_valid? response
|
101
|
+
response_to_array_of_hashes response['YourMembership_Response']['Sa.Members.Referrals.Get'], ['Member']
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns a list of a member's sub-accounts.
|
105
|
+
#
|
106
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Members_SubAccounts_Get.htm
|
107
|
+
#
|
108
|
+
# @param member_id [String] ID of the person whose sub-accounts to return.
|
109
|
+
# @param options [Hash]
|
110
|
+
# @option options [Datetime] :Timestamp Filter the returned results by date/time. Only those members who
|
111
|
+
# registered after the supplied date/time will be returned.
|
112
|
+
#
|
113
|
+
# @return [Array] Returns an Array of Hashes that represent a Member's Subaccounts
|
114
|
+
def self.subAccounts_get(member_id, options = {}) # rubocop:disable Style/MethodName
|
115
|
+
options[:ID] = member_id
|
116
|
+
|
117
|
+
response = post('/', :body => build_XML_request('Sa.Members.SubAccounts.Get', nil, options))
|
118
|
+
|
119
|
+
response_valid? response
|
120
|
+
response_to_array_of_hashes response['YourMembership_Response']['Sa.Members.SubAccounts.Get'], ['Member']
|
121
|
+
end
|
122
|
+
|
123
|
+
# Create a CEU Journal Entry.
|
124
|
+
#
|
125
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Members_Certifications_JournalEntry_Create.htm
|
126
|
+
#
|
127
|
+
# @param member_id [String] ID of the person who owns this certification journal entry.
|
128
|
+
# @param ceus_earned [Integer] The number of CEU Credits earned for this journal entry.
|
129
|
+
# @param ceus_expire_date [DateTime] The ODBC Date the CEU Credits Expire.
|
130
|
+
# @param description [String] Description of this journal entry.
|
131
|
+
# @param entry_date [DateTime] Date and time of this journal entry.
|
132
|
+
# @param options [Hash]
|
133
|
+
# @option options [String] :CertificationId The ID of the certification this journal entry is a part of. If
|
134
|
+
# neither CertificationName nor CertificationID are supplied, the journal entry will not be attached to a
|
135
|
+
# specific certification.
|
136
|
+
# @option options [String] :CertificationName For Self-Awarded certification journal entries that are not linked
|
137
|
+
# an existing certification record. This is the same behavior as choosing "Other Certification" and entering a
|
138
|
+
# Self-Awarded journal entry. If neither CertificationName nor CertificationID are supplied, the journal entry
|
139
|
+
# will not be attached to a specific certification.
|
140
|
+
# @option options [Decimal] :ScorePercent The decimal representation of a percentage score.
|
141
|
+
# For example, 90% would be 0.90.
|
142
|
+
# @option options [String] :CreditTypeCode Unique code for this new Journal Entry's Credit Type.
|
143
|
+
# If absent, the default Credit Type Code will be used.
|
144
|
+
#
|
145
|
+
# @return [Boolean] Returns true or raises exception.
|
146
|
+
def self.certifications_journalEntry_create(member_id, ceus_earned, ceus_expire_date, description, entry_date, options = {}) # rubocop:disable Style/MethodName
|
147
|
+
options['ID'] = member_id
|
148
|
+
options['CEUsEarned'] = ceus_earned
|
149
|
+
options['CEUsExpireDate'] = ceus_expire_date
|
150
|
+
options['Description'] = description
|
151
|
+
options['EntryDate'] = entry_date
|
152
|
+
|
153
|
+
response = post('/', :body => build_XML_request('Sa.Members.Certifications.JournalEntry.Create', nil, options))
|
154
|
+
response_valid? response
|
155
|
+
end
|
156
|
+
|
157
|
+
# Creates a new member profile and returns a member object.
|
158
|
+
#
|
159
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Members_Profile_Create.htm
|
160
|
+
#
|
161
|
+
# @param profile [YourMembership::Profile]
|
162
|
+
#
|
163
|
+
# @return [YourMembership::Member] A Member object for the member that was just created.
|
164
|
+
# @todo: This currently returns an authenticated session for each created user. This may not be the desired
|
165
|
+
# permanent operation of this function.
|
166
|
+
def self.profile_create(profile)
|
167
|
+
options = {}
|
168
|
+
options['profile'] = profile
|
169
|
+
response = post('/', :body => build_XML_request('Sa.Members.Profile.Create', nil, options))
|
170
|
+
response_valid? response
|
171
|
+
YourMembership::Sa::Auth.authenticate(
|
172
|
+
YourMembership::Session.new,
|
173
|
+
profile.data['Username'],
|
174
|
+
profile.data['Password']
|
175
|
+
)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module YourMembership
|
2
|
+
module Sa
|
3
|
+
# YourMembership System Administrator Members Namespace
|
4
|
+
class NonMembers < YourMembership::Base
|
5
|
+
# Returns a list of non-member IDs that may be optionally filtered by timestamp. This method is provided for data
|
6
|
+
# synchronization purposes and will return a maximum of 10,000 results. It would typically be used in conjunction
|
7
|
+
# with subsequent calls to Sa.People.Profile.Get for each ID returned.
|
8
|
+
#
|
9
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_NonMembers_All_GetIDs.htm
|
10
|
+
#
|
11
|
+
# @param [Hash] options
|
12
|
+
# @option options [DateTime] :Timestamp Only accounts created after the this time will be returned
|
13
|
+
# @option options [String] :WebsiteID Filter the returned results by sequential WebsiteID.
|
14
|
+
# @option options [Array] :Groups Filter the returned results by group membership. [key, value] will translate to
|
15
|
+
# <key>value</key>
|
16
|
+
#
|
17
|
+
# @return [Array] A list of API IDs for non-members in your community.
|
18
|
+
def self.all_getIDs(options = {}) # rubocop:disable Style/MethodName
|
19
|
+
response = post('/', :body => build_XML_request('Sa.NonMembers.All.GetIDs', nil, options))
|
20
|
+
response_valid? response
|
21
|
+
response['YourMembership_Response']['Sa.NonMembers.All.GetIDs']['NonMembers']['ID']
|
22
|
+
end
|
23
|
+
|
24
|
+
# Creates a new non-member profile and returns the new non-member's ID and WebsiteID. The returned ID must be
|
25
|
+
# supplied when performing future updates to the non-member's profile. The returned WebsiteID represents the
|
26
|
+
# numeric identifier used by the YourMembership.com application for navigation purposes.
|
27
|
+
#
|
28
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_NonMembers_Profile_Create.htm
|
29
|
+
#
|
30
|
+
# @param [YourMembership::Profile] profile
|
31
|
+
# @return [Hash] The ID and WebsiteID of the nonmember created
|
32
|
+
def self.profile_create(profile)
|
33
|
+
options = {}
|
34
|
+
options['profile'] = profile
|
35
|
+
response = post('/', :body => build_XML_request('Sa.NonMembers.Profile.Create', nil, options))
|
36
|
+
response_valid? response
|
37
|
+
response['YourMembership_Response']['Sa.NonMembers.Profile.Create']
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module YourMembership
|
2
|
+
module Sa
|
3
|
+
# YourMembership System Administrator Members Namespace
|
4
|
+
class People < YourMembership::Base
|
5
|
+
# Returns a list of member and non-member IDs that may be optionally filtered by timestamp. This method is
|
6
|
+
# provided for data synchronization purposes and will return a maximum of 10,000 results. It would typically be
|
7
|
+
# used in conjunction with subsequent calls to Sa.People.Profile.Get for each ID returned
|
8
|
+
#
|
9
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_People_All_GetIDs.htm
|
10
|
+
#
|
11
|
+
# @param [Hash] options
|
12
|
+
# @option options [DateTime] :Timestamp Only accounts created after the this time will be returned
|
13
|
+
# @option options [String] :WebsiteID Filter the returned results by sequential WebsiteID.
|
14
|
+
# @option options [Array] :Groups Filter the returned results by group membership. [key, value] will translate to
|
15
|
+
# <key>value</key>
|
16
|
+
#
|
17
|
+
# @return [Array] A list of API IDs for non-members in your community.
|
18
|
+
def self.all_getIDs(options = {}) # rubocop:disable Style/MethodName
|
19
|
+
response = post('/', :body => build_XML_request('Sa.People.All.GetIDs', nil, options))
|
20
|
+
response_valid? response
|
21
|
+
response['YourMembership_Response']['Sa.People.All.GetIDs']['People']['ID']
|
22
|
+
end
|
23
|
+
|
24
|
+
# Finds and returns a member or non-member <ID> using Import ID, Constituent ID or Website/Profile ID as criteria.
|
25
|
+
# If a single ID cannot be uniquely identified based on the criteria supplied then error code 406 is returned.
|
26
|
+
#
|
27
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_People_Profile_FindID.htm
|
28
|
+
#
|
29
|
+
# @param [Hash] options
|
30
|
+
# @option options [String] :ImportID Import ID of the person whose ID you are trying to find.
|
31
|
+
# @option options [String] :ConstituentID Constituent ID of the person whose ID you are trying to find.
|
32
|
+
# @option options [Integer] :WebsiteID Website/Profile ID of the person whose ID you are trying to find.
|
33
|
+
# @option options [String] :Username Username of the person whose ID you are trying to find.
|
34
|
+
# @option options [String] :Email Email Address of the person whose <ID> you are trying to find.
|
35
|
+
# May return multiple <ID>'s as Email Address is not unique.
|
36
|
+
#
|
37
|
+
# @return [String] if a single record is found (normal for all calls except for :Email)
|
38
|
+
# @return [Array] if multiple records are found (possible only for :Email searches)
|
39
|
+
def self.profile_findID(options = {}) # rubocop:disable Style/MethodName
|
40
|
+
response = post('/', :body => build_XML_request('Sa.People.Profile.FindID', nil, options))
|
41
|
+
response_valid? response
|
42
|
+
response['YourMembership_Response']['Sa.People.Profile.FindID']['ID']
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns a person's profile data.
|
46
|
+
#
|
47
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_People_Profile_Get.htm
|
48
|
+
#
|
49
|
+
# @param [String] id ID of the person whose profile data to return.
|
50
|
+
# @return [YourMembership::Profile] Returns a Profile object that represents the person's profile
|
51
|
+
def self.profile_get(id)
|
52
|
+
options = {}
|
53
|
+
options[:ID] = id
|
54
|
+
response = post('/', :body => build_XML_request('Sa.People.Profile.Get', nil, options))
|
55
|
+
response_valid? response
|
56
|
+
YourMembership::Profile.new response['YourMembership_Response']['Sa.People.Profile.Get']
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns a person's group relationship data. There are three types of relationships that members may have with
|
60
|
+
# particular groups; "Administrator", "Member" and "Representative". Groups are listed within nodes respective
|
61
|
+
# of their relationship type.
|
62
|
+
#
|
63
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_People_Profile_Groups_Get.htm
|
64
|
+
#
|
65
|
+
# @param [String] id ID of the person whose profile data to return.
|
66
|
+
# @return [Hash] Returns a Hash that represents the person's group relationships
|
67
|
+
def self.profile_groups_get(id)
|
68
|
+
options = {}
|
69
|
+
options[:ID] = id
|
70
|
+
response = post('/', :body => build_XML_request('Sa.People.Profile.Groups.Get', nil, options))
|
71
|
+
|
72
|
+
response_valid? response
|
73
|
+
response['YourMembership_Response']['Sa.People.Profile.Groups.Get']
|
74
|
+
end
|
75
|
+
|
76
|
+
# Updates an existing person's profile.
|
77
|
+
#
|
78
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_People_Profile_Update.htm
|
79
|
+
#
|
80
|
+
# @param [String] id ID of the person whose profile is to be updated.
|
81
|
+
# @param [YourMembership::Profile] profile The profile object containing the fields to be updated
|
82
|
+
# @return [Boolean] Will raise and exception or return TRUE
|
83
|
+
def self.profile_update(id, profile)
|
84
|
+
options = {}
|
85
|
+
options['ID'] = id
|
86
|
+
options['profile'] = profile
|
87
|
+
response = post('/', :body => build_XML_request('Sa.People.Profile.Update', nil, options))
|
88
|
+
response_valid? response
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
module YourMembership
|
2
|
+
# YourMembership Session Object
|
3
|
+
#
|
4
|
+
# Session objects encapsulate the creation, storage, authentication, maintenance, and destruction of sessions in the
|
5
|
+
# YourMembership.com API.
|
6
|
+
#
|
7
|
+
# @note It is important to note that the Auth Namespace has been consumed by Sessions in the SDK as sessions and
|
8
|
+
# authentication are inextricably linked.
|
9
|
+
#
|
10
|
+
# Sessions can be *generic* (unauthenticated), *authenticated*, or *abandoned*.
|
11
|
+
#
|
12
|
+
# * *Generic sessions* are used extensively whenever the scope of a specific user is not necessary.
|
13
|
+
# * *Authenticated sessions* are used when the called method requires the scope of a specific user.
|
14
|
+
# * *Abandoned sessions* are no longer usable and are essentially the same as logging out.
|
15
|
+
#
|
16
|
+
# @example Generic (unauthenticated) Session
|
17
|
+
# session = YourMembership::Session.new # => <YourMembership::Session>
|
18
|
+
# @example Authenticated Session
|
19
|
+
# auth_session = YourMembership::Session.new 'username', 'password' # => <YourMembership::Session>
|
20
|
+
#
|
21
|
+
# @attr_reader [String] session_id The unique session identifier provided by the API
|
22
|
+
# @attr_reader [String, Nil] user_id The user id of the user bound to the session, if one exists.
|
23
|
+
class Session < YourMembership::Base
|
24
|
+
attr_reader :session_id, :user_id
|
25
|
+
|
26
|
+
# @see https://api.yourmembership.com/reference/2_00/Session_Create.htm
|
27
|
+
# @param user_name [String] Constructor takes optional parameters of user_name and password. If supplied then the
|
28
|
+
# session will be automatically authenticated upon instantiation.
|
29
|
+
# @param password [String]
|
30
|
+
def initialize(user_name = nil, password = nil)
|
31
|
+
@call_id = 1
|
32
|
+
@user_id = nil
|
33
|
+
|
34
|
+
response = self.class.post('/', :body => self.class.build_XML_request('Session.Create'))
|
35
|
+
|
36
|
+
if self.class.response_valid? response
|
37
|
+
@session_id = response['YourMembership_Response']['Session.Create']['SessionID']
|
38
|
+
end
|
39
|
+
|
40
|
+
authenticate user_name, password if user_name
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Integer] Auto Increments ad returns the call_id for the session as required by the YourMembership.com API
|
44
|
+
def call_id
|
45
|
+
@call_id += 1
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [String] Returns the session_id
|
49
|
+
def to_s
|
50
|
+
@session_id
|
51
|
+
end
|
52
|
+
|
53
|
+
# Destroys an API session, thus preventing any further calls against it.
|
54
|
+
#
|
55
|
+
# @see https://api.yourmembership.com/reference/2_00/Session_Abandon.htm
|
56
|
+
#
|
57
|
+
# @return [Boolean] Returns true if the session was alive and successfully abandoned.
|
58
|
+
def abandon
|
59
|
+
response = self.class.post('/', :body => self.class.build_XML_request('Session.Abandon', self))
|
60
|
+
self.class.response_valid? response
|
61
|
+
end
|
62
|
+
|
63
|
+
# When called at intervals of less than 20 minutes, this method acts as an API session keep-alive.
|
64
|
+
#
|
65
|
+
# @see https://api.yourmembership.com/reference/2_00/Session_Ping.htm
|
66
|
+
#
|
67
|
+
# @return [Boolean] Returns true if the session is still alive.
|
68
|
+
def ping
|
69
|
+
response = self.class.post('/', :body => self.class.build_XML_request('Session.Ping', self))
|
70
|
+
self.class.response_valid? response
|
71
|
+
response['YourMembership_Response']['Session.Ping'] == '1'
|
72
|
+
end
|
73
|
+
|
74
|
+
# Convenience method for ping.
|
75
|
+
def valid?
|
76
|
+
ping
|
77
|
+
end
|
78
|
+
|
79
|
+
# Authenticates a member's username and password and binds them to the current API session.
|
80
|
+
#
|
81
|
+
# @see https://api.yourmembership.com/reference/2_00/Auth_Authenticate.htm
|
82
|
+
#
|
83
|
+
# @param user_name [String] The username of the member that is being authenticated.
|
84
|
+
# @param password [String] The clear text password of the member that is being authenticated.
|
85
|
+
#
|
86
|
+
# @return [Hash] Returns the member's ID and WebsiteID. The returned WebsiteID represents the numeric identifier
|
87
|
+
# used by the YourMembership.com application for navigation purposes. It may be used to provide direct navigation to
|
88
|
+
# a member's profile, photo gallery, personal blog, etc.
|
89
|
+
def authenticate(user_name, password)
|
90
|
+
options = {}
|
91
|
+
options[:Username] = user_name
|
92
|
+
options[:Password] = password
|
93
|
+
|
94
|
+
response = self.class.post('/', :body => self.class.build_XML_request('Auth.Authenticate', self, options))
|
95
|
+
|
96
|
+
self.class.response_valid? response
|
97
|
+
if response['YourMembership_Response']['Auth.Authenticate']
|
98
|
+
get_authenticated_user
|
99
|
+
else
|
100
|
+
false
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Creates an AuthToken that is bound to the current session. The returned token must be supplied to the Sign-In
|
105
|
+
# form during member authentication in order to bind a member to their API session. The sign-in URL, which will
|
106
|
+
# include the new AuthToken in its query-string, is returned by this method as GoToUrl. Tokens expire after a short
|
107
|
+
# period of time, so it is suggested that the user be immediately redirected the returned GoToUrl after creating an
|
108
|
+
# authentication token.
|
109
|
+
#
|
110
|
+
# @see https://api.yourmembership.com/reference/2_00/Auth_CreateToken.htm
|
111
|
+
#
|
112
|
+
# @param options [Hash]
|
113
|
+
# @option options [String] :RetUrl After authentication the browser will be redirected to this URL
|
114
|
+
# @option options [String] :Username The user can optionally be logged in automatically if :Username and :Password
|
115
|
+
# are supplied in cleartext.
|
116
|
+
# @option options [String] :Password The user's password
|
117
|
+
# @option options [Boolean] :Persist Supplying this value is only necessary when also providing user credentials for
|
118
|
+
# automated authentication. The purpose of enabling persistence is to extend an authenticated user's browsing
|
119
|
+
# session beyond its normal inactivity threshold of 20 minutes.
|
120
|
+
#
|
121
|
+
# @return [Hash] Contains the token String and a URL that will authenticate the session based on that token.
|
122
|
+
def createToken(options = {}) # rubocop:disable Style/MethodName
|
123
|
+
# Options inlclude: :RetUrl(String), :Username(String),
|
124
|
+
# :Password(String), :Persist(Boolean)
|
125
|
+
|
126
|
+
response = self.class.post('/', :body => self.class.build_XML_request('Auth.CreateToken', self, options))
|
127
|
+
|
128
|
+
self.class.response_valid? response
|
129
|
+
response['YourMembership_Response']['Auth.CreateToken']
|
130
|
+
end
|
131
|
+
|
132
|
+
# Indicates whether the session is bound to a user.
|
133
|
+
def authenticated?
|
134
|
+
if valid?
|
135
|
+
!get_authenticated_user.nil?
|
136
|
+
else
|
137
|
+
false
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Get the ID of the currently authenticated user bound to this session.
|
142
|
+
# @return [String, Nil] The API ID of the currently authenticated user
|
143
|
+
def get_authenticated_user # rubocop:disable Style/AccessorMethodName
|
144
|
+
@user_id = YourMembership::Member.isAuthenticated(self)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "nokogiri"
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
require "httparty/patch"
|
6
|
+
|
7
|
+
require "your_membership/error"
|
8
|
+
require "your_membership/config"
|
9
|
+
require "your_membership/base"
|
10
|
+
require "your_membership/session"
|
11
|
+
require "your_membership/profile"
|
12
|
+
require "your_membership/member"
|
13
|
+
require "your_membership/commerce"
|
14
|
+
require "your_membership/members"
|
15
|
+
require "your_membership/convert"
|
16
|
+
require "your_membership/sa_auth"
|
17
|
+
require "your_membership/sa_members"
|
18
|
+
require "your_membership/sa_certifications"
|
19
|
+
require "your_membership/sa_commerce"
|
20
|
+
require "your_membership/sa_events"
|
21
|
+
require "your_membership/sa_export"
|
22
|
+
require "your_membership/sa_groups"
|
23
|
+
require "your_membership/sa_member"
|
24
|
+
require "your_membership/sa_nonmembers"
|
25
|
+
require "your_membership/sa_people"
|
26
|
+
require "your_membership/events"
|
27
|
+
require "your_membership/feeds"
|
28
|
+
require "your_membership/people"
|
29
|
+
|
30
|
+
require "your_membership/version"
|
31
|
+
|
32
|
+
# Ruby SDK for YourMembership.Com XML API
|
33
|
+
# @author Nate Flood <nflood@echonet.org>
|
34
|
+
# @version 2.00
|
35
|
+
# @see http://www.yourmembership.com/company/api-reference.aspx
|
36
|
+
module YourMembership
|
37
|
+
end
|